private static boolean encodeLatin1( int keyId, String string, PropertyBlock target ) { int length = string.length(); Bits bits = newBitsForStep8(length); writeHeader( bits, keyId, ENCODING_LATIN1, length ); if ( !writeLatin1Characters( string, bits ) ) { return false; } target.setValueBlocks( bits.getLongs() ); return true; }
private static boolean encodeUTF8( int keyId, String string, PropertyBlock target, int payloadSize ) { byte[] bytes = string.getBytes( StandardCharsets.UTF_8 ); final int length = bytes.length; if ( length > payloadSize - 3/*key*/ - 2/*enc+len*/ ) { return false; } Bits bits = newBitsForStep8(length); writeHeader( bits, keyId, ENCODING_UTF8, length); // In this case it isn't the string length, but the number of bytes for ( byte value : bytes ) { bits.put( value ); } target.setValueBlocks( bits.getLongs() ); return true; }
static boolean tryInlineInNodeRecord( NodeRecord node, long[] ids, Collection<DynamicRecord> changedDynamicRecords ) { // We reserve the high header bit for future extensions of the format of the in-lined label bits // i.e. the 0-valued high header bit can allow for 0-7 in-lined labels in the bit-packed format. if ( ids.length > 7 ) { return false; } byte bitsPerLabel = (byte) (ids.length > 0 ? (LABEL_BITS / ids.length) : LABEL_BITS); Bits bits = bits( 5 ); if ( !inlineValues( ids, bitsPerLabel, bits ) ) { return false; } node.setLabelField( combineLabelCountAndLabelStorage( (byte) ids.length, bits.getLongs()[0] ), changedDynamicRecords ); return true; }
private long inlinedLabelsLongRepresentation( long... labelIds ) { long header = (long) labelIds.length << 36; byte bitsPerLabel = (byte) (36 / labelIds.length); Bits bits = bits( 5 ); for ( long labelId : labelIds ) { bits.put( labelId, bitsPerLabel ); } return header | bits.getLongs()[0]; }
private long inlinedLabelsLongRepresentation( long... labelIds ) { long header = (long) labelIds.length << 36; byte bitsPerLabel = (byte) (36 / labelIds.length); Bits bits = bits( 5 ); for ( long labelId : labelIds ) { bits.put( labelId, bitsPerLabel ); } return header | bits.getLongs()[0]; }
private boolean doEncode( int keyId, byte[] data, PropertyBlock target, int payloadSize, final int length ) { if ( length > maxLength( payloadSize ) ) { return false; } Bits bits = newBits( this, length ); writeHeader( bits, keyId, encodingHeader, length ); if ( length > 0 ) { translateData( bits, data, length, step ); } target.setValueBlocks( bits.getLongs() ); return true; }
target.setValueBlocks( result.getLongs() ); return true;
putClient.fieldBits.put( labelIds.length, bitsPerLabel ); putClient.fieldBits.put( spillOverIndex, Long.SIZE - bitsPerLabel ); cache.set( nodeId, putClient.fieldBits.getLongs()[0] );
private static boolean encodeLatin1( int keyId, String string, PropertyBlock target ) { int length = string.length(); Bits bits = newBitsForStep8(length); writeHeader( bits, keyId, ENCODING_LATIN1, length ); if ( !writeLatin1Characters( string, bits ) ) { return false; } target.setValueBlocks( bits.getLongs() ); return true; }
private static boolean encodeUTF8( int keyId, String string, PropertyBlock target, int payloadSize ) { byte[] bytes = string.getBytes( StandardCharsets.UTF_8 ); final int length = bytes.length; if ( length > payloadSize - 3/*key*/ - 2/*enc+len*/ ) { return false; } Bits bits = newBitsForStep8(length); writeHeader( bits, keyId, ENCODING_UTF8, length); // In this case it isn't the string length, but the number of bytes for ( byte value : bytes ) { bits.put( value ); } target.setValueBlocks( bits.getLongs() ); return true; }
static boolean tryInlineInNodeRecord( NodeRecord node, long[] ids, Collection<DynamicRecord> changedDynamicRecords ) { // We reserve the high header bit for future extensions of the format of the in-lined label bits // i.e. the 0-valued high header bit can allow for 0-7 in-lined labels in the bit-packed format. if ( ids.length > 7 ) { return false; } byte bitsPerLabel = (byte) (ids.length > 0 ? (LABEL_BITS / ids.length) : LABEL_BITS); Bits bits = bits( 5 ); if ( !inlineValues( ids, bitsPerLabel, bits ) ) { return false; } node.setLabelField( combineLabelCountAndLabelStorage( (byte) ids.length, bits.getLongs()[0] ), changedDynamicRecords ); return true; }
private long inlinedLabelsLongRepresentation( long... labelIds ) { long header = (long) labelIds.length << 36; byte bitsPerLabel = (byte) (36 / labelIds.length); Bits bits = bits( 5 ); for ( long labelId : labelIds ) { bits.put( labelId, bitsPerLabel ); } return header | bits.getLongs()[0]; }
private boolean doEncode( int keyId, byte[] data, PropertyBlock target, int payloadSize, final int length ) { if ( length > maxLength( payloadSize ) ) { return false; } Bits bits = newBits( this, length ); writeHeader( bits, keyId, encodingHeader, length ); if ( length > 0 ) { translateData( bits, data, length, step ); } target.setValueBlocks( bits.getLongs() ); return true; }
target.setValueBlocks( result.getLongs() ); return true;
putClient.fieldBits.put( labelIds.length, bitsPerLabel ); putClient.fieldBits.put( spillOverIndex, Long.SIZE - bitsPerLabel ); cache.set( nodeId, putClient.fieldBits.getLongs()[0] );