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(); }
public static StormTopology buildTopology(LocalDRPC drpc) { FixedBatchSpout spout = new FixedBatchSpout(new Fields("word"), 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(); TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16).flatMap(split).map(toUpper) .filter(theFilter).peek(new Consumer() { @Override public void accept(TridentTuple input) { System.out.println(input.getString(0)); } }).groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) .parallelismHint(16); topology.newDRPCStream("words", drpc).flatMap(split).groupBy(new Fields("args")) .stateQuery(wordCounts, new Fields("args"), new MapGet(), new Fields("count")).filter(new FilterNull()) .aggregate(new Fields("count"), new Sum(), new Fields("sum")); return topology.build(); }
public static StormTopology buildTopology(LocalDRPC drpc) { 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(); TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")).groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) .parallelismHint(16); topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word")) .groupBy(new Fields("word")) .stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count")) .each(new Fields("count"), new FilterNull()) .aggregate(new Fields("count"), new Sum(), new Fields("sum")); return topology.build(); }
TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(spout_Parallelism_hint) .each(new Fields("sentence"), new Split(), new Fields("word")).parallelismHint(split_Parallelism_hint).groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) .parallelismHint(count_Parallelism_hint);
public static StormTopology buildTopology(LocalDRPC drpc) throws IOException { FakeTweetsBatchSpout spout = new FakeTweetsBatchSpout(); TridentTopology topology = new TridentTopology(); topology.newStream("spout", spout) .parallelismHint(2) .partitionBy(new Fields("actor")) // .shuffle() .each(new Fields("actor", "text"), new PerActorTweetsFilter("dave")).parallelismHint(5) .each(new Fields("actor", "text"), new Utils.PrintFilter()); return topology.build(); }
new BucketsStateQuery(), new Fields("tw_id", "collidingTweetsList")) .parallelismHint(bucketsParallelism) .each(new Fields("collidingTweetsList"), new ExpandList(), new Fields("coltweet_obj", "coltweetId")) "coltweet_obj"), new ComputeDistance(), new Fields("cosSim")) .parallelismHint(computeDistance) new RecentTweetsStateQuery(), new Fields("nnRecentTweet")) .parallelismHint(recentTweetsParalellism)
.parallelismHint(5).each(new Fields("text", "actor"), new Utils.PrintFilter()); .each(new Fields("text", "actor"), new PereTweetsFilter()).parallelismHint(5) .each(new Fields("text", "actor"), new Utils.PrintFilter()); topology.newStream("parallel_and_partitioned", spout).parallelismHint(1).shuffle() .each(new Fields("text", "actor"), new PereTweetsFilter()).parallelismHint(5) .each(new Fields("text", "actor"), new Utils.PrintFilter()); topology.newStream("aggregation", spout).parallelismHint(1) .aggregate(new Fields("location"), new LocationAggregator(), new Fields("aggregated_result")) .parallelismHint(5).each(new Fields("aggregated_result"), new Utils.PrintFilter()); .parallelismHint(1) .shuffle() .partitionAggregate(new Fields("location"), new LocationAggregator(), new Fields("aggregated_result")).parallelismHint(6) .each(new Fields("aggregated_result"), new Utils.PrintFilter()); topology.newStream("aggregation", spout).parallelismHint(1).groupBy(new Fields("location")) .aggregate(new Fields("location"), new Count(), new Fields("count")).parallelismHint(5) .each(new Fields("location", "count"), new Utils.PrintFilter());
.newStream("aggregation", spout) .aggregate(new Fields("location"), new StringCounter(), new Fields("aggregated_result")) .parallelismHint(3) .partitionBy(new Fields("location")) .partitionAggregate(new Fields("location"), new StringCounter(), new Fields("aggregated_result")) .parallelismHint(3) .each(new Fields("count_map"), new HasSpain()) .each(new Fields("count_map"), new Print("AFTER-HAS-SPAIN")) .parallelismHint(3) .shuffle() .each(new Fields("count_map"), new TimesTen(), new Fields("count_map_times_ten")) .each(new Fields("count_map_times_ten"), new Print("AFTER-TIMES-TEN")) .parallelismHint(3) .global() .each(new Fields("actor"), new Print()) .parallelismHint(3)
stream = stream.parallelismHint(component.getParallelism());
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException { TridentTopology topology = new TridentTopology(); TridentState count = topology .newStream("tweets", spout) .each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user")) .project(new Fields("content", "user")) .each(new Fields("content"), new OnlyHashtags()) .each(new Fields("user"), new OnlyEnglish()) .each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName")) .parallelismHint(3) .groupBy(new Fields("followerClass", "contentName")) .persistentAggregate(new HazelCastStateFactory(), new Count(), new Fields("count")) .parallelismHint(3) ; topology .newDRPCStream("hashtag_count") .each(new Constants<String>("< 100", "< 10K", "< 100K", ">= 100K"), new Fields("followerClass")) .stateQuery(count, new Fields("followerClass", "args"), new MapGet(), new Fields("count")) ; return topology.build(); }
.newStream("parallel", spout) .each(new Fields("actor"), new RegexFilter("pere")) .parallelismHint(5) .each(new Fields("text", "actor"), new Print());