use of org.apache.storm.trident.state.CombinerValueUpdater in project storm by apache.
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 org.apache.storm.trident.state.CombinerValueUpdater in project storm by apache.
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 org.apache.storm.trident.state.CombinerValueUpdater in project storm by apache.
the class DebugMemoryMapState method print.
private void print(List<List<Object>> keys, List<ValueUpdater> updaters) {
for (int i = 0; i < keys.size(); i++) {
ValueUpdater valueUpdater = updaters.get(i);
Object arg = ((CombinerValueUpdater) valueUpdater).getArg();
LOG.info("updateCount = {}, keys = {} => updaterArgs = {}", updateCount, keys.get(i), arg);
}
}
Aggregations