use of storm.trident.state.CombinerValueUpdater in project jstorm by alibaba.
the class MapCombinerAggStateUpdater method updateState.
@Override
public void updateState(MapState map, List<TridentTuple> tuples, TridentCollector collector) {
List<List<Object>> groups = new ArrayList<List<Object>>(tuples.size());
List<ValueUpdater> updaters = new ArrayList<ValueUpdater>(tuples.size());
for (TridentTuple t : tuples) {
groups.add(_groupFactory.create(t));
updaters.add(new CombinerValueUpdater(_agg, _inputFactory.create(t).getValue(0)));
}
List<Object> newVals = map.multiUpdate(groups, updaters);
for (int i = 0; i < tuples.size(); i++) {
List<Object> key = groups.get(i);
Object result = newVals.get(i);
collector.emit(_factory.create(new List[] { key, new Values(result) }));
}
}
use of storm.trident.state.CombinerValueUpdater in project jstorm by alibaba.
the class CombinerAggStateUpdater method updateState.
@Override
public void updateState(Snapshottable state, List<TridentTuple> tuples, TridentCollector collector) {
if (tuples.size() != 1) {
throw new IllegalArgumentException("Combiner state updater should receive a single tuple. Received: " + tuples.toString());
}
Object newVal = state.update(new CombinerValueUpdater(_agg, tuples.get(0).getValue(0)));
collector.emit(new Values(newVal));
}
use of storm.trident.state.CombinerValueUpdater in project storm by nathanmarz.
the class MapCombinerAggStateUpdater method updateState.
@Override
public void updateState(MapState map, List<TridentTuple> tuples, TridentCollector collector) {
List<List<Object>> groups = new ArrayList<List<Object>>(tuples.size());
List<ValueUpdater> updaters = new ArrayList<ValueUpdater>(tuples.size());
for (TridentTuple t : tuples) {
groups.add(_groupFactory.create(t));
updaters.add(new CombinerValueUpdater(_agg, _inputFactory.create(t).getValue(0)));
}
List<Object> newVals = map.multiUpdate(groups, updaters);
for (int i = 0; i < tuples.size(); i++) {
List<Object> key = groups.get(i);
Object result = newVals.get(i);
collector.emit(_factory.create(new List[] { key, new Values(result) }));
}
}
use of storm.trident.state.CombinerValueUpdater in project storm by nathanmarz.
the class CombinerAggStateUpdater method updateState.
@Override
public void updateState(Snapshottable state, List<TridentTuple> tuples, TridentCollector collector) {
if (tuples.size() != 1) {
throw new IllegalArgumentException("Combiner state updater should receive a single tuple. Received: " + tuples.toString());
}
Object newVal = state.update(new CombinerValueUpdater(_agg, tuples.get(0).getValue(0)));
collector.emit(new Values(newVal));
}
Aggregations