Search in sources :

Example 1 with TridentTuple

use of storm.trident.tuple.TridentTuple in project storm by nathanmarz.

the class GroupedMultiReducerExecutor method complete.

@Override
public void complete(Map<TridentTuple, Object> state, TridentCollector collector) {
    for (Map.Entry e : state.entrySet()) {
        TridentTuple group = (TridentTuple) e.getKey();
        Object val = e.getValue();
        _reducer.complete(val, group, collector);
    }
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) TridentTuple(storm.trident.tuple.TridentTuple)

Example 2 with TridentTuple

use of storm.trident.tuple.TridentTuple in project storm-hbase by jrkinley.

the class HBaseValueUpdater method updateState.

/**
 * {@inheritDoc}
 */
@Override
public void updateState(HBaseValueState state, List<TridentTuple> tuples, TridentCollector collector) {
    List<Put> puts = new ArrayList<Put>();
    for (TridentTuple t : tuples) {
        puts.add(state.getConf().getPutFromTridentTuple(t));
    }
    state.setValuesBulk(puts);
}
Also used : ArrayList(java.util.ArrayList) Put(org.apache.hadoop.hbase.client.Put) TridentTuple(storm.trident.tuple.TridentTuple)

Example 3 with TridentTuple

use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.

the class TridentWindowingInmemoryStoreTopology method buildTopology.

public static StormTopology buildTopology(WindowsStoreFactory windowStore, WindowConfig windowConfig) throws Exception {
    FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
    spout.setCycle(true);
    TridentTopology topology = new TridentTopology();
    Stream stream = topology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowStore, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new Consumer() {

        @Override
        public void accept(TridentTuple input) {
            LOG.info("Received tuple: [{}]", input);
        }
    });
    return topology.build();
}
Also used : FixedBatchSpout(storm.trident.testing.FixedBatchSpout) Fields(backtype.storm.tuple.Fields) Consumer(storm.trident.operation.Consumer) TridentTopology(storm.trident.TridentTopology) CountAsAggregator(storm.trident.testing.CountAsAggregator) Values(backtype.storm.tuple.Values) Stream(storm.trident.Stream) Split(storm.trident.testing.Split) TridentTuple(storm.trident.tuple.TridentTuple)

Example 4 with TridentTuple

use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.

the class GroupedMultiReducerExecutor method complete.

@Override
public void complete(Map<TridentTuple, Object> state, TridentCollector collector) {
    for (Map.Entry e : state.entrySet()) {
        TridentTuple group = (TridentTuple) e.getKey();
        Object val = e.getValue();
        _reducer.complete(val, group, collector);
    }
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) TridentTuple(storm.trident.tuple.TridentTuple)

Example 5 with TridentTuple

use of storm.trident.tuple.TridentTuple in project jstorm by alibaba.

the class ChainedAggregatorImpl method aggregate.

public void aggregate(ChainedResult val, TridentTuple tuple, TridentCollector collector) {
    val.setFollowThroughCollector(collector);
    for (int i = 0; i < _aggs.length; i++) {
        TridentTuple projected = _inputFactories[i].create((TridentTupleView) tuple);
        _aggs[i].aggregate(val.objs[i], projected, val.collectors[i]);
    }
}
Also used : 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