private PropertyBlock nextPropertyBlock() { if ( propertyBlocksCursor == propertyBlocks.length ) { propertyBlocks = Arrays.copyOf( propertyBlocks, propertyBlocksCursor * 2 ); for ( int i = propertyBlocksCursor; i < propertyBlocks.length; i++ ) { propertyBlocks[i] = new PropertyBlock(); } } return propertyBlocks[propertyBlocksCursor++]; }
public PropertyBlock encodePropertyValue( int propertyKey, Value value ) { return encodeValue( new PropertyBlock(), propertyKey, value ); }
private PropertyBlock property( long key, Value value ) { PropertyBlock block = new PropertyBlock(); store.encodeValue( block, (int) key, value ); return block; }
@Override public PropertyBlock clone() { PropertyBlock result = new PropertyBlock(); if ( valueBlocks != null ) { result.valueBlocks = valueBlocks.clone(); } if ( valueRecords != null ) { for ( DynamicRecord valueRecord : valueRecords ) { result.addValueRecord( valueRecord.clone() ); } } return result; }
private void assertCanNotEncode( Object intArray, int payloadSize ) { assertFalse( ShortArray.encode( 0, intArray, new PropertyBlock(), payloadSize ) ); }
private void assertCannotEncode( String string, int payloadSize ) { assertFalse( LongerShortString.encode( 0, string, new PropertyBlock(), payloadSize ) ); } }
@Override protected PropertyBlock fetchNextOrNull() { if ( i >= propertyCount ) { return null; } PropertyBlock block = new PropertyBlock(); propertyStore.encodeValue( block, i, random.nextValue() ); i++; return block; } };
private void expectInvalidPropertyValue( PropertyRecord property, long[] longs ) { PropertyBlock block = new PropertyBlock(); block.setValueBlocks( longs ); property.addPropertyBlock( block ); // when ConsistencyReport.PropertyConsistencyReport report = check( property ); // then verify( report ).invalidPropertyValue( block ); verifyNoMoreInteractions( report ); }
public static PropertyBlock propertyBlock( PropertyKeyTokenRecord key, PropertyType type, long value ) { PropertyBlock block = new PropertyBlock(); block.setSingleBlock( key.getId() | (((long) type.intValue()) << 24) | (value << 28) ); return block; }
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 assertCanEncodeAndDecodeToSameValue( Object value, int payloadSize ) { PropertyBlock target = new PropertyBlock(); boolean encoded = ShortArray.encode( 0, value, target, payloadSize ); assertTrue( encoded ); assertEquals( Values.of( value ), ShortArray.decode( target ) ); } }
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; } } );
private void assertCanEncodeAndDecodeToSame( String string, int payloadSize ) { PropertyBlock target = new PropertyBlock(); assertTrue( LongerShortString.encode( 0, string, target, payloadSize ) ); assertEquals( Values.stringValue( string ), LongerShortString.decode( target ) ); }
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 PropertyBlock propertyBlockWith( DynamicRecord dynamicRecord ) { PropertyBlock propertyBlock = new PropertyBlock(); PropertyKeyTokenRecord key = new PropertyKeyTokenRecord( 10 ); propertyBlock.setSingleBlock( key.getId() | (((long) PropertyType.STRING.intValue()) << 24) | (dynamicRecord .getId() << 28) ); propertyBlock.addValueRecord( dynamicRecord ); return propertyBlock; } }
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 void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { // structurally correct, but does not have the 'mandatory' property with the 'draconian' label NodeRecord node = new NodeRecord( next.node(), false, -1, next.property() ); node.setInUse( true ); node.setLabelField( inlinedLabelsLongRepresentation( draconian ), Collections.emptySet() ); PropertyRecord property = new PropertyRecord( node.getNextProp(), node ); property.setInUse( true ); PropertyBlock block = new PropertyBlock(); block.setSingleBlock( key1 | (((long) PropertyType.INT.intValue()) << 24) | (1337L << 28) ); property.addPropertyBlock( block ); tx.create( node ); tx.create( property ); } } );
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { DynamicRecord string = new DynamicRecord( next.stringProperty() ); string.setInUse( true ); string.setCreated(); string.setType( PropertyType.STRING.intValue() ); string.setNextBlock( next.stringProperty() ); string.setData( UTF8.encode( "hello world" ) ); PropertyBlock block = new PropertyBlock(); block.setSingleBlock( (((long) PropertyType.STRING.intValue()) << 24) | (string.getId() << 28) ); block.addValueRecord( string ); PropertyRecord property = new PropertyRecord( next.property() ); property.addPropertyBlock( block ); tx.create( property ); } } );
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { DynamicRecord array = new DynamicRecord( next.arrayProperty() ); array.setInUse( true ); array.setCreated(); array.setType( ARRAY.intValue() ); array.setNextBlock( next.arrayProperty() ); array.setData( UTF8.encode( "hello world" ) ); PropertyBlock block = new PropertyBlock(); block.setSingleBlock( (((long) ARRAY.intValue()) << 24) | (array.getId() << 28) ); block.addValueRecord( array ); PropertyRecord property = new PropertyRecord( next.property() ); property.addPropertyBlock( block ); tx.create( property ); } } );