public RelationshipGroupStage( String topic, Configuration config, RecordStore<RelationshipGroupRecord> store, NodeRelationshipCache cache ) { super( NAME, topic, config, RECYCLE_BATCHES ); add( new ReadGroupRecordsByCacheStep( control(), config, store, cache ) ); add( new UpdateRecordsStep<>( control(), config, store, new StorePrepareIdSequence() ) ); } }
@Test public void ioThroughputStatDoesNotOverflow() { // store with huge record size to force overflow and not create huge batch of records RecordStore<NodeRecord> store = mock( RecordStore.class ); when( store.getRecordSize() ).thenReturn( Integer.MAX_VALUE / 2 ); Configuration configuration = mock( Configuration.class ); StageControl stageControl = mock( StageControl.class ); UpdateRecordsStep<NodeRecord> step = new UpdateRecordsStep<>( stageControl, configuration, store, new StorePrepareIdSequence() ); NodeRecord record = new NodeRecord( 1 ); record.setInUse( true ); NodeRecord[] batch = new NodeRecord[11]; Arrays.fill( batch, record ); step.process( batch, mock( BatchSender.class ) ); Stat stat = step.stat( Keys.io_throughput ); assertThat( stat.asLong(), greaterThan( 0L ) ); }
@Test public void recordWithReservedIdIsSkipped() { RecordStore<NodeRecord> store = mock( NodeStore.class ); StageControl stageControl = mock( StageControl.class ); UpdateRecordsStep<NodeRecord> step = new UpdateRecordsStep<>( stageControl, Configuration.DEFAULT, store, new StorePrepareIdSequence() ); NodeRecord node1 = new NodeRecord( 1 ); node1.setInUse( true ); NodeRecord node2 = new NodeRecord( 2 ); node2.setInUse( true ); NodeRecord nodeWithReservedId = new NodeRecord( IdGeneratorImpl.INTEGER_MINUS_ONE ); NodeRecord[] batch = {node1, node2, nodeWithReservedId}; step.process( batch, mock( BatchSender.class ) ); verify( store ).prepareForCommit( eq( node1 ), any( IdSequence.class ) ); verify( store ).updateRecord( node1 ); verify( store ).prepareForCommit( eq( node2 ), any( IdSequence.class ) ); verify( store ).updateRecord( node2 ); verify( store, never() ).prepareForCommit( eq( nodeWithReservedId ), any( IdSequence.class ) ); verify( store, never() ).updateRecord( nodeWithReservedId ); } }
public WriteGroupsStage( Configuration config, RelationshipGroupCache cache, RecordStore<RelationshipGroupRecord> store ) { super( NAME, null, config, 0 ); add( new ReadGroupsFromCacheStep( control(), config, cache.iterator(), GROUP_ENTRY_SIZE ) ); add( new EncodeGroupsStep( control(), config, store ) ); add( new UpdateRecordsStep<>( control(), config, store, new StorePrepareIdSequence() ) ); } }
public NodeFirstGroupStage( Configuration config, RecordStore<RelationshipGroupRecord> groupStore, NodeStore nodeStore, ByteArray cache ) { super( NAME, null, config, 0 ); add( new BatchFeedStep( control(), config, allIn( groupStore, config ), groupStore.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, groupStore ) ); add( new NodeSetFirstGroupStep( control(), config, nodeStore, cache ) ); add( new UpdateRecordsStep<>( control(), config, nodeStore, new StorePrepareIdSequence() ) ); } }
public SparseNodeFirstRelationshipStage( Configuration config, NodeStore nodeStore, NodeRelationshipCache cache ) { super( NAME, null, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); add( new ReadNodeIdsByCacheStep( control(), config, cache, NodeType.NODE_TYPE_SPARSE ) ); add( new ReadRecordsStep<>( control(), config, true, nodeStore ) ); add( new RecordProcessorStep<>( control(), "LINK", config, new SparseNodeFirstRelationshipProcessor( cache ), false ) ); add( new UpdateRecordsStep<>( control(), config, nodeStore, new StorePrepareIdSequence() ) ); } }
public RelationshipLinkforwardStage( String topic, Configuration config, BatchingNeoStores stores, NodeRelationshipCache cache, Predicate<RelationshipRecord> readFilter, Predicate<RelationshipRecord> denseChangeFilter, int nodeTypes, StatsProvider... additionalStatsProvider ) { super( NAME, topic, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); RelationshipStore store = stores.getRelationshipStore(); add( new BatchFeedStep( control(), config, forwards( 0, store.getHighId(), config ), store.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, store, new RecordDataAssembler<>( store::newRecord, readFilter ) ) ); add( new RelationshipLinkforwardStep( control(), config, cache, denseChangeFilter, nodeTypes, additionalStatsProvider ) ); add( new UpdateRecordsStep<>( control(), config, store, PrepareIdSequence.of( stores.usesDoubleRelationshipRecordUnits() ) ) ); } }
public RelationshipLinkbackStage( String topic, Configuration config, BatchingNeoStores stores, NodeRelationshipCache cache, Predicate<RelationshipRecord> readFilter, Predicate<RelationshipRecord> changeFilter, int nodeTypes, StatsProvider... additionalStatsProvider ) { super( NAME, topic, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); RelationshipStore store = stores.getRelationshipStore(); add( new BatchFeedStep( control(), config, backwards( 0, store.getHighId(), config ), store.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, store, new RecordDataAssembler<>( store::newRecord, readFilter ) ) ); add( new RelationshipLinkbackStep( control(), config, cache, changeFilter, nodeTypes, additionalStatsProvider ) ); add( new UpdateRecordsStep<>( control(), config, store, PrepareIdSequence.of( stores.usesDoubleRelationshipRecordUnits() ) ) ); } }
public RelationshipGroupStage( String topic, Configuration config, RecordStore<RelationshipGroupRecord> store, NodeRelationshipCache cache ) { super( NAME, topic, config, RECYCLE_BATCHES ); add( new ReadGroupRecordsByCacheStep( control(), config, store, cache ) ); add( new UpdateRecordsStep<>( control(), config, store, new StorePrepareIdSequence() ) ); } }
public WriteGroupsStage( Configuration config, RelationshipGroupCache cache, RecordStore<RelationshipGroupRecord> store ) { super( NAME, null, config, 0 ); add( new ReadGroupsFromCacheStep( control(), config, cache.iterator(), GROUP_ENTRY_SIZE ) ); add( new EncodeGroupsStep( control(), config, store ) ); add( new UpdateRecordsStep<>( control(), config, store, new StorePrepareIdSequence() ) ); } }
public NodeFirstGroupStage( Configuration config, RecordStore<RelationshipGroupRecord> groupStore, NodeStore nodeStore, ByteArray cache ) { super( NAME, null, config, 0 ); add( new BatchFeedStep( control(), config, allIn( groupStore, config ), groupStore.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, groupStore ) ); add( new NodeSetFirstGroupStep( control(), config, nodeStore, cache ) ); add( new UpdateRecordsStep<>( control(), config, nodeStore, new StorePrepareIdSequence() ) ); } }
public SparseNodeFirstRelationshipStage( Configuration config, NodeStore nodeStore, NodeRelationshipCache cache ) { super( NAME, null, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); add( new ReadNodeIdsByCacheStep( control(), config, cache, NodeType.NODE_TYPE_SPARSE ) ); add( new ReadRecordsStep<>( control(), config, true, nodeStore ) ); add( new RecordProcessorStep<>( control(), "LINK", config, new SparseNodeFirstRelationshipProcessor( cache ), false ) ); add( new UpdateRecordsStep<>( control(), config, nodeStore, new StorePrepareIdSequence() ) ); } }
public RelationshipLinkforwardStage( String topic, Configuration config, BatchingNeoStores stores, NodeRelationshipCache cache, Predicate<RelationshipRecord> readFilter, Predicate<RelationshipRecord> denseChangeFilter, int nodeTypes, StatsProvider... additionalStatsProvider ) { super( NAME, topic, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); RelationshipStore store = stores.getRelationshipStore(); add( new BatchFeedStep( control(), config, forwards( 0, store.getHighId(), config ), store.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, store, new RecordDataAssembler<>( store::newRecord, readFilter ) ) ); add( new RelationshipLinkforwardStep( control(), config, cache, denseChangeFilter, nodeTypes, additionalStatsProvider ) ); add( new UpdateRecordsStep<>( control(), config, store, PrepareIdSequence.of( stores.usesDoubleRelationshipRecordUnits() ) ) ); } }
public RelationshipLinkbackStage( String topic, Configuration config, BatchingNeoStores stores, NodeRelationshipCache cache, Predicate<RelationshipRecord> readFilter, Predicate<RelationshipRecord> changeFilter, int nodeTypes, StatsProvider... additionalStatsProvider ) { super( NAME, topic, config, ORDER_SEND_DOWNSTREAM | RECYCLE_BATCHES ); RelationshipStore store = stores.getRelationshipStore(); add( new BatchFeedStep( control(), config, backwards( 0, store.getHighId(), config ), store.getRecordSize() ) ); add( new ReadRecordsStep<>( control(), config, true, store, new RecordDataAssembler<>( store::newRecord, readFilter ) ) ); add( new RelationshipLinkbackStep( control(), config, cache, changeFilter, nodeTypes, additionalStatsProvider ) ); add( new UpdateRecordsStep<>( control(), config, store, PrepareIdSequence.of( stores.usesDoubleRelationshipRecordUnits() ) ) ); } }