@Test public void nodeCommandWithFixedReferenceFormat302() throws Exception { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); NodeRecord before = new NodeRecord( 42, true, false, 33, 99, 66 ); NodeRecord after = new NodeRecord( 42, true, false, 33, 99, 66 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.NodeCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.NodeCommand); Command.NodeCommand nodeCommand = (Command.NodeCommand) command; // Then assertEquals( before, nodeCommand.getBefore() ); assertEquals( after, nodeCommand.getAfter() ); assertTrue( nodeCommand.getBefore().isUseFixedReferences() ); assertTrue( nodeCommand.getAfter().isUseFixedReferences() ); }
@Test public void nodeCommandWithFixedReferenceFormat300() throws Exception { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); NodeRecord before = new NodeRecord( 42, true, false, 33, 99, 66 ); NodeRecord after = new NodeRecord( 42, true, false, 33, 99, 66 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.NodeCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.NodeCommand); Command.NodeCommand nodeCommand = (Command.NodeCommand) command; // Then assertEquals( before, nodeCommand.getBefore() ); assertEquals( after, nodeCommand.getAfter() ); assertTrue( nodeCommand.getBefore().isUseFixedReferences() ); assertTrue( nodeCommand.getAfter().isUseFixedReferences() ); }
private void writeNodeRecord( WritableChannel channel, NodeRecord record ) throws IOException { byte flags = bitFlags( bitFlag( record.inUse(), Record.IN_USE.byteValue() ), bitFlag( record.isCreated(), Record.CREATED_IN_TX ), bitFlag( record.requiresSecondaryUnit(), Record.REQUIRE_SECONDARY_UNIT ), bitFlag( record.hasSecondaryUnitId(), Record.HAS_SECONDARY_UNIT ), bitFlag( record.isUseFixedReferences(), Record.USES_FIXED_REFERENCE_FORMAT ) ); channel.put( flags ); if ( record.inUse() ) { channel.put( record.isDense() ? (byte) 1 : (byte) 0 ); channel.putLong( record.getNextRel() ).putLong( record.getNextProp() ); channel.putLong( record.getLabelField() ); if ( record.hasSecondaryUnitId() ) { channel.putLong( record.getSecondaryUnitId() ); } } // Always write dynamic label records because we want to know which ones have been deleted // especially if the node has been deleted. writeDynamicRecords( channel, record.getDynamicLabelRecords() ); } }
@Override protected void doWriteInternal( NodeRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed reference format writeFixedReferencesRecord( record, cursor ); } else { encode( cursor, record.getNextRel(), NULL ); encode( cursor, record.getNextProp(), NULL ); encode( cursor, record.getLabelField(), NULL_LABELS ); } }
@Override protected void doWriteInternal( NodeRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed reference format writeFixedReferencesRecord( record, cursor ); } else { encode( cursor, record.getNextRel(), NULL ); encode( cursor, record.getNextProp(), NULL ); encode( cursor, record.getLabelField(), NULL_LABELS ); } }
@Override protected void doWriteInternal( NodeRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed reference format writeFixedReferencesRecord( record, cursor ); } else { encode( cursor, record.getNextRel(), NULL ); encode( cursor, record.getNextProp(), NULL ); encode( cursor, record.getLabelField(), NULL_LABELS ); } }
@Override protected void doWriteInternal( NodeRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed reference format writeFixedReferencesRecord( record, cursor ); } else { encode( cursor, record.getNextRel(), NULL ); encode( cursor, record.getNextProp(), NULL ); encode( cursor, record.getLabelField(), NULL_LABELS ); } }
@Override protected void doReadInternal( NodeRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { // Interpret the header byte boolean dense = has( headerByte, DENSE_NODE_BIT ); if ( record.isUseFixedReferences() ) { // read record in a fixed reference format readFixedReferencesRecord( record, cursor, inUse, dense ); record.setUseFixedReferences( true ); } else { // Now read the rest of the data. The adapter will take care of moving the cursor over to the // other unit when we've exhausted the first one. long nextRel = decodeCompressedReference( cursor, headerByte, HAS_RELATIONSHIP_BIT, NULL ); long nextProp = decodeCompressedReference( cursor, headerByte, HAS_PROPERTY_BIT, NULL ); long labelField = decodeCompressedReference( cursor, headerByte, HAS_LABELS_BIT, NULL_LABELS ); record.initialize( inUse, nextProp, dense, nextRel, labelField ); } }
@Override protected void doReadInternal( NodeRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { // Interpret the header byte boolean dense = has( headerByte, DENSE_NODE_BIT ); if ( record.isUseFixedReferences() ) { // read record in a fixed reference format readFixedReferencesRecord( record, cursor, inUse, dense ); record.setUseFixedReferences( true ); } else { // Now read the rest of the data. The adapter will take care of moving the cursor over to the // other unit when we've exhausted the first one. long nextRel = decodeCompressedReference( cursor, headerByte, HAS_RELATIONSHIP_BIT, NULL ); long nextProp = decodeCompressedReference( cursor, headerByte, HAS_PROPERTY_BIT, NULL ); long labelField = decodeCompressedReference( cursor, headerByte, HAS_LABELS_BIT, NULL_LABELS ); record.initialize( inUse, nextProp, dense, nextRel, labelField ); } }
@Override protected void doReadInternal( NodeRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { // Interpret the header byte boolean dense = has( headerByte, DENSE_NODE_BIT ); if ( record.isUseFixedReferences() ) { // read record in a fixed reference format readFixedReferencesRecord( record, cursor, inUse, dense ); record.setUseFixedReferences( true ); } else { // Now read the rest of the data. The adapter will take care of moving the cursor over to the // other unit when we've exhausted the first one. long nextRel = decodeCompressedReference( cursor, headerByte, HAS_RELATIONSHIP_BIT, NULL ); long nextProp = decodeCompressedReference( cursor, headerByte, HAS_PROPERTY_BIT, NULL ); long labelField = decodeCompressedReference( cursor, headerByte, HAS_LABELS_BIT, NULL_LABELS ); record.initialize( inUse, nextProp, dense, nextRel, labelField ); } }
@Override protected void doReadInternal( NodeRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { // Interpret the header byte boolean dense = has( headerByte, DENSE_NODE_BIT ); if ( record.isUseFixedReferences() ) { // read record in a fixed reference format readFixedReferencesRecord( record, cursor, inUse, dense ); record.setUseFixedReferences( true ); } else { // Now read the rest of the data. The adapter will take care of moving the cursor over to the // other unit when we've exhausted the first one. long nextRel = decodeCompressedReference( cursor, headerByte, HAS_RELATIONSHIP_BIT, NULL ); long nextProp = decodeCompressedReference( cursor, headerByte, HAS_PROPERTY_BIT, NULL ); long labelField = decodeCompressedReference( cursor, headerByte, HAS_LABELS_BIT, NULL_LABELS ); record.initialize( inUse, nextProp, dense, nextRel, labelField ); } }
private void writeNodeRecord( WritableChannel channel, NodeRecord record ) throws IOException { byte flags = bitFlags( bitFlag( record.inUse(), Record.IN_USE.byteValue() ), bitFlag( record.isCreated(), Record.CREATED_IN_TX ), bitFlag( record.requiresSecondaryUnit(), Record.REQUIRE_SECONDARY_UNIT ), bitFlag( record.hasSecondaryUnitId(), Record.HAS_SECONDARY_UNIT ), bitFlag( record.isUseFixedReferences(), Record.USES_FIXED_REFERENCE_FORMAT ) ); channel.put( flags ); if ( record.inUse() ) { channel.put( record.isDense() ? (byte) 1 : (byte) 0 ); channel.putLong( record.getNextRel() ).putLong( record.getNextProp() ); channel.putLong( record.getLabelField() ); if ( record.hasSecondaryUnitId() ) { channel.putLong( record.getSecondaryUnitId() ); } } // Always write dynamic label records because we want to know which ones have been deleted // especially if the node has been deleted. writeDynamicRecords( channel, record.getDynamicLabelRecords() ); } }