@Override public void execute(TupleWindow inputWindow) { List<Tuple> tuplesInWindow = inputWindow.get(); List<Tuple> newTuples = inputWindow.getNew(); List<Tuple> expiredTuples = inputWindow.getExpired(); LOG.info("tuplesInWindow.size() = " + tuplesInWindow.size()); LOG.info("newTuples.size() = " + newTuples.size()); LOG.info("expiredTuples.size() = " + expiredTuples.size()); LOG.info(StringDecorator.decorate(componentId, "tuplesInWindow = " + tuplesInWindow.stream() .map(t -> t.getValues()) .collect(Collectors.toList()))); collector.emit(new Values("dummyValue")); }
@Override public void execute(TupleWindow inputWindow) { List<Tuple> tuplesInWindow = inputWindow.get(); List<Tuple> newTuples = inputWindow.getNew(); List<Tuple> expiredTuples = inputWindow.getExpired(); LOG.info("tuplesInWindow.size() = " + tuplesInWindow.size()); LOG.info("newTuples.size() = " + newTuples.size()); LOG.info("expiredTuples.size() = " + expiredTuples.size()); List<TimeData> dataInWindow = tuplesInWindow.stream() .map(TimeData::fromTuple) .collect(Collectors.toList()); final String jsonData = TimeData.toString(dataInWindow); LOG.info(StringDecorator.decorate(componentId, jsonData)); collector.emit(new Values("dummyValue")); }
@Override public void execute(TupleWindow inputWindow) { /* * The inputWindow gives a view of * (a) all the events in the window * (b) events that expired since last activation of the window * (c) events that newly arrived since last activation of the window */ List<Tuple> tuplesInWindow = inputWindow.get(); List<Tuple> newTuples = inputWindow.getNew(); List<Tuple> expiredTuples = inputWindow.getExpired(); LOG.debug("Events in current window: " + tuplesInWindow.size()); /* * Instead of iterating over all the tuples in the window to compute * the sum, the values for the new events are added and old events are * subtracted. Similar optimizations might be possible in other * windowing computations. */ for (Tuple tuple : newTuples) { sum += (int) tuple.getValue(0); } for (Tuple tuple : expiredTuples) { sum -= (int) tuple.getValue(0); } collector.emit(new Values(sum)); }
@Override public void execute(TupleWindow inputWindow) { /* * The inputWindow gives a view of * (a) all the events in the window * (b) events that expired since last activation of the window * (c) events that newly arrived since last activation of the window */ List<Tuple> tuplesInWindow = inputWindow.get(); List<Tuple> newTuples = inputWindow.getNew(); List<Tuple> expiredTuples = inputWindow.getExpired(); LOG.debug("Events in current window: " + tuplesInWindow.size()); /* * Instead of iterating over all the tuples in the window to compute * the sum, the values for the new events are added and old events are * subtracted. Similar optimizations might be possible in other * windowing computations. */ for (Tuple tuple : newTuples) { sum += (int) tuple.getValue(0); } for (Tuple tuple : expiredTuples) { sum -= (int) tuple.getValue(0); } collector.emit(new Values(sum)); }