September 2017
Beginner to intermediate
360 pages
8h 13m
English
Here, in basic Storm Trident topology we will go through a word count example. More examples will be explained later in the chapter. This is the code for the example:
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,new Values("this is simple example of trident topology"),new Values("this example count same words"));spout.setCycle(true); // Line 1TridentTopology topology = new TridentTopology(); // Line 2MemoryMapState.Factory stateFactory = new MemoryMapState.Factory(); // Line 3topology.newStream("spout1", spout) // Line 4.each(new Fields("sentence"), new Split(), new Fields("word")) // Line 5.groupBy(new Fields("word")) // Line 6.persistentAggregate(stateFactory, new Count(), new Fields("count")).newValuesStream() ...Read now
Unlock full access