if ( record.inUse() && record.isStartRecord() )
@Override public void check( DynamicRecord record, CheckerEngine<DynamicRecord, DynamicLabelConsistencyReport> engine, RecordAccess records ) { if ( record.inUse() && record.isStartRecord() ) { Long ownerId = readOwnerFromDynamicLabelsRecord( record ); if ( null == ownerId ) { // no owner but in use indicates a broken record engine.report().orphanDynamicLabelRecord(); } else { // look at owning node record to verify consistency engine.comparativeCheck( records.node( ownerId ), VALID_NODE_RECORD ); } } }
@Override protected void assertRecordsEqual( DynamicRecord actualRecord, DynamicRecord expectedRecord ) { assertNotNull( "actualRecord", actualRecord ); assertNotNull( "expectedRecord", expectedRecord ); assertThat( "getData", actualRecord.getData(), is( expectedRecord.getData() ) ); assertThat( "getLength", actualRecord.getLength(), is( expectedRecord.getLength() ) ); assertThat( "getNextBlock", actualRecord.getNextBlock(), is( expectedRecord.getNextBlock() ) ); assertThat( "getType", actualRecord.getType(), is( expectedRecord.getType() ) ); assertThat( "getId", actualRecord.getId(), is( expectedRecord.getId() ) ); assertThat( "getLongId", actualRecord.getId(), is( expectedRecord.getId() ) ); assertThat( "isStartRecord", actualRecord.isStartRecord(), is( expectedRecord.isStartRecord() ) ); } }
@Override public RecordKey<DynamicRecord> dynamic() { return ( written, read ) -> { // Don't assert type, since that's read from the data, and the data in this test // is randomly generated. Since we assert that the data is the same then the type // is also correct. assertEquals( written.getLength(), read.getLength() ); assertEquals( written.getNextBlock(), read.getNextBlock() ); assertArrayEquals( written.getData(), read.getData() ); assertEquals( written.isStartRecord(), read.isStartRecord() ); }; } }
assertThat( "[" + i + "]getId", actualNameRecord.getId(), is( expectedNameRecord.getId() ) ); assertThat( "[" + i + "]getLongId", actualNameRecord.getId(), is( expectedNameRecord.getId() ) ); assertThat( "[" + i + "]isStartRecord", actualNameRecord.isStartRecord(), is( expectedNameRecord.isStartRecord() ) ); assertThat( "[" + i + "]inUse", actualNameRecord.inUse(), is( expectedNameRecord.inUse() ) ); i++;
RecordAccess records ) if ( record.inUse() && record.isStartRecord() )
assertThat( "[" + index + "]getValueRecords[" + i + "]getLongId", actualValueRecord.getId(), is( expectedValueRecord.getId() ) ); assertThat( "[" + index + "]getValueRecords[" + i + "]isStartRecord", actualValueRecord.isStartRecord(), is( expectedValueRecord.isStartRecord() ) ); assertThat( "[" + index + "]getValueRecords[" + i + "]inUse", actualValueRecord.inUse(), is( expectedValueRecord.inUse() ) );
@Override public void write( DynamicRecord record, PageCursor cursor, int recordSize ) { if ( record.inUse() ) { long nextBlock = record.getNextBlock(); int highByteInFirstInteger = nextBlock == Record.NO_NEXT_BLOCK.intValue() ? 0 : (int) ((nextBlock & 0xF00000000L) >> 8); highByteInFirstInteger |= Record.IN_USE.byteValue() << 28; highByteInFirstInteger |= (record.isStartRecord() ? 0 : 1) << 31; /* * First 4b * [x , ][ , ][ , ][ , ] 0: start record, 1: linked record * [ x, ][ , ][ , ][ , ] inUse * [ ,xxxx][ , ][ , ][ , ] high next block bits * [ , ][xxxx,xxxx][xxxx,xxxx][xxxx,xxxx] nr of bytes in the data field in this record * */ int firstInteger = record.getLength(); assert firstInteger < (1 << 24) - 1; firstInteger |= highByteInFirstInteger; cursor.putInt( firstInteger ); cursor.putInt( (int) nextBlock ); cursor.putBytes( record.getData() ); } else { cursor.putByte( Record.NOT_IN_USE.byteValue() ); } }
void writeDynamicRecord( WritableChannel channel, DynamicRecord record ) throws IOException { // id+type+in_use(byte)+nr_of_bytes(int)+next_block(long) if ( record.inUse() ) { byte inUse = Record.IN_USE.byteValue(); if ( record.isStartRecord() ) { inUse |= Record.FIRST_IN_CHAIN.byteValue(); } channel.putLong( record.getId() ) .putInt( record.getTypeAsInt() ) .put( inUse ) .putInt( record.getLength() ) .putLong( record.getNextBlock() ); byte[] data = record.getData(); assert data != null; channel.put( data, data.length ); } else { byte inUse = Record.NOT_IN_USE.byteValue(); channel.putLong( record.getId() ) .putInt( record.getTypeAsInt() ) .put( inUse ); } }
if ( record.inUse() && record.isStartRecord() )
if ( record.inUse() && record.isStartRecord() )
@Override public void write( DynamicRecord record, PageCursor cursor, int recordSize ) { if ( record.inUse() ) { long nextBlock = record.getNextBlock(); int highByteInFirstInteger = nextBlock == Record.NO_NEXT_BLOCK.intValue() ? 0 : (int) ((nextBlock & 0xF00000000L) >> 8); highByteInFirstInteger |= Record.IN_USE.byteValue() << 28; highByteInFirstInteger |= (record.isStartRecord() ? 0 : 1) << 31; /* * First 4b * [x , ][ , ][ , ][ , ] 0: start record, 1: linked record * [ x, ][ , ][ , ][ , ] inUse * [ ,xxxx][ , ][ , ][ , ] high next block bits * [ , ][xxxx,xxxx][xxxx,xxxx][xxxx,xxxx] nr of bytes in the data field in this record * */ int firstInteger = record.getLength(); assert firstInteger < (1 << 24) - 1; firstInteger |= highByteInFirstInteger; cursor.putInt( firstInteger ); cursor.putInt( (int) nextBlock ); cursor.putBytes( record.getData() ); } else { cursor.putByte( Record.NOT_IN_USE.byteValue() ); } }
@Override public void write( DynamicRecord record, PageCursor cursor, int recordSize ) { if ( record.inUse() ) { assert record.getLength() < (1 << 24) - 1; byte headerByte = (byte) ((record.inUse() ? IN_USE_BIT : 0) | (record.isStartRecord() ? START_RECORD_BIT : 0)); cursor.putByte( headerByte ); cursor.putShort( (short) record.getLength() ); cursor.putByte( (byte) (record.getLength() >>> 16 ) ); cursor.putLong( record.getNextBlock() ); cursor.putBytes( record.getData() ); } else { markAsUnused( cursor ); } }
void writeDynamicRecord( WritableChannel channel, DynamicRecord record ) throws IOException { // id+type+in_use(byte)+nr_of_bytes(int)+next_block(long) if ( record.inUse() ) { byte inUse = Record.IN_USE.byteValue(); if ( record.isStartRecord() ) { inUse |= Record.FIRST_IN_CHAIN.byteValue(); } channel.putLong( record.getId() ) .putInt( record.getTypeAsInt() ) .put( inUse ) .putInt( record.getLength() ) .putLong( record.getNextBlock() ); byte[] data = record.getData(); assert data != null; channel.put( data, data.length ); } else { byte inUse = Record.NOT_IN_USE.byteValue(); channel.putLong( record.getId() ) .putInt( record.getTypeAsInt() ) .put( inUse ); } }