@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 RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
@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 ) ); } }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }