public PropertyBlock encodeValue( PropertyBlock block, int propertyKey, Value value ) { PropertyStore.encodeValue( block, propertyKey, value, stringRecordAllocator, arrayRecordAllocator, allowStorePointsAndTemporal ); return block; }
public void encodeValue( PropertyBlock block, int keyId, Value value ) { encodeValue( block, keyId, value, stringStore, arrayStore, allowStorePointsAndTemporal ); }
private void encodeProperty( PropertyBlock block, int key, Object value ) { PropertyStore.encodeValue( block, key, ValueUtils.asValue( value ), dynamicStringRecordAllocator, dynamicArrayRecordAllocator, propertyStore.allowStorePointsAndTemporal() ); }
private PropertyBlock property( long key, Value value ) { PropertyBlock block = new PropertyBlock(); store.encodeValue( block, (int) key, value ); return block; }
@Override protected PropertyBlock fetchNextOrNull() { if ( i >= propertyCount ) { return null; } PropertyBlock block = new PropertyBlock(); propertyStore.encodeValue( block, i, random.nextValue() ); i++; return block; } };
@Override public int applyAsInt( Value[] values ) { stringRecordIds.reset(); arrayRecordIds.reset(); int propertyRecordsUsed = 0; int freeBlocksInCurrentRecord = 0; for ( Value value : values ) { PropertyBlock block = new PropertyBlock(); PropertyStore.encodeValue( block, 0 /*doesn't matter*/, value, stringRecordCounter, arrayRecordCounter, true ); if ( block.getValueBlocks().length > freeBlocksInCurrentRecord ) { propertyRecordsUsed++; freeBlocksInCurrentRecord = PropertyType.getPayloadSizeLongs(); } freeBlocksInCurrentRecord -= block.getValueBlocks().length; } int size = propertyRecordsUsed * propertyRecordSize; size += toIntExact( stringRecordIds.peek() ) * stringRecordSize; size += toIntExact( arrayRecordIds.peek() ) * arrayRecordSize; return size; } }
private static void addBlock( PropertyRecord record, int key, int value ) { PropertyBlock block = new PropertyBlock(); PropertyStore.encodeValue( block, key, Values.of( value ), null, null, true ); for ( long valueBlock : block.getValueBlocks() ) { record.addLoadedBlock( valueBlock ); } } }
private void encode( String string ) { PropertyBlock block = new PropertyBlock(); TextValue expectedValue = Values.stringValue( string ); propertyStore.encodeValue( block, KEY_ID, expectedValue ); assertEquals( 0, block.getValueRecords().size() ); Value readValue = block.getType().value( block, propertyStore ); assertEquals( expectedValue, readValue ); } }
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() ); }
private PropertyRecord propertyRecordWithSingleIntProperty( long id, int propertyKeyId, long prev, long next ) { PropertyRecord record = new PropertyRecord( id ).initialize( true, prev, next ); PropertyBlock block = new PropertyBlock(); PropertyStore.encodeValue( block, propertyKeyId, Values.intValue( 10 ), null, null, false ); record.addPropertyBlock( block ); return record; } } );
@Override public boolean id( Object id, Group group ) { long nodeId = nodeIds.next(); nodeRecord.setId( nodeId ); idMapper.put( id, nodeId, group ); // also store this id as property in temp property store if ( id != null ) { idPropertyStore.encodeValue( idPropertyBlock, 0, Values.of( id ) ); idPropertyRecord.addPropertyBlock( idPropertyBlock ); idPropertyRecord.setId( nodeId ); // yes nodeId idPropertyRecord.setInUse( true ); idPropertyStore.updateRecord( idPropertyRecord ); idPropertyRecord.clear(); } return true; }
private <RECORD extends AbstractBaseRecord> void createRecordIn( RecordStore<RECORD> store ) { RECORD record = store.newRecord(); record.setId( store.nextId() ); record.setInUse( true ); if ( record instanceof PropertyRecord ) { // Special hack for property store, since it's not enough to simply set a record as in use there PropertyBlock block = new PropertyBlock(); ((PropertyStore)store).encodeValue( block, 0, Values.of( 10 ) ); ((PropertyRecord) record).addPropertyBlock( block ); } store.updateRecord( record ); }
@Override protected PropertyRecord createExistingRecord( boolean light ) { PropertyRecord record = new PropertyRecord( ID ); record.setId( ID ); record.setNextProp( 2 ); record.setPrevProp( 4 ); record.setInUse( true ); PropertyBlock block = new PropertyBlock(); DynamicRecordAllocator stringAllocator = new ReusableRecordsAllocator( 64, new DynamicRecord( 7 ) ); Value value = Values.of( "a string too large to fit in the property block itself" ); PropertyStore.encodeValue( block, 6, value, stringAllocator, null, true ); if ( light ) { block.getValueRecords().clear(); } record.setPropertyBlock( block ); return record; }
public static PropertyCommand createProperty( long id, PropertyType type, int key, long... valueRecordIds ) { PropertyRecord record = new PropertyRecord( id ); record.setInUse( true ); record.setCreated(); PropertyBlock block = new PropertyBlock(); if ( valueRecordIds.length == 0 ) { PropertyStore.encodeValue( block, key, Values.of( 123 ), null, null, true ); } else { PropertyStore.setSingleBlockValue( block, key, type, valueRecordIds[0] ); block.setValueRecords( dynamicRecords( valueRecordIds ) ); } record.addPropertyBlock( block ); return new PropertyCommand( new PropertyRecord( id ), record ); }
@Override public Generator<PropertyRecord> property() { return ( recordSize, format, recordId ) -> { PropertyRecord record = new PropertyRecord( recordId ); int maxProperties = random.intBetween( 1, 4 ); StandaloneDynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator(); StandaloneDynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator(); record.setInUse( true ); int blocksOccupied = 0; for ( int i = 0; i < maxProperties && blocksOccupied < 4; ) { PropertyBlock block = new PropertyBlock(); // Dynamic records will not be written and read by the property record format, // that happens in the store where it delegates to a "sub" store. PropertyStore.encodeValue( block, random.nextInt( tokenBits ), random.nextValue(), stringAllocator, arrayAllocator, true ); int tentativeBlocksWithThisOne = blocksOccupied + block.getValueBlocks().length; if ( tentativeBlocksWithThisOne <= 4 ) { record.addPropertyBlock( block ); blocksOccupied = tentativeBlocksWithThisOne; } } record.setPrevProp( randomLongOrOccasionallyNull( propertyBits ) ); record.setNextProp( randomLongOrOccasionallyNull( propertyBits ) ); return record; }; }
public PropertyBlock encodeValue( PropertyBlock block, int propertyKey, Value value ) { PropertyStore.encodeValue( block, propertyKey, value, stringRecordAllocator, arrayRecordAllocator, allowStorePointsAndTemporal ); return block; }
public void encodeValue( PropertyBlock block, int keyId, Value value ) { encodeValue( block, keyId, value, stringStore, arrayStore, allowStorePointsAndTemporal ); }
private void encodeProperty( PropertyBlock block, int key, Object value ) { PropertyStore.encodeValue( block, key, ValueUtils.asValue( value ), dynamicStringRecordAllocator, dynamicArrayRecordAllocator, propertyStore.allowStorePointsAndTemporal() ); }
@Override public int applyAsInt( Value[] values ) { stringRecordIds.reset(); arrayRecordIds.reset(); int propertyRecordsUsed = 0; int freeBlocksInCurrentRecord = 0; for ( Value value : values ) { PropertyBlock block = new PropertyBlock(); PropertyStore.encodeValue( block, 0 /*doesn't matter*/, value, stringRecordCounter, arrayRecordCounter, true ); if ( block.getValueBlocks().length > freeBlocksInCurrentRecord ) { propertyRecordsUsed++; freeBlocksInCurrentRecord = PropertyType.getPayloadSizeLongs(); } freeBlocksInCurrentRecord -= block.getValueBlocks().length; } int size = propertyRecordsUsed * propertyRecordSize; size += toIntExact( stringRecordIds.peek() ) * stringRecordSize; size += toIntExact( arrayRecordIds.peek() ) * arrayRecordSize; return size; } }
@Override public boolean id( Object id, Group group ) { long nodeId = nodeIds.next(); nodeRecord.setId( nodeId ); idMapper.put( id, nodeId, group ); // also store this id as property in temp property store if ( id != null ) { idPropertyStore.encodeValue( idPropertyBlock, 0, Values.of( id ) ); idPropertyRecord.addPropertyBlock( idPropertyBlock ); idPropertyRecord.setId( nodeId ); // yes nodeId idPropertyRecord.setInUse( true ); idPropertyStore.updateRecord( idPropertyRecord ); idPropertyRecord.clear(); } return true; }