Java Code Examples for com.bigdata.rdf.model.StatementEnum#MASK_OVERRIDE

The following examples show how to use com.bigdata.rdf.model.StatementEnum#MASK_OVERRIDE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SPOTupleSerializer.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
     * Return the byte[] that would be written into a statement index for this
     * {@link SPO}, including the optional {@link StatementEnum#MASK_OVERRIDE}
     * bit. If the statement identifier is non-null then it will be included in
     * the returned byte[].
     * 
     * @param override
     *            <code>true</code> iff you want the
     *            {@link StatementEnum#MASK_OVERRIDE} bit set (this is only set
     *            when serializing values for a remote procedure that will write
     *            on the index, it is never set in the index itself).
     * @param userFlag
     *            <code>true</code> iff you want the
     *            {@link StatementEnum#MASK_USER_FLAG} bit set.
     * @param type
     *            The {@link StatementEnum}.
     * 
     * @return The value that would be written into a statement index for this
     *         {@link SPO}.
     */
//    * @param buf
//    *            A buffer supplied by the caller. The buffer will be reset
//    *            before the value is written on the buffer.
    public byte[] serializeVal(//final ByteArrayBuffer buf,
            final boolean override, final boolean userFlag,
            final StatementEnum type) {
        
//      buf.reset();

        // optionally set the override and user flag bits on the value.
        final byte b = (byte) 
            (type.code()
                | (override ? StatementEnum.MASK_OVERRIDE : 0x0) 
                | (userFlag ? StatementEnum.MASK_USER_FLAG : 0x0)
                );

//      buf.putByte(b);
//
//      final byte[] a = buf.toByteArray();
//
//        assert a.length == 1 : "Expecting one byte, but have "
//                + BytesUtil.toString(a);
        
        return RDFValueFactory.getValue(b);

    }
 
Example 2
Source File: HistoryIndexTupleSerializer.java    From database with GNU General Public License v2.0 3 votes vote down vote up
@Override
   public byte[] serializeVal(final HistoryChangeRecord changeRecord) {

       if (changeRecord == null)
           throw new IllegalArgumentException();

       final ISPO spo = changeRecord.getStatement();

       final boolean override = spo.isOverride();

       final boolean userFlag = spo.getUserFlag();

       final StatementEnum type = spo.getStatementType();

       // optionally set the override and user flag bits on the value.
       final byte lowNibble = (byte) //
           (type.code()// statement type
               | (override ? StatementEnum.MASK_OVERRIDE : 0x0) //
               | (userFlag ? StatementEnum.MASK_USER_FLAG : 0x0)//
               );
               
       final byte highNibble = (byte) changeRecord.getChangeAction().ordinal();

       final byte b = (byte) (0xff & (highNibble << 4 | lowNibble));

       return new byte[] { b };

}