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() ) ); } }
@Test public void shouldProduceCompleteBatchesPerOwner() { // GIVEN Configuration config = Configuration.withBatchSize( DEFAULT, 10 ); Iterator<RelationshipGroupRecord> groups = groups( new Group( 1, 3 ), new Group( 2, 3 ), new Group( 3, 4 ), // ^^^ perfect batch size new Group( 4, 2 ), new Group( 5, 10 ), // ^^^ slightly bigger than batch size new Group( 6, 35 ), // ^^^ much bigger than batch size new Group( 7, 2 ) ).iterator(); final AtomicInteger processCounter = new AtomicInteger(); Stage stage = new Stage( getClass().getSimpleName(), null, config, 0 ) { { add( new ReadGroupsFromCacheStep( control(), config, groups, 1 ) ); add( new VerifierStep( control(), config, processCounter ) ); } }; // WHEN processing the data superviseDynamicExecution( stage ); // THEN assertEquals( 4, processCounter.get() ); }
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() ) ); } }