for ( RecordProxy<RelationshipRecord, Void> change : recordChangeSet.getRelRecords().changes() ) relCommands[i++] = new Command.RelationshipCommand( change.getBefore(), prepared( change, relationshipStore ) );
@Test public void testVisitRelationshipCommand() throws Exception { Command.RelationshipCommand cmd = mock( Command.RelationshipCommand.class ); when( cmd.handle( any( CommandVisitor.class ) ) ).thenCallRealMethod(); // WHEN boolean result = facade.visitRelationshipCommand( cmd ); // THEN InOrder inOrder = inOrder( txApplier1, txApplier2, txApplier3 ); inOrder.verify( txApplier1 ).visitRelationshipCommand( cmd ); inOrder.verify( txApplier2 ).visitRelationshipCommand( cmd ); inOrder.verify( txApplier3 ).visitRelationshipCommand( cmd ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); }
for ( RecordProxy<RelationshipRecord, Void> change : recordChangeSet.getRelRecords().changes() ) relCommands[i++] = new Command.RelationshipCommand( change.getBefore(), prepared( change, relationshipStore ) );
return new Command.RelationshipCommand( null, record );
return new Command.RelationshipCommand( null, record );
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 Command visitRelationshipCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipRecord before = readRelationshipRecord( id, channel ); if ( before == null ) { return null; } RelationshipRecord after = readRelationshipRecord( id, channel ); if ( after == null ) { return null; } if ( !before.inUse() && after.inUse() ) { after.setCreated(); } return new Command.RelationshipCommand( before, after ); }
private Command visitRelationshipCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipRecord before = readRelationshipRecord( id, channel ); if ( before == null ) { return null; } RelationshipRecord after = readRelationshipRecord( id, channel ); if ( after == null ) { return null; } if ( !before.inUse() && after.inUse() ) { after.setCreated(); } return new Command.RelationshipCommand( before, after ); }
@Override public boolean visitRelationshipCommand( Command.RelationshipCommand command ) { relationshipCommandsById.put( command.getKey(), command ); hasUpdates = true; return false; }
public void add( RelationshipRecord relationship ) { Command.RelationshipCommand command = new Command.RelationshipCommand(); command.init( relationship ); addCommand( command ); }
@Override public boolean visitRelationshipCommand( Command.RelationshipCommand command ) { lockGroup.add( lockService.acquireRelationshipLock( command.getKey(), LockService.LockType.WRITE_LOCK ) ); updateStore( neoStores.getRelationshipStore(), command ); return false; }
assertTrue( format.relationship().prepared( ((RelationshipCommand) command).getAfter() ) ); rels++;
relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord relationshipPropertyBlocks = new PropertyRecord( propertyId ); relationshipPropertyBlocks.setRelId( relId );
relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId );
return new Command.RelationshipCommand( null, record );
return new Command.RelationshipCommand( null, record );
tracker.visitRelationshipCommand( new RelationshipCommand( new RelationshipRecord( relationship.getId() ), relationship ) ); tracker.visitRelationshipGroupCommand( new RelationshipGroupCommand(
@Test public void shouldContainFedRelationshipUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); long relId = 0; RelationshipRecord inUse = getRelationship( relId, true, ENTITY_TOKEN ); Value propertyValue = Values.of( "hej" ); long propertyId = createRelationshipProperty( inUse, propertyValue, 1 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, RELATIONSHIP, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, relationshipCommand ) ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( relId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
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 shouldSetCorrectHighIdWhenApplyingExternalTransactions() throws Exception { // WHEN recovering a transaction that creates some data long nodeId = neoStores.getNodeStore().nextId(); long relationshipId = neoStores.getRelationshipStore().nextId(); int type = 1; applyExternalTransaction( 1, new NodeCommand( new NodeRecord( nodeId ), inUse( created( new NodeRecord( nodeId ) ) ) ), new RelationshipCommand( null, inUse( created( with( new RelationshipRecord( relationshipId ), nodeId, nodeId, type ) ) ) ) ); // and when, later on, recovering a transaction deleting some of those applyExternalTransaction( 2, new NodeCommand( inUse( created( new NodeRecord( nodeId ) ) ), new NodeRecord( nodeId ) ), new RelationshipCommand( null, new RelationshipRecord( relationshipId ) ) ); // THEN that should be possible and the high ids should be correct, i.e. highest applied + 1 assertEquals( nodeId + 1, neoStores.getNodeStore().getHighId() ); assertEquals( relationshipId + 1, neoStores.getRelationshipStore().getHighId() ); }