private boolean propertyFitsInside( int newBlockSizeInBytes, PropertyRecord propRecord ) { int propSize = propRecord.size(); assert propSize >= 0 : propRecord; return propSize + newBlockSizeInBytes <= PropertyType.getPayloadSize(); }
if ( i == PropertyType.getPayloadSize() - 1 && j != propRecCount - 1 ) else if ( i == PropertyType.getPayloadSize() - 1 && j == propRecCount - 1 )
private static boolean encodeWithCharSet( int keyId, String string, PropertyBlock target, int payloadSize, int stringLength ) { int maxBytes = PropertyType.getPayloadSize(); if ( stringLength <= maxBytes - 5 ) { return encodeLatin1( keyId, string, target ) || encodeUTF8( keyId, string, target, payloadSize ); } return false; }
private void assertCanEncodeAndDecodeToSameValue( Object value ) { assertCanEncodeAndDecodeToSameValue( value, PropertyType.getPayloadSize() ); }
assert propRecord.inUse() : primitive + "->" + Arrays.toString( toCheck.toArray() ); assert propRecord.size() <= PropertyType.getPayloadSize() : propRecord + " size " + propRecord.size(); nextIdToFetch = propRecord.getNextProp();
public void addPropertyBlock( PropertyBlock block ) { ensureBlocksLoaded(); assert size() + block.getSize() <= PropertyType.getPayloadSize() : "Exceeded capacity of property record " + this + ". My current size is reported as " + size() + "The added block was " + block + " (note that size is " + block.getSize() + ")"; blockRecords[blockRecordsCursor++] = block; }
@Override public void writeString( String value ) throws IllegalArgumentException { // Try short string first, i.e. inlined in the property block if ( LongerShortString.encode( keyId, value, block, PropertyType.getPayloadSize() ) ) { return; } // Fall back to dynamic string store byte[] encodedString = encodeString( value ); List<DynamicRecord> valueRecords = new ArrayList<>(); allocateStringRecords( valueRecords, encodedString, stringAllocator ); setSingleBlockValue( block, keyId, PropertyType.STRING, Iterables.first( valueRecords ).getId() ); for ( DynamicRecord valueRecord : valueRecords ) { valueRecord.setType( PropertyType.STRING.intValue() ); } block.setValueRecords( valueRecords ); }
if ( currentRecord.size() + block.getSize() > PropertyType.getPayloadSize() )
private void existingRecord( PropertyRecord record, ExpectedRecord initialRecord ) { for ( ExpectedProperty initialProperty : initialRecord.properties ) { PropertyBlock block = new PropertyBlock(); propertyStore.encodeValue( block, initialProperty.key, initialProperty.value ); record.addPropertyBlock( block ); } assertTrue( record.size() <= PropertyType.getPayloadSize() ); }
public static void encodeValue( PropertyBlock block, int keyId, Value value, DynamicRecordAllocator stringAllocator, DynamicRecordAllocator arrayAllocator, boolean allowStorePointsAndTemporal ) { if ( value instanceof ArrayValue ) { Object asObject = value.asObject(); // Try short array first, i.e. inlined in the property block if ( ShortArray.encode( keyId, asObject, block, PropertyType.getPayloadSize() ) ) { return; } // Fall back to dynamic array store List<DynamicRecord> arrayRecords = new ArrayList<>(); allocateArrayRecords( arrayRecords, asObject, arrayAllocator, allowStorePointsAndTemporal ); setSingleBlockValue( block, keyId, PropertyType.ARRAY, Iterables.first( arrayRecords ).getId() ); for ( DynamicRecord valueRecord : arrayRecords ) { valueRecord.setType( PropertyType.ARRAY.intValue() ); } block.setValueRecords( arrayRecords ); } else { value.writeTo( new PropertyBlockValueWriter( block, keyId, stringAllocator, allowStorePointsAndTemporal ) ); } }
if ( currentRecord.size() + block.getSize() > PropertyType.getPayloadSize() )
private boolean propertyFitsInside( int newBlockSizeInBytes, PropertyRecord propRecord ) { int propSize = propRecord.size(); assert propSize >= 0 : propRecord; return propSize + newBlockSizeInBytes <= PropertyType.getPayloadSize(); }
private static boolean encodeWithCharSet( int keyId, String string, PropertyBlock target, int payloadSize, int stringLength ) { int maxBytes = PropertyType.getPayloadSize(); if ( stringLength <= maxBytes - 5 ) { return encodeLatin1( keyId, string, target ) || encodeUTF8( keyId, string, target, payloadSize ); } return false; }
assert propRecord.inUse() : primitive + "->" + Arrays.toString( toCheck.toArray() ); assert propRecord.size() <= PropertyType.getPayloadSize() : propRecord + " size " + propRecord.size(); nextIdToFetch = propRecord.getNextProp();
public void addPropertyBlock( PropertyBlock block ) { ensureBlocksLoaded(); assert size() + block.getSize() <= PropertyType.getPayloadSize() : "Exceeded capacity of property record " + this + ". My current size is reported as " + size() + "The added block was " + block + " (note that size is " + block.getSize() + ")"; blockRecords[blockRecordsCursor++] = block; }
@Override public void writeString( String value ) throws IllegalArgumentException { // Try short string first, i.e. inlined in the property block if ( LongerShortString.encode( keyId, value, block, PropertyType.getPayloadSize() ) ) { return; } // Fall back to dynamic string store byte[] encodedString = encodeString( value ); List<DynamicRecord> valueRecords = new ArrayList<>(); allocateStringRecords( valueRecords, encodedString, stringAllocator ); setSingleBlockValue( block, keyId, PropertyType.STRING, Iterables.first( valueRecords ).getId() ); for ( DynamicRecord valueRecord : valueRecords ) { valueRecord.setType( PropertyType.STRING.intValue() ); } block.setValueRecords( valueRecords ); }
if ( currentRecord.size() + block.getSize() > PropertyType.getPayloadSize() )
public static void encodeValue( PropertyBlock block, int keyId, Value value, DynamicRecordAllocator stringAllocator, DynamicRecordAllocator arrayAllocator, boolean allowStorePointsAndTemporal ) { if ( value instanceof ArrayValue ) { Object asObject = value.asObject(); // Try short array first, i.e. inlined in the property block if ( ShortArray.encode( keyId, asObject, block, PropertyType.getPayloadSize() ) ) { return; } // Fall back to dynamic array store List<DynamicRecord> arrayRecords = new ArrayList<>(); allocateArrayRecords( arrayRecords, asObject, arrayAllocator, allowStorePointsAndTemporal ); setSingleBlockValue( block, keyId, PropertyType.ARRAY, Iterables.first( arrayRecords ).getId() ); for ( DynamicRecord valueRecord : arrayRecords ) { valueRecord.setType( PropertyType.ARRAY.intValue() ); } block.setValueRecords( arrayRecords ); } else { value.writeTo( new PropertyBlockValueWriter( block, keyId, stringAllocator, allowStorePointsAndTemporal ) ); } }
if ( currentRecord.size() + block.getSize() > PropertyType.getPayloadSize() )