Search in sources :

Example 16 with ConsoleOutputOperator

use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator 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)

Example 17 with ConsoleOutputOperator

use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.

the class ApexStreamImpl method print.

@Override
@SuppressWarnings("unchecked")
public ApexStreamImpl<T> print() {
    ConsoleOutputOperator consoleOutputOperator = new ConsoleOutputOperator();
    addOperator(consoleOutputOperator, (Operator.InputPort<T>) consoleOutputOperator.input, null, Option.Options.name(IDGenerator.generateOperatorIDWithUUID(consoleOutputOperator.getClass())));
    return this;
}
Also used : ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) Operator(com.datatorrent.api.Operator) FunctionOperator(org.apache.apex.malhar.lib.function.FunctionOperator) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator)

Example 18 with ConsoleOutputOperator

use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.

the class ApexStreamImpl method print.

@Override
@SuppressWarnings("unchecked")
public ApexStreamImpl<T> print(Option... opts) {
    ConsoleOutputOperator consoleOutputOperator = new ConsoleOutputOperator();
    addOperator(consoleOutputOperator, (Operator.InputPort<T>) consoleOutputOperator.input, null, opts);
    return this;
}
Also used : ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) Operator(com.datatorrent.api.Operator) FunctionOperator(org.apache.apex.malhar.lib.function.FunctionOperator) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator)

Example 19 with ConsoleOutputOperator

use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.

the class WindowedMergeOperatorTestApplication method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    WindowedMergeOperatorImpl<Integer, Integer, List<Set<Integer>>, List<List<Integer>>> op = dag.addOperator("Merge", new WindowedMergeOperatorImpl<Integer, Integer, List<Set<Integer>>, List<List<Integer>>>());
    op.setAccumulation(new CoGroup<Integer>());
    op.setDataStorage(new InMemoryWindowedStorage<List<Set<Integer>>>());
    op.setRetractionStorage(new InMemoryWindowedStorage<List<List<Integer>>>());
    op.setWindowStateStorage(windowStateMap);
    // Can select one of the following window options, or don't select any of them.
    // op.setWindowOption(new WindowOption.GlobalWindow());
    op.setWindowOption(new WindowOption.TimeWindows(Duration.millis(2000)));
    op.setTriggerOption(new TriggerOption().withEarlyFiringsAtEvery(1).accumulatingFiredPanes());
    op.setAllowedLateness(Duration.millis(500));
    NumGen1 numGen1 = dag.addOperator("numGen1", new NumGen1());
    NumGen2 numGen2 = dag.addOperator("numGen2", new NumGen2());
    Collector collector = dag.addOperator("collector", new Collector());
    ConsoleOutputOperator con = dag.addOperator("console", new ConsoleOutputOperator());
    dag.addStream("num1", numGen1.output, op.input);
    dag.addStream("num2", numGen2.output, op.input2);
    dag.addStream("wm1", numGen1.watermarkDefaultOutputPort, op.controlInput);
    dag.addStream("wm2", numGen2.watermarkDefaultOutputPort, op.controlInput2);
    dag.addStream("MergedResult", op.output, collector.input);
    dag.addStream("output", collector.output, con.input);
}
Also used : TriggerOption(org.apache.apex.malhar.lib.window.TriggerOption) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with ConsoleOutputOperator

use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.

the class Application method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration configuration) {
    WordGenerator inputOperator = new WordGenerator();
    KeyedWindowedOperatorImpl<String, Long, MutableLong, Long> windowedOperator = new KeyedWindowedOperatorImpl<>();
    Accumulation<Long, MutableLong, Long> sum = new SumAccumulation();
    windowedOperator.setAccumulation(sum);
    windowedOperator.setDataStorage(new InMemoryWindowedKeyedStorage<String, MutableLong>());
    windowedOperator.setRetractionStorage(new InMemoryWindowedKeyedStorage<String, Long>());
    windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());
    windowedOperator.setWindowOption(new WindowOption.TimeWindows(Duration.standardMinutes(1)));
    windowedOperator.setTriggerOption(TriggerOption.AtWatermark().withEarlyFiringsAtEvery(Duration.millis(1000)).accumulatingAndRetractingFiredPanes());
    // windowedOperator.setAllowedLateness(Duration.millis(14000));
    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) SumAccumulation(org.apache.apex.malhar.lib.window.SumAccumulation) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) KeyedWindowedOperatorImpl(org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) MutableLong(org.apache.commons.lang3.mutable.MutableLong) MutableLong(org.apache.commons.lang3.mutable.MutableLong)

Aggregations

ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)36 RandomEventGenerator (org.apache.apex.malhar.lib.testbench.RandomEventGenerator)6 Operator (com.datatorrent.api.Operator)5 Counter (org.apache.apex.malhar.lib.stream.Counter)5 PubSubWebSocketAppDataQuery (org.apache.apex.malhar.lib.io.PubSubWebSocketAppDataQuery)4 PubSubWebSocketAppDataResult (org.apache.apex.malhar.lib.io.PubSubWebSocketAppDataResult)4 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)4 URI (java.net.URI)3 UniqueCounter (org.apache.apex.malhar.lib.algo.UniqueCounter)3 AppDataSnapshotServerMap (org.apache.apex.malhar.lib.appdata.snapshot.AppDataSnapshotServerMap)3 MapToKeyHashValuePairConverter (org.apache.apex.malhar.lib.converter.MapToKeyHashValuePairConverter)3 WindowState (org.apache.apex.malhar.lib.window.WindowState)3 List (java.util.List)2 FunctionOperator (org.apache.apex.malhar.lib.function.FunctionOperator)2 ApacheLogParseMapOutputOperator (org.apache.apex.malhar.lib.logs.ApacheLogParseMapOutputOperator)2 DimensionObject (org.apache.apex.malhar.lib.logs.DimensionObject)2 JsonByteArrayOperator (org.apache.apex.malhar.lib.stream.JsonByteArrayOperator)2 KeyValPair (org.apache.apex.malhar.lib.util.KeyValPair)2 FSWindowDataManager (org.apache.apex.malhar.lib.wal.FSWindowDataManager)2 TriggerOption (org.apache.apex.malhar.lib.window.TriggerOption)2