assertTrue( format.relationship().prepared( ((RelationshipCommand) command).getAfter() ) ); rels++;
private EntityUpdates.Builder gatherUpdatesFromCommandsForRelationship( long relationshipId, RelationshipCommand relationshipCommand, List<PropertyCommand> propertyCommands ) { long reltypeBefore; long reltypeAfter; if ( relationshipCommand != null ) { reltypeBefore = relationshipCommand.getBefore().getType(); reltypeAfter = relationshipCommand.getAfter().getType(); } else { RelationshipRecord relationshipRecord = loadRelationship( relationshipId ); reltypeBefore = reltypeAfter = relationshipRecord.getType(); } EntityUpdates.Builder relationshipPropertyUpdates = EntityUpdates.forEntity( relationshipId ).withTokens( reltypeBefore ).withTokensAfter( reltypeAfter ); if ( propertyCommands != null ) { converter.convertPropertyRecord( relationshipId, Iterables.cast( propertyCommands ), relationshipPropertyUpdates ); } return relationshipPropertyUpdates; }
private EntityUpdates.Builder gatherUpdatesFromCommandsForRelationship( long relationshipId, RelationshipCommand relationshipCommand, List<PropertyCommand> propertyCommands ) { long reltypeBefore; long reltypeAfter; if ( relationshipCommand != null ) { reltypeBefore = relationshipCommand.getBefore().getType(); reltypeAfter = relationshipCommand.getAfter().getType(); } else { RelationshipRecord relationshipRecord = loadRelationship( relationshipId ); reltypeBefore = reltypeAfter = relationshipRecord.getType(); } EntityUpdates.Builder relationshipPropertyUpdates = EntityUpdates.forEntity( relationshipId ).withTokens( reltypeBefore ).withTokensAfter( reltypeAfter ); if ( propertyCommands != null ) { converter.convertPropertyRecord( relationshipId, Iterables.cast( propertyCommands ), relationshipPropertyUpdates ); } return relationshipPropertyUpdates; }
@Test public void readRelationshipCommandWithFixedReferenceFormat300() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipRecord before = new RelationshipRecord( 42, true, 1, 2, 3, 4, 5, 6, 7, true, true ); before.setUseFixedReferences( true ); RelationshipRecord after = new RelationshipRecord( 42, true, 1, 8, 3, 4, 5, 6, 7, true, true ); after.setUseFixedReferences( true ); new Command.RelationshipCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipCommand ); Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command; assertEquals( before, relationshipCommand.getBefore() ); assertTrue( relationshipCommand.getBefore().isUseFixedReferences() ); assertEquals( after, relationshipCommand.getAfter() ); assertTrue( relationshipCommand.getAfter().isUseFixedReferences() ); }
@Test public void readRelationshipCommandWithFixedReferenceFormat302() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipRecord before = new RelationshipRecord( 42, true, 1, 2, 3, 4, 5, 6, 7, true, true ); before.setUseFixedReferences( true ); RelationshipRecord after = new RelationshipRecord( 42, true, 1, 8, 3, 4, 5, 6, 7, true, true ); after.setUseFixedReferences( true ); new Command.RelationshipCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipCommand ); Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command; assertEquals( before, relationshipCommand.getBefore() ); assertTrue( relationshipCommand.getBefore().isUseFixedReferences() ); assertEquals( after, relationshipCommand.getAfter() ); assertTrue( relationshipCommand.getAfter().isUseFixedReferences() ); }
@Test public void readRelationshipCommandWithSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipRecord before = new RelationshipRecord( 42, true, 1, 2, 3, 4, 5, 6, 7, true, true ); before.setRequiresSecondaryUnit( true ); before.setSecondaryUnitId( 47 ); RelationshipRecord after = new RelationshipRecord( 42, true, 1, 8, 3, 4, 5, 6, 7, true, true ); new Command.RelationshipCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipCommand ); Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command; assertEquals( before, relationshipCommand.getBefore() ); verifySecondaryUnit( before, relationshipCommand.getBefore() ); assertEquals( after, relationshipCommand.getAfter() ); }
@Test public void readRelationshipCommandWithNonRequiredSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipRecord before = new RelationshipRecord( 42, true, 1, 2, 3, 4, 5, 6, 7, true, true ); before.setRequiresSecondaryUnit( false ); before.setSecondaryUnitId( 52 ); RelationshipRecord after = new RelationshipRecord( 42, true, 1, 8, 3, 4, 5, 6, 7, true, true ); new Command.RelationshipCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipCommand ); Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command; assertEquals( before, relationshipCommand.getBefore() ); verifySecondaryUnit( before, relationshipCommand.getBefore() ); assertEquals( after, relationshipCommand.getAfter() ); }
@Test public void shouldReadRelationshipCommand() throws Throwable { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipRecord before = new RelationshipRecord( 42, -1, -1, -1 ); RelationshipRecord after = new RelationshipRecord( 42, true, 1, 2, 3, 4, 5, 6, 7, true, true ); new Command.RelationshipCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipCommand ); Command.RelationshipCommand relationshipCommand = (Command.RelationshipCommand) command; // Then assertEquals( before, relationshipCommand.getBefore() ); assertEquals( after, relationshipCommand.getAfter() ); }
private void prepareForCommit() { for ( Command.NodeCommand command : nodeCommands ) { neoStores.getNodeStore().prepareForCommit( command.getAfter() ); } for ( Command.RelationshipCommand command : relationshipCommands ) { neoStores.getRelationshipStore().prepareForCommit( command.getAfter() ); } for ( Command.RelationshipGroupCommand command : relationshipGroupCommands ) { neoStores.getRelationshipGroupStore().prepareForCommit( command.getAfter() ); } }