Search in sources :

Example 1 with Window

use of com.twitter.heron.streamlet.Window in project incubator-heron by apache.

the class JoinOperator method getKeyedWindow.

private KeyedWindow<K> getKeyedWindow(K key, TupleWindow tupleWindow) {
    long startWindow;
    long endWindow;
    if (tupleWindow.getStartTimestamp() == null) {
        startWindow = 0;
    } else {
        startWindow = tupleWindow.getStartTimestamp();
    }
    if (tupleWindow.getEndTimestamp() == null) {
        endWindow = 0;
    } else {
        endWindow = tupleWindow.getEndTimestamp();
    }
    Window window = new Window(startWindow, endWindow, tupleWindow.get().size());
    return new KeyedWindow<>(key, window);
}
Also used : KeyedWindow(com.twitter.heron.streamlet.KeyedWindow) Window(com.twitter.heron.streamlet.Window) TupleWindow(com.twitter.heron.api.windowing.TupleWindow) KeyedWindow(com.twitter.heron.streamlet.KeyedWindow)

Example 2 with Window

use of com.twitter.heron.streamlet.Window in project incubator-heron by apache.

the class ReduceByKeyAndWindowOperator method execute.

@SuppressWarnings("unchecked")
@Override
public void execute(TupleWindow inputWindow) {
    Map<K, V> reduceMap = new HashMap<>();
    Map<K, Integer> windowCountMap = new HashMap<>();
    for (Tuple tuple : inputWindow.get()) {
        R tup = (R) tuple.getValue(0);
        addMap(reduceMap, windowCountMap, tup);
    }
    long startWindow;
    long endWindow;
    if (inputWindow.getStartTimestamp() == null) {
        startWindow = 0;
    } else {
        startWindow = inputWindow.getStartTimestamp();
    }
    if (inputWindow.getEndTimestamp() == null) {
        endWindow = 0;
    } else {
        endWindow = inputWindow.getEndTimestamp();
    }
    for (K key : reduceMap.keySet()) {
        Window window = new Window(startWindow, endWindow, windowCountMap.get(key));
        KeyedWindow<K> keyedWindow = new KeyedWindow<>(key, window);
        collector.emit(new Values(new KeyValue<>(keyedWindow, reduceMap.get(key))));
    }
}
Also used : KeyedWindow(com.twitter.heron.streamlet.KeyedWindow) Window(com.twitter.heron.streamlet.Window) TupleWindow(com.twitter.heron.api.windowing.TupleWindow) KeyValue(com.twitter.heron.streamlet.KeyValue) HashMap(java.util.HashMap) KeyedWindow(com.twitter.heron.streamlet.KeyedWindow) Values(com.twitter.heron.api.tuple.Values) Tuple(com.twitter.heron.api.tuple.Tuple)

Example 3 with Window

use of com.twitter.heron.streamlet.Window in project incubator-heron by apache.

the class GeneralReduceByKeyAndWindowOperator method execute.

@SuppressWarnings("unchecked")
@Override
public void execute(TupleWindow inputWindow) {
    Map<K, VR> reduceMap = new HashMap<>();
    Map<K, Integer> windowCountMap = new HashMap<>();
    for (Tuple tuple : inputWindow.get()) {
        V tup = (V) tuple.getValue(0);
        addMap(reduceMap, windowCountMap, tup);
    }
    long startWindow;
    long endWindow;
    if (inputWindow.getStartTimestamp() == null) {
        startWindow = 0;
    } else {
        startWindow = inputWindow.getStartTimestamp();
    }
    if (inputWindow.getEndTimestamp() == null) {
        endWindow = 0;
    } else {
        endWindow = inputWindow.getEndTimestamp();
    }
    for (K key : reduceMap.keySet()) {
        Window window = new Window(startWindow, endWindow, windowCountMap.get(key));
        KeyedWindow<K> keyedWindow = new KeyedWindow<>(key, window);
        collector.emit(new Values(new KeyValue<>(keyedWindow, reduceMap.get(key))));
    }
}
Also used : KeyedWindow(com.twitter.heron.streamlet.KeyedWindow) Window(com.twitter.heron.streamlet.Window) TupleWindow(com.twitter.heron.api.windowing.TupleWindow) KeyValue(com.twitter.heron.streamlet.KeyValue) HashMap(java.util.HashMap) KeyedWindow(com.twitter.heron.streamlet.KeyedWindow) Values(com.twitter.heron.api.tuple.Values) Tuple(com.twitter.heron.api.tuple.Tuple)

Aggregations

TupleWindow (com.twitter.heron.api.windowing.TupleWindow)3 KeyedWindow (com.twitter.heron.streamlet.KeyedWindow)3 Window (com.twitter.heron.streamlet.Window)3 Tuple (com.twitter.heron.api.tuple.Tuple)2 Values (com.twitter.heron.api.tuple.Values)2 KeyValue (com.twitter.heron.streamlet.KeyValue)2 HashMap (java.util.HashMap)2