Dynamic( RecordType type, DynamicRecord record ) { this.type = type; this.id = record.getId(); }
public static String payloadTooBigErrorMessage( DynamicRecord record, int recordSize, int nrOfBytes ) { return format( "DynamicRecord[%s] claims to have a payload of %s bytes, " + "which is larger than the record size of %s bytes.", record.getId(), nrOfBytes, recordSize ); }
public static long dynamicPointer( Collection<DynamicRecord> newRecords ) { return 0x8000000000L | Iterables.first( newRecords ).getId(); }
public SchemaRecord initialize( Collection<DynamicRecord> records ) { initialize( true ); Iterator<DynamicRecord> iterator = records.iterator(); long id = iterator.hasNext() ? iterator.next().getId() : NULL_REFERENCE.intValue(); setId( id ); this.records = records; return this; }
private long dynamicLabelsLongRepresentation( Iterable<DynamicRecord> records ) { return 0x8000000000L | Iterables.first( records ).getId(); }
public SchemaRuleCommand( SchemaRecord recordsBefore, SchemaRecord recordsAfter, SchemaRule schemaRule ) { setup( Iterables.first( recordsAfter ).getId(), Mode.fromRecordState( Iterables.first( recordsAfter ) ) ); this.recordsBefore = recordsBefore; this.recordsAfter = recordsAfter; this.schemaRule = schemaRule; }
@Override public DynamicRecord clone() { DynamicRecord clone = new DynamicRecord( getId() ).initialize( inUse(), startRecord, nextBlock, type, length ); if ( data != null ) { clone.setData( data.clone() ); } return clone; } }
private long create( DynamicArrayStore store, Object arrayToStore ) { Collection<DynamicRecord> records = new ArrayList<>(); store.allocateRecords( records, arrayToStore ); for ( DynamicRecord record : records ) { store.updateRecord( record ); } return Iterables.first( records ).getId(); }
private long storeRule( SchemaRule rule ) { Collection<DynamicRecord> records = store.allocateFrom( rule ); for ( DynamicRecord record : records ) { store.updateRecord( record ); } return Iterables.first( records ).getId(); }
public void createToken( String name, long id, RecordAccess<R, Void> recordAccess ) { R record = recordAccess.create( id, null ).forChangingData(); record.setInUse( true ); record.setCreated(); Collection<DynamicRecord> nameRecords = store.allocateNameRecords( encodeString( name ) ); record.setNameId( (int) Iterables.first( nameRecords ).getId() ); record.addNameRecords( nameRecords ); } }
@Test public void shouldReadIdOfDynamicRecordFromDynamicLabelsField() { // GIVEN NodeRecord node = nodeRecordWithDynamicLabels( nodeStore, oneByteLongs( 5 ) ); DynamicRecord dynamicRecord = node.getDynamicLabelRecords().iterator().next(); // WHEN long dynRecordId = NodeLabelsField.firstDynamicLabelRecordId( node.getLabelField() ); // THEN assertEquals( dynamicRecord.getId(), dynRecordId ); }
@Test public void shouldReportSelfReferentialNext() { // given DynamicRecord property = add( inUse( fill( record( 42 ) ) ) ); property.setNextBlock( property.getId() ); // when ConsistencyReport.DynamicConsistencyReport report = check( property ); // then verify( report ).selfReferentialNext(); verifyNoMoreInteractions( report ); }
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { DynamicRecord schema = new DynamicRecord( next.schema() ); DynamicRecord schemaBefore = schema.clone(); schema.setNextBlock( next.schema() ); // Point to a record that isn't in use. StoreIndexDescriptor rule = indexRule( schema.getId(), label1, key1, DESCRIPTOR ); schema.setData( SchemaRuleSerialization.serialize( rule ) ); tx.createSchema( asList( schemaBefore ), asList( schema ), rule ); } } );
private static void assertDynamicRecordChain( DynamicRecord... records ) { if ( records.length > 0 ) { for ( int i = 1; i < records.length; i++ ) { assertEquals( records[i].getId(), records[i - 1].getNextBlock() ); } assertTrue( Record.NO_NEXT_BLOCK.is( records[records.length - 1].getNextBlock() ) ); } }
static PropertyBlock propertyBlock( PropertyKeyTokenRecord key, DynamicRecord value ) { PropertyType type = value.getType(); if ( value.getType() != PropertyType.STRING && value.getType() != PropertyType.ARRAY ) { fail( "Dynamic record must be either STRING or ARRAY" ); return null; } return propertyBlock( key, type, value.getId() ); }
@Test void shouldReportDynamicBlockNotInUse() { // given LabelTokenRecord key = inUse( new LabelTokenRecord( 42 ) ); DynamicRecord name = addLabelName( notInUse( new DynamicRecord( 6 ) ) ); key.setNameId( (int) name.getId() ); // when LabelTokenConsistencyReport report = check( key ); // then verify( report ).nameBlockNotInUse( name ); verifyNoMoreInteractions( report ); }
@Test void shouldReportDynamicBlockNotInUse() { // given PropertyKeyTokenRecord key = inUse( new PropertyKeyTokenRecord( 42 ) ); DynamicRecord name = addKeyName( notInUse( new DynamicRecord( 6 ) ) ); key.setNameId( (int) name.getId() ); // when PropertyKeyTokenConsistencyReport report = check( key ); // then verify( report ).nameBlockNotInUse( name ); verifyNoMoreInteractions( report ); }
@Test public void shouldReportRecordWithEmptyNext() { // given DynamicRecord property = inUse( fill( record( 42 ) ) ); DynamicRecord next = add( inUse( record( 7 ) ) ); property.setNextBlock( next.getId() ); // when ConsistencyReport.DynamicConsistencyReport report = check( property ); // then verify( report ).emptyNextBlock( next ); verifyNoMoreInteractions( report ); }
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; } }
@Test public void shouldNotReportAnythingForRecordWithConsistentReferences() { // given DynamicRecord property = inUse( fill( record( 42 ) ) ); DynamicRecord next = add( inUse( fill( record( 7 ), blockSize / 2 ) ) ); property.setNextBlock( next.getId() ); // when ConsistencyReport.DynamicConsistencyReport report = check( property ); // then verifyNoMoreInteractions( report ); }