Search in sources :

Example 1 with PojoInnerJoin

use of org.apache.apex.malhar.lib.window.accumulation.PojoInnerJoin in project apex-malhar by apache.

the class PojoInnerJoinTestApplication method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    POJOGenerator salesGenerator = dag.addOperator("Input1", new POJOGenerator(1, 1));
    POJOGenerator productGenerator = dag.addOperator("Input2", new POJOGenerator(1, 1));
    productGenerator.setSalesEvent(false);
    WindowedMergeOperatorImpl<POJOGenerator.SalesEvent, POJOGenerator.ProductEvent, List<Set<Object>>, List<List<Object>>> op = dag.addOperator("Merge", new WindowedMergeOperatorImpl<POJOGenerator.SalesEvent, POJOGenerator.ProductEvent, List<Set<Object>>, List<List<Object>>>());
    op.setAccumulation(new PojoInnerJoin(2, POJOGenerator.OutputEvent.class, "productId", "productId"));
    op.setDataStorage(new InMemoryWindowedStorage<List<Set<Object>>>());
    WindowedStorage.WindowedPlainStorage<WindowState> windowStateMap = new InMemoryWindowedStorage<>();
    op.setWindowStateStorage(windowStateMap);
    op.setWindowOption(new WindowOption.TimeWindows(Duration.millis(10)));
    op.setTriggerOption(new TriggerOption().withEarlyFiringsAtEvery(1).accumulatingFiredPanes());
    op.setAllowedLateness(Duration.millis(500));
    ResultCollector results = dag.addOperator("results", new ResultCollector());
    dag.addStream("SalesToJoin", salesGenerator.outputsales, op.input);
    dag.addStream("ProductToJoin", productGenerator.outputproduct, op.input2);
    dag.addStream("results", op.output, results.input);
    dag.addStream("wm1", salesGenerator.watermarkDefaultOutputPort, op.controlInput);
    dag.addStream("wm2", productGenerator.watermarkDefaultOutputPort, op.controlInput2);
}
Also used : WindowState(org.apache.apex.malhar.lib.window.WindowState) PojoInnerJoin(org.apache.apex.malhar.lib.window.accumulation.PojoInnerJoin) TriggerOption(org.apache.apex.malhar.lib.window.TriggerOption) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) WindowedStorage(org.apache.apex.malhar.lib.window.WindowedStorage) List(java.util.List)

Aggregations

List (java.util.List)1 TriggerOption (org.apache.apex.malhar.lib.window.TriggerOption)1 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)1 WindowState (org.apache.apex.malhar.lib.window.WindowState)1 WindowedStorage (org.apache.apex.malhar.lib.window.WindowedStorage)1 PojoInnerJoin (org.apache.apex.malhar.lib.window.accumulation.PojoInnerJoin)1