Search in sources :

Example 1 with WindowedOperatorImpl

use of org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl in project apex-malhar by apache.

the class WindowedOperatorTest method createDefaultWindowedOperator.

private WindowedOperatorImpl<Long, MutableLong, Long> createDefaultWindowedOperator() {
    WindowedOperatorImpl<Long, MutableLong, Long> windowedOperator = new WindowedOperatorImpl<>();
    if (useSpillable) {
        sccImpl = new SpillableComplexComponentImpl(testMeta.timeStore);
        // TODO: We don't yet support Spillable data structures for window state storage because SpillableMapImpl does not yet support iterating over all keys.
        windowStateStorage = new InMemoryWindowedStorage<>();
        SpillableWindowedPlainStorage<MutableLong> pds = new SpillableWindowedPlainStorage<>();
        pds.setSpillableComplexComponent(sccImpl);
        plainDataStorage = pds;
        SpillableWindowedPlainStorage<Long> prs = new SpillableWindowedPlainStorage<>();
        prs.setSpillableComplexComponent(sccImpl);
        plainRetractionStorage = prs;
        windowedOperator.addComponent("SpillableComplexComponent", sccImpl);
    } else {
        windowStateStorage = new InMemoryWindowedStorage<>();
        plainDataStorage = new InMemoryWindowedStorage<>();
        plainRetractionStorage = new InMemoryWindowedStorage<>();
    }
    windowedOperator.setDataStorage(plainDataStorage);
    windowedOperator.setRetractionStorage(plainRetractionStorage);
    windowedOperator.setWindowStateStorage(windowStateStorage);
    windowedOperator.setAccumulation(new SumAccumulation());
    return windowedOperator;
}
Also used : KeyedWindowedOperatorImpl(org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl) WindowedOperatorImpl(org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl) MutableLong(org.apache.commons.lang3.mutable.MutableLong) MutableLong(org.apache.commons.lang3.mutable.MutableLong) SpillableWindowedPlainStorage(org.apache.apex.malhar.lib.window.impl.SpillableWindowedPlainStorage) SpillableComplexComponentImpl(org.apache.apex.malhar.lib.state.spillable.SpillableComplexComponentImpl)

Example 2 with WindowedOperatorImpl

use of org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl in project apex-malhar by apache.

the class Application method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration configuration) {
    RandomNumberPairGenerator inputOperator = new RandomNumberPairGenerator();
    WindowedOperatorImpl<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> windowedOperator = new WindowedOperatorImpl<>();
    Accumulation<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> piAccumulation = new PiAccumulation();
    windowedOperator.setAccumulation(piAccumulation);
    windowedOperator.setDataStorage(new InMemoryWindowedStorage<MutablePair<MutableLong, MutableLong>>());
    windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());
    windowedOperator.setWindowOption(new WindowOption.GlobalWindow());
    windowedOperator.setTriggerOption(TriggerOption.AtWatermark().withEarlyFiringsAtEvery(Duration.millis(1000)).accumulatingFiredPanes());
    ConsoleOutputOperator outputOperator = new ConsoleOutputOperator();
    dag.addOperator("inputOperator", inputOperator);
    dag.addOperator("windowedOperator", windowedOperator);
    dag.addOperator("outputOperator", outputOperator);
    dag.addStream("input_windowed", inputOperator.output, windowedOperator.input);
    dag.addStream("windowed_output", windowedOperator.output, outputOperator.input);
}
Also used : WindowState(org.apache.apex.malhar.lib.window.WindowState) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) WindowedOperatorImpl(org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) MutablePair(org.apache.commons.lang3.tuple.MutablePair)

Aggregations

WindowedOperatorImpl (org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl)2 ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)1 SpillableComplexComponentImpl (org.apache.apex.malhar.lib.state.spillable.SpillableComplexComponentImpl)1 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)1 WindowState (org.apache.apex.malhar.lib.window.WindowState)1 KeyedWindowedOperatorImpl (org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl)1 SpillableWindowedPlainStorage (org.apache.apex.malhar.lib.window.impl.SpillableWindowedPlainStorage)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 MutablePair (org.apache.commons.lang3.tuple.MutablePair)1