Search in sources :

Example 1 with StringLength

use of org.apache.storm.trident.testing.StringLength in project storm by apache.

the class TestTridentTopology method buildTopology.

private StormTopology buildTopology() {
    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"));
    spout.setCycle(true);
    TridentTopology topology = new TridentTopology();
    topology.newStream("spout", spout).each(new Fields("sentence"), new Split(), new Fields("word")).partitionBy(new Fields("word")).name("abc").each(new Fields("word"), new StringLength(), new Fields("length")).partitionBy(new Fields("length")).name("def").aggregate(new Fields("length"), new Count(), new Fields("count")).partitionBy(new Fields("count")).name("ghi").aggregate(new Fields("count"), new Sum(), new Fields("sum"));
    return topology.build();
}
Also used : FixedBatchSpout(org.apache.storm.trident.testing.FixedBatchSpout) StringLength(org.apache.storm.trident.testing.StringLength) Fields(org.apache.storm.tuple.Fields) Values(org.apache.storm.tuple.Values) Sum(org.apache.storm.trident.operation.builtin.Sum) Count(org.apache.storm.trident.operation.builtin.Count) Split(org.apache.storm.trident.testing.Split)

Aggregations

Count (org.apache.storm.trident.operation.builtin.Count)1 Sum (org.apache.storm.trident.operation.builtin.Sum)1 FixedBatchSpout (org.apache.storm.trident.testing.FixedBatchSpout)1 Split (org.apache.storm.trident.testing.Split)1 StringLength (org.apache.storm.trident.testing.StringLength)1 Fields (org.apache.storm.tuple.Fields)1 Values (org.apache.storm.tuple.Values)1