use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.
the class SnapshotGet method batchRetrieve.
@Override
public List<Object> batchRetrieve(ReadOnlySnapshottable state, List<TridentTuple> args) {
List<Object> ret = new ArrayList<Object>(args.size());
Object snapshot = state.get();
for (TridentTuple arg : args) {
ret.add(snapshot);
}
return ret;
}
use of storm.trident.tuple.TridentTuple 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.tuple.TridentTuple in project jstorm by alibaba.
the class StoreBasedTridentWindowManager method addToWindowManager.
private void addToWindowManager(int tupleIndex, String effectiveBatchId, TridentTuple tridentTuple) {
TridentTuple actualTuple = null;
if (maxCachedTuplesSize == null || currentCachedTuplesSize.get() < maxCachedTuplesSize) {
actualTuple = tridentTuple;
}
currentCachedTuplesSize.incrementAndGet();
windowManager.add(new TridentBatchTuple(effectiveBatchId, System.currentTimeMillis(), tupleIndex, actualTuple));
}
use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.
the class StoreBasedTridentWindowManager method addTuplesBatch.
public void addTuplesBatch(Object batchId, List<TridentTuple> tuples) {
LOG.debug("Adding tuples to window-manager for batch: [{}]", batchId);
List<WindowsStore.Entry> entries = new ArrayList<>();
for (int i = 0; i < tuples.size(); i++) {
String key = keyOf(batchId);
TridentTuple tridentTuple = tuples.get(i);
entries.add(new WindowsStore.Entry(key + i, tridentTuple.select(inputFields)));
}
// tuples should be available in store before they are added to window manager
windowStore.putAll(entries);
for (int i = 0; i < tuples.size(); i++) {
String key = keyOf(batchId);
TridentTuple tridentTuple = tuples.get(i);
addToWindowManager(i, key, tridentTuple);
}
}
use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.
the class StoreBasedTridentWindowManager method getTridentTuples.
public List<TridentTuple> getTridentTuples(List<TridentBatchTuple> tridentBatchTuples) {
List<TridentTuple> resultTuples = new ArrayList<>();
List<String> keys = new ArrayList<>();
for (TridentBatchTuple tridentBatchTuple : tridentBatchTuples) {
TridentTuple tuple = collectTridentTupleOrKey(tridentBatchTuple, keys);
if (tuple != null) {
resultTuples.add(tuple);
}
}
if (keys.size() > 0) {
Iterable<Object> storedTupleValues = windowStore.get(keys);
for (Object storedTupleValue : storedTupleValues) {
TridentTuple tridentTuple = freshOutputFactory.create((List<Object>) storedTupleValue);
resultTuples.add(tridentTuple);
}
}
return resultTuples;
}
Aggregations