Search in sources :

Example 1 with CombinerValueUpdater

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) }));
    }
}
Also used : CombinerValueUpdater(storm.trident.state.CombinerValueUpdater) ValueUpdater(storm.trident.state.ValueUpdater) ArrayList(java.util.ArrayList) Values(backtype.storm.tuple.Values) CombinerValueUpdater(storm.trident.state.CombinerValueUpdater) ArrayList(java.util.ArrayList) List(java.util.List) ComboList(storm.trident.tuple.ComboList) TridentTuple(storm.trident.tuple.TridentTuple)

Example 2 with CombinerValueUpdater

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));
}
Also used : Values(backtype.storm.tuple.Values) CombinerValueUpdater(storm.trident.state.CombinerValueUpdater)

Example 3 with CombinerValueUpdater

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) }));
    }
}
Also used : CombinerValueUpdater(storm.trident.state.CombinerValueUpdater) ValueUpdater(storm.trident.state.ValueUpdater) ArrayList(java.util.ArrayList) Values(backtype.storm.tuple.Values) CombinerValueUpdater(storm.trident.state.CombinerValueUpdater) ArrayList(java.util.ArrayList) List(java.util.List) ComboList(storm.trident.tuple.ComboList) TridentTuple(storm.trident.tuple.TridentTuple)

Example 4 with CombinerValueUpdater

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));
}
Also used : Values(backtype.storm.tuple.Values) CombinerValueUpdater(storm.trident.state.CombinerValueUpdater)

Aggregations

Values (backtype.storm.tuple.Values)4 CombinerValueUpdater (storm.trident.state.CombinerValueUpdater)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ValueUpdater (storm.trident.state.ValueUpdater)2 ComboList (storm.trident.tuple.ComboList)2 TridentTuple (storm.trident.tuple.TridentTuple)2