Search in sources :

Example 1 with EventTimeExtractor

use of edu.iu.dsc.tws.examples.task.streaming.windowing.extract.EventTimeExtractor in project twister2 by DSC-SPIDAL.

the class STWindowEventTimeExample method buildTaskGraph.

@Override
public ComputeGraphBuilder buildTaskGraph() {
    List<Integer> taskStages = jobParameters.getTaskStages();
    int sourceParallelism = taskStages.get(0);
    int sinkParallelism = taskStages.get(1);
    String edge = "edge";
    BaseWindowSource g = new SourceWindowTimeStampTask(edge);
    ITimestampExtractor<EventTimeData> timestampExtractor = new EventTimeExtractor();
    // Tumbling Window
    BaseWindowedSink dw = new DirectWindowedReceivingTask().withTumblingCountWindow(5);
    BaseWindowedSink dwDuration = new DirectWindowedReceivingTask().withTumblingDurationWindow(2, TimeUnit.MILLISECONDS);
    // Sliding Window
    BaseWindowedSink sdw = new DirectWindowedReceivingTask().withSlidingCountWindow(5, 2);
    BaseWindowedSink sdwDuration = new DirectWindowedReceivingTask().withSlidingDurationWindow(2, TimeUnit.MILLISECONDS, 1, TimeUnit.MILLISECONDS);
    BaseWindowedSink sdwDurationReduce = new DirectReduceWindowedTask(new ReduceFunctionImpl()).withSlidingDurationWindow(2, TimeUnit.MILLISECONDS, 1, TimeUnit.MILLISECONDS);
    BaseWindowedSink sdwCountSlidingReduce = new DirectReduceWindowedTask(new ReduceFunctionImpl()).withSlidingCountWindow(5, 2);
    BaseWindowedSink sdwCountTumblingReduce = new DirectReduceWindowedTask(new ReduceFunctionImpl()).withTumblingCountWindow(5);
    BaseWindowedSink sdwCountTumblingAggregate = new STWindowExample.DirectAggregateWindowedTask(new AggregateFunctionImpl(1, 2)).withTumblingCountWindow(5);
    BaseWindowedSink sdwCountTumblingFold = new DirectFoldWindowedTask(new FoldFunctionImpl()).withTumblingCountWindow(5);
    BaseWindowedSink sdwCountTumblingProcess = new DirectProcessWindowedIntTask(new ProcessFunctionIntImpl()).withCustomTimestampExtractor(timestampExtractor).withAllowedLateness(0, TimeUnit.MILLISECONDS).withWatermarkInterval(1, TimeUnit.MILLISECONDS).withTumblingDurationWindow(1, TimeUnit.MILLISECONDS);
    computeGraphBuilder.addSource(SOURCE, g, sourceParallelism);
    computeConnection = computeGraphBuilder.addCompute(SINK, sdwCountTumblingProcess, sinkParallelism);
    computeConnection.direct(SOURCE).viaEdge(edge).withDataType(MessageTypes.INTEGER_ARRAY);
    return computeGraphBuilder;
}
Also used : BaseWindowedSink(edu.iu.dsc.tws.task.window.core.BaseWindowedSink) EventTimeData(edu.iu.dsc.tws.examples.task.streaming.windowing.data.EventTimeData) BaseWindowSource(edu.iu.dsc.tws.task.window.BaseWindowSource) EventTimeExtractor(edu.iu.dsc.tws.examples.task.streaming.windowing.extract.EventTimeExtractor)

Aggregations

EventTimeData (edu.iu.dsc.tws.examples.task.streaming.windowing.data.EventTimeData)1 EventTimeExtractor (edu.iu.dsc.tws.examples.task.streaming.windowing.extract.EventTimeExtractor)1 BaseWindowSource (edu.iu.dsc.tws.task.window.BaseWindowSource)1 BaseWindowedSink (edu.iu.dsc.tws.task.window.core.BaseWindowedSink)1