Search in sources :

Example 6 with TridentTuple

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;
}
Also used : ArrayList(java.util.ArrayList) TridentTuple(storm.trident.tuple.TridentTuple)

Example 7 with TridentTuple

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) }));
    }
}
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 8 with TridentTuple

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));
}
Also used : TridentTuple(storm.trident.tuple.TridentTuple)

Example 9 with TridentTuple

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);
    }
}
Also used : ArrayList(java.util.ArrayList) TridentTuple(storm.trident.tuple.TridentTuple)

Example 10 with 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;
}
Also used : ArrayList(java.util.ArrayList) TridentTuple(storm.trident.tuple.TridentTuple)

Aggregations

TridentTuple (storm.trident.tuple.TridentTuple)25 ArrayList (java.util.ArrayList)10 List (java.util.List)8 Values (backtype.storm.tuple.Values)6 HashMap (java.util.HashMap)6 ComboList (storm.trident.tuple.ComboList)6 Map (java.util.Map)4 ValueUpdater (storm.trident.state.ValueUpdater)4 FailedException (backtype.storm.topology.FailedException)2 Fields (backtype.storm.tuple.Fields)2 TridentTopology (storm.trident.TridentTopology)2 Consumer (storm.trident.operation.Consumer)2 CombinerValueUpdater (storm.trident.state.CombinerValueUpdater)2 ReducerValueUpdater (storm.trident.state.ReducerValueUpdater)2 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)2 ProjectionFactory (storm.trident.tuple.TridentTupleView.ProjectionFactory)2 HashSet (java.util.HashSet)1 IllegalClassException (org.apache.commons.lang.IllegalClassException)1 Put (org.apache.hadoop.hbase.client.Put)1 ElasticSearchException (org.elasticsearch.ElasticSearchException)1