@Before public void before() throws Exception { collectionsFactory = Mockito.spy( new TestCollectionsFactory() ); when( headerInformation.getAdditionalHeader() ).thenReturn( new byte[0] ); when( headerInformationFactory.create() ).thenReturn( headerInformation ); when( neoStores.getMetaDataStore() ).thenReturn( metaDataStore ); when( storageEngine.newReader() ).thenReturn( readLayer ); doAnswer( invocation -> ((Collection<StorageCommand>) invocation.getArgument(0) ).add( new Command .RelationshipCountsCommand( 1, 2,3, 4L ) ) ) .when( storageEngine ).createCommands( anyCollection(), any( ReadableTransactionState.class ), any( StorageReader.class ), any( ResourceLocker.class ), anyLong(), any( TxStateVisitor.Decorator.class ) ); }
@Test public void testVisitRelationshipCountsCommand() throws Exception { Command.RelationshipCountsCommand cmd = mock( Command.RelationshipCountsCommand.class ); when( cmd.handle( any( CommandVisitor.class ) ) ).thenCallRealMethod(); // WHEN boolean result = facade.visitRelationshipCountsCommand( cmd ); // THEN InOrder inOrder = inOrder( txApplier1, txApplier2, txApplier3 ); inOrder.verify( txApplier1 ).visitRelationshipCountsCommand( cmd ); inOrder.verify( txApplier2 ).visitRelationshipCountsCommand( cmd ); inOrder.verify( txApplier3 ).visitRelationshipCountsCommand( cmd ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); } }
public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta ) { addCommand( new Command.RelationshipCountsCommand().init( startLabelId, typeId, endLabelId, delta ) ); }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
@Override public void visitRelationshipCount( int startLabelId, int typeId, int endLabelId, long count ) { if ( count != 0 ) { // Only add commands for counts that actually change commands.add( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, count ) ); } } }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
@Override public void serialize( WritableChannel channel ) throws IOException { channel.put( NeoCommandType.UPDATE_RELATIONSHIP_COUNTS_COMMAND ); channel.putInt( startLabelId() ) .putInt( typeId() ) .putInt( endLabelId() ) .putLong( delta() ); } }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
@Override public boolean visitRelationshipCountsCommand( Command.RelationshipCountsCommand command ) { assert countsUpdater != null || mode == TransactionApplicationMode.RECOVERY : "You must call begin first"; haveUpdates = true; if ( countsUpdater != null ) { // CountsUpdater is null if we're in recovery and the counts store already has had this transaction applied. countsUpdater.incrementRelationshipCount( command.startLabelId(), command.typeId(), command.endLabelId(), command.delta() ); } return false; }
public RelationshipCountsCommand( int startLabelId, int typeId, int endLabelId, long delta ) { setup( typeId, Mode.UPDATE ); assert delta != 0 : "Tried to create a RelationshipCountsCommand for something that didn't change any count"; this.startLabelId = startLabelId; this.typeId = typeId; this.endLabelId = endLabelId; this.delta = delta; }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
@Override public void visitRelationshipCount( int startLabelId, int typeId, int endLabelId, long count ) { if ( count != 0 ) { // Only add commands for counts that actually change commands.add( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, count ) ); } } }
public RelationshipCountsCommand( int startLabelId, int typeId, int endLabelId, long delta ) { setup( typeId, Mode.UPDATE ); assert delta != 0 : "Tried to create a RelationshipCountsCommand for something that didn't change any count"; this.startLabelId = startLabelId; this.typeId = typeId; this.endLabelId = endLabelId; this.delta = delta; }
public void incrementRelationshipCount( int startLabelId, int typeId, int endLabelId, long delta ) { otherCommands.add( new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ) ); }
@Override public boolean visitRelationshipCountsCommand( Command.RelationshipCountsCommand command ) { assert countsUpdater != null || mode == TransactionApplicationMode.RECOVERY : "You must call begin first"; haveUpdates = true; if ( countsUpdater != null ) { // CountsUpdater is null if we're in recovery and the counts store already has had this transaction applied. countsUpdater.incrementRelationshipCount( command.startLabelId(), command.typeId(), command.endLabelId(), command.delta() ); } return false; }
@Override public void serialize( WritableChannel channel ) throws IOException { channel.put( NeoCommandType.UPDATE_RELATIONSHIP_COUNTS_COMMAND ); channel.putInt( startLabelId() ) .putInt( typeId() ) .putInt( endLabelId() ) .putLong( delta() ); } }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }
private Command visitRelationshipCountsCommand( ReadableChannel channel ) throws IOException { int startLabelId = channel.getInt(); int typeId = channel.getInt(); int endLabelId = channel.getInt(); long delta = channel.getLong(); return new Command.RelationshipCountsCommand( startLabelId, typeId, endLabelId, delta ); }