@Test public void readRelationshipGroupCommandWithFixedReferenceFormat302() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); before.setUseFixedReferences( true ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setUseFixedReferences( true ); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); assertTrue( relationshipGroupCommand.getBefore().isUseFixedReferences() ); assertTrue( relationshipGroupCommand.getAfter().isUseFixedReferences() ); }
@Test public void readRelationshipGroupCommandWithFixedReferenceFormat300() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); before.setUseFixedReferences( true ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setUseFixedReferences( true ); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); assertTrue( relationshipGroupCommand.getBefore().isUseFixedReferences() ); assertTrue( relationshipGroupCommand.getAfter().isUseFixedReferences() ); }
private void writeRelationshipGroupRecord( WritableChannel channel, RelationshipGroupRecord record ) throws IOException { byte flags = bitFlags( bitFlag( record.inUse(), Record.IN_USE.byteValue() ), 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 ); channel.putShort( (short) record.getType() ); channel.putLong( record.getNext() ); channel.putLong( record.getFirstOut() ); channel.putLong( record.getFirstIn() ); channel.putLong( record.getFirstLoop() ); channel.putLong( record.getOwningNode() ); if ( record.hasSecondaryUnitId() ) { channel.putLong( record.getSecondaryUnitId() ); } } }
@Override protected void doReadInternal( RelationshipGroupRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { if ( record.isUseFixedReferences() ) { // read record in fixed references format readFixedReferencesMethod( record, cursor, inUse ); record.setUseFixedReferences( true ); } else { int type = getType( cursor ); record.initialize( inUse, type, decodeCompressedReference( cursor, headerByte, HAS_OUTGOING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_INCOMING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_LOOP_BIT, NULL ), decodeCompressedReference( cursor ), decodeCompressedReference( cursor, headerByte, HAS_NEXT_BIT, NULL ) ); } }
@Override protected void doReadInternal( RelationshipGroupRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { if ( record.isUseFixedReferences() ) { // read record in fixed references format readFixedReferencesMethod( record, cursor, inUse ); record.setUseFixedReferences( true ); } else { record.initialize( inUse, cursor.getShort() & 0xFFFF, decodeCompressedReference( cursor, headerByte, HAS_OUTGOING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_INCOMING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_LOOP_BIT, NULL ), decodeCompressedReference( cursor ), decodeCompressedReference( cursor, headerByte, HAS_NEXT_BIT, NULL ) ); } }
@Override protected void doReadInternal( RelationshipGroupRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { if ( record.isUseFixedReferences() ) { // read record in fixed references format readFixedReferencesMethod( record, cursor, inUse ); record.setUseFixedReferences( true ); } else { int type = getType( cursor ); record.initialize( inUse, type, decodeCompressedReference( cursor, headerByte, HAS_OUTGOING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_INCOMING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_LOOP_BIT, NULL ), decodeCompressedReference( cursor ), decodeCompressedReference( cursor, headerByte, HAS_NEXT_BIT, NULL ) ); } }
@Override protected void doReadInternal( RelationshipGroupRecord record, PageCursor cursor, int recordSize, long headerByte, boolean inUse ) { if ( record.isUseFixedReferences() ) { // read record in fixed references format readFixedReferencesMethod( record, cursor, inUse ); record.setUseFixedReferences( true ); } else { int type = getType( cursor ); record.initialize( inUse, type, decodeCompressedReference( cursor, headerByte, HAS_OUTGOING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_INCOMING_BIT, NULL ), decodeCompressedReference( cursor, headerByte, HAS_LOOP_BIT, NULL ), decodeCompressedReference( cursor ), decodeCompressedReference( cursor, headerByte, HAS_NEXT_BIT, NULL ) ); } }
@Override protected void doWriteInternal( RelationshipGroupRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed references format writeFixedReferencesRecord( record, cursor ); } else { writeType( cursor, record.getType() ); encode( cursor, record.getFirstOut(), NULL ); encode( cursor, record.getFirstIn(), NULL ); encode( cursor, record.getFirstLoop(), NULL ); encode( cursor, record.getOwningNode() ); encode( cursor, record.getNext(), NULL ); } }
@Override protected void doWriteInternal( RelationshipGroupRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed references format writeFixedReferencesRecord( record, cursor ); } else { cursor.putShort( (short) record.getType() ); encode( cursor, record.getFirstOut(), NULL ); encode( cursor, record.getFirstIn(), NULL ); encode( cursor, record.getFirstLoop(), NULL ); encode( cursor, record.getOwningNode() ); encode( cursor, record.getNext(), NULL ); } }
@Override protected void doWriteInternal( RelationshipGroupRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed references format writeFixedReferencesRecord( record, cursor ); } else { writeType( cursor, record.getType() ); encode( cursor, record.getFirstOut(), NULL ); encode( cursor, record.getFirstIn(), NULL ); encode( cursor, record.getFirstLoop(), NULL ); encode( cursor, record.getOwningNode() ); encode( cursor, record.getNext(), NULL ); } }
@Override protected void doWriteInternal( RelationshipGroupRecord record, PageCursor cursor ) { if ( record.isUseFixedReferences() ) { // write record in fixed references format writeFixedReferencesRecord( record, cursor ); } else { writeType( cursor, record.getType() ); encode( cursor, record.getFirstOut(), NULL ); encode( cursor, record.getFirstIn(), NULL ); encode( cursor, record.getFirstLoop(), NULL ); encode( cursor, record.getOwningNode() ); encode( cursor, record.getNext(), NULL ); } }
private void writeRelationshipGroupRecord( WritableChannel channel, RelationshipGroupRecord record ) throws IOException { byte flags = bitFlags( bitFlag( record.inUse(), Record.IN_USE.byteValue() ), 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 ); channel.putShort( (short) record.getType() ); channel.putLong( record.getNext() ); channel.putLong( record.getFirstOut() ); channel.putLong( record.getFirstIn() ); channel.putLong( record.getFirstLoop() ); channel.putLong( record.getOwningNode() ); if ( record.hasSecondaryUnitId() ) { channel.putLong( record.getSecondaryUnitId() ); } } }