本文整理汇总了Java中storm.trident.operation.builtin.MapGet类的典型用法代码示例。如果您正苦于以下问题:Java MapGet类的具体用法?Java MapGet怎么用?Java MapGet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapGet类属于storm.trident.operation.builtin包,在下文中一共展示了MapGet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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();
}
示例2: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
.parallelismHint(6);
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();
}
示例3: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
public static StormTopology buildTopology() {
LOG.info("Building topology.");
TridentTopology topology = new TridentTopology();
StateFactory clickThruMemory = new MemoryMapState.Factory();
ClickThruSpout spout = new ClickThruSpout();
Stream inputStream = topology.newStream("clithru", spout);
TridentState clickThruState = inputStream.each(new Fields("username", "campaign", "product", "click"), new Filter("click", "true"))
.each(new Fields("username", "campaign", "product", "click"), new Distinct())
.groupBy(new Fields("campaign"))
.persistentAggregate(clickThruMemory, new Count(), new Fields("click_thru_count"));
inputStream.groupBy(new Fields("campaign"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("impression_count"))
.newValuesStream()
.stateQuery(clickThruState, new Fields("campaign"), new MapGet(), new Fields("click_thru_count"))
.each(new Fields("campaign", "impression_count", "click_thru_count"), new CampaignEffectiveness(), new Fields(""));
return topology.build();
}
示例4: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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"))
.groupBy(new Fields("followerClass", "contentName"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
;
topology
.newDRPCStream("hashtag_count")
.stateQuery(count, new TupleCollectionGet(), new Fields("followerClass", "contentName"))
.stateQuery(count, new Fields("followerClass", "contentName"), new MapGet(), new Fields("count"))
.groupBy(new Fields("followerClass"))
.aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(1,"count", true), new Fields("contentName", "count"))
;
return topology.build();
}
示例5: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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"))
.groupBy(new Fields("followerClass", "contentName"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
;
topology
.newDRPCStream("top_hashtags")
.stateQuery(count, new TupleCollectionGet(), new Fields("followerClass", "contentName"))
.stateQuery(count, new Fields("followerClass", "contentName"), new MapGet(), new Fields("count"))
.aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(5,"count", true), new Fields("contentName", "count"))
;
return topology.build();
}
示例6: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("status"), new OnlyGeo())
.each(new Fields("status", "content"), new ExtractLocation(), new Fields("country", "contentName"))
.groupBy(new Fields("country", "contentName"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
;
topology
.newDRPCStream("location_hashtag_count")
.stateQuery(count, new TupleCollectionGet(), new Fields("country", "contentName"))
.stateQuery(count, new Fields("country", "contentName"), new MapGet(), new Fields("count"))
.groupBy(new Fields("country"))
.aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(3,"count", true), new Fields("contentName", "count"))
;
return topology.build();
}
示例7: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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();
}
示例8: main
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = new Config();
// Submits the topology
String topologyName = args[0];
conf.setNumWorkers(8); // Our Vagrant environment has 8 workers
FakeTweetsBatchSpout fakeTweets = new FakeTweetsBatchSpout(10);
TridentTopology topology = new TridentTopology();
TridentState countState =
topology
.newStream("spout", fakeTweets)
.groupBy(new Fields("actor"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"));
topology
.newDRPCStream("count_per_actor")
.stateQuery(countState, new Fields("args"), new MapGet(), new Fields("count"));
StormSubmitter.submitTopology(topologyName, conf, topology.build());
}
示例9: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
TridentTopology topology = new TridentTopology();
TridentState urlToTweeters =
topology.newStaticState(
new StaticSingleKeyMapState.Factory(TWEETERS_DB));
TridentState tweetersToFollowers =
topology.newStaticState(
new StaticSingleKeyMapState.Factory(FOLLOWERS_DB));
topology.newDRPCStream("reach", drpc)
.stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields("tweeters"))
.each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter"))
.shuffle()
.stateQuery(tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers"))
.each(new Fields("followers"), new ExpandList(), new Fields("follower"))
.groupBy(new Fields("follower"))
.aggregate(new One(), new Fields("one"))
.aggregate(new Fields("one"), new Sum(), new Fields("reach"));
return topology.build();
}
示例10: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
public StormTopology buildTopology(LocalDRPC drpc) {
TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(brokerHosts, "storm-sentence", "storm");
kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
TransactionalTridentKafkaSpout kafkaSpout = new TransactionalTridentKafkaSpout(kafkaConfig);
TridentTopology topology = new TridentTopology();
TridentState wordCounts = topology.newStream("kafka", kafkaSpout).shuffle().
each(new Fields("str"), new WordSplit(), new Fields("word")).
groupBy(new Fields("word")).
persistentAggregate(new HazelCastStateFactory(), new Count(), new Fields("aggregates_words")).parallelismHint(2);
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();
}
示例11: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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();
}
示例12: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
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();
}
示例13: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
private static StormTopology buildTopology(LocalDRPC drpc) {
TridentTopology topology = new TridentTopology();
TridentState urlToTweeters = topology.newStaticState(new StaticSingleKeyMapState.Factory(TWEETERS_DB));
TridentState tweetersToFollowers = topology.newStaticState(new StaticSingleKeyMapState.Factory(FOLLOWERS_DB));
topology.newDRPCStream("reach", drpc)
.stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields("tweeters"))
.each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter")).shuffle()
.stateQuery(tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers"))
.each(new Fields("followers"), new ExpandList(), new Fields("follower"))
.groupBy(new Fields("follower")).aggregate(new One(), new Fields("one"))
.aggregate(new Fields("one"), new Sum(), new Fields("reach"));
return topology.build();
}
示例14: buildWordCountAndSourceTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static StormTopology buildWordCountAndSourceTopology(LocalDRPC drpc) {
LOG.info("Building topology.");
TridentTopology topology = new TridentTopology();
String source1 = "spout1";
String source2 = "spout2";
FixedBatchSpout spout1 = new FixedBatchSpout(new Fields("sentence", "source"), 3,
new Values("the cow jumped over the moon", source1),
new Values("the man went to the store and bought some candy", source1),
new Values("four score and four years ago", source2),
new Values("how much wood can a wood chuck chuck", source2));
spout1.setCycle(true);
TridentState wordCounts =
topology.newStream("spout1", spout1)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word", "source"))
.persistentAggregate(CassandraCqlMapState.nonTransactional(new WordCountAndSourceMapper()),
new IntegerCount(), new Fields("count"))
.parallelismHint(6);
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();
}
示例15: buildTopology
import storm.trident.operation.builtin.MapGet; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
TridentTopology topology = new TridentTopology();
TridentState urlToTweeters = topology.newStaticState(new StaticSingleKeyMapState.Factory(TWEETERS_DB));
TridentState tweetersToFollowers = topology.newStaticState(new StaticSingleKeyMapState.Factory(FOLLOWERS_DB));
topology.newDRPCStream("reach", drpc).stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields(
"tweeters")).each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter")).shuffle().stateQuery(
tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers")).each(new Fields("followers"),
new ExpandList(), new Fields("follower")).groupBy(new Fields("follower")).aggregate(new One(), new Fields(
"one")).aggregate(new Fields("one"), new Sum(), new Fields("reach"));
return topology.build();
}