本文整理汇总了Java中storm.trident.operation.builtin.FilterNull类的典型用法代码示例。如果您正苦于以下问题:Java FilterNull类的具体用法?Java FilterNull怎么用?Java FilterNull使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FilterNull类属于storm.trident.operation.builtin包,在下文中一共展示了FilterNull类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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.FilterNull; //导入依赖的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.FilterNull; //导入依赖的package包/类
@Override
protected 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"),
new Values("to be or not to be the person"));
spout.setCycle(true);
ESIndexState.Factory<Tweet> factory = new ESIndexState.Factory<>(getLocalClient(), Tweet.class);
TridentTopology topology = new TridentTopology();
TridentState state = topology.newStream("tweets", spout)
.partitionPersist(factory, new Fields("sentence"), new ESIndexUpdater(new MyTridentTupleMapper()));
topology.newDRPCStream("search", drpc)
.each(new Fields("args"), new ExtractSearchArgs(), new Fields("query", "indices", "types"))
.groupBy(new Fields("query", "indices", "types"))
.stateQuery(state, new Fields("query", "indices", "types"), new QuerySearchIndexQuery(), new Fields("tweet"))
.each(new Fields("tweet"), new FilterNull())
.each(new Fields("tweet"), new CreateJson(), new Fields("json"))
.project(new Fields("json"));
return topology.build();
}
示例4: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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();
}
示例5: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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();
}
示例6: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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();
}
示例7: buildWordCountAndSourceTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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();
}
示例8: buildTopology1
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
private static StormTopology buildTopology1(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 100,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("to be or not to be the person"));
spout.setCycle(true);
AerospikeOptions options = new AerospikeOptions();
options.set = "words";
options.keyType = AerospikeOptions.AerospikeKeyType.STRING;
TridentTopology topology = new TridentTopology();
TridentState wordCounts =
topology.newStream("spout1", spout)
.parallelismHint(4)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(AerospikeSingleBinMapState.getTransactional("count", options),
new CountAggregator(), new Fields("count"))
.parallelismHint(4);
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();
}
示例9: buildTopology2
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
private static StormTopology buildTopology2(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("customerid", "fruit"), 100,
new Values(1L, "apple"),
new Values(1L, "apple"),
new Values(1L, "apple"),
new Values(1L, "pear"),
new Values(2L, "pear"),
new Values(2L, "orange"),
new Values(3L, "orange"),
new Values(3L, "orange"),
new Values(3L, "banana"));
spout.setCycle(true);
AerospikeOptions options = new AerospikeOptions();
options.set = "customers";
options.keyType = AerospikeOptions.AerospikeKeyType.LONG;
TridentTopology topology = new TridentTopology();
TridentState fruitCounts =
topology.newStream("spout2", spout)
.parallelismHint(4)
.groupBy(new Fields("customerid", "fruit"))
.persistentAggregate(AerospikeSplitKeySingleBinMapState.getTransactional("fruits", options),
new CountAggregator(), new Fields("count"))
.parallelismHint(4);
topology.newDRPCStream("fruits", drpc)
.each(new Fields("args"), new SplitIntoTwo(), new Fields("customerid", "fruit"))
.groupBy(new Fields("customerid", "fruit"))
.stateQuery(fruitCounts, new Fields("customerid", "fruit"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.project(new Fields("count"));
return topology.build();
}
示例10: addDRPCStream
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
private Stream addDRPCStream(TridentTopology tridentTopology, TridentState state, LocalDRPC drpc) {
return tridentTopology.newDRPCStream("words", drpc)
.each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(state, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.project(new Fields("word", "count"));
}
示例11: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
@Override
public StormTopology buildTopology( ) {
ESIndexMapState.Factory<Tweet> state = ESIndexMapState.nonTransactional(getLocalClient(), Tweet.class);
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 staticState = topology.newStaticState(new ESIndexState.Factory<>(getLocalClient(), Tweet.class));
topology.newStream("tweets", spout)
.each(new Fields("sentence"), new DocumentBuilder(), new Fields("document"))
.each(new Fields("document"), new ExtractDocumentInfo(), new Fields("id", "index", "type"))
.groupBy(new Fields("index", "type", "id"))
.persistentAggregate(state, new Fields("document"), new TweetBuilder(), new Fields("tweet"))
.parallelismHint(1);
topology.newDRPCStream("search", drpc)
.each(new Fields("args"), new ExtractSearchArgs(), new Fields("query", "indices", "types"))
.groupBy(new Fields("query", "indices", "types"))
.stateQuery(staticState, new Fields("query", "indices", "types"), new QuerySearchIndexQuery(), new Fields("tweet"))
.each(new Fields("tweet"), new FilterNull())
.each(new Fields("tweet"), new CreateJson(), new Fields("json"))
.project(new Fields("json"));
return topology.build();
}
示例12: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
public StormTopology buildTopology() {
TridentTopology topology = new TridentTopology();
SamevalGenerator dataGen = new SamevalGenerator();
StateFactory mapState = new MemoryMapState.Factory();
TridentState counterState = topology.newStream("CounterGen", dataGen)
.groupBy(new Fields(Names.TIME_STAMP_FLD))
.persistentAggregate(mapState, new Fields(Names.USER_ID_FLD),
new HLLAggregator(Names.USER_ID_FLD),
new Fields("ItemCounter"));
topology.newDRPCStream("CountItemStream", localDRPC)
.each(new Fields("args"), new Split(), new Fields("FLD"))
.each(new Fields("FLD"), new DataTypeConvert(new Integer(1)), new Fields(Names.MIN_OF_DAY_FLD))
.each(new Fields(Names.MIN_OF_DAY_FLD), new Debug())
.stateQuery(counterState, new Fields(Names.MIN_OF_DAY_FLD), new MapGet(), new Fields(Names.COUNTER_VALS_FLD))
.each(new Fields(Names.COUNTER_VALS_FLD), new FilterNull())
//.each(new Fields("CounterVals"), new HLLToStrConverter("CounterVals"), new Fields("UniqueItems"));
.each(new Fields(Names.COUNTER_VALS_FLD), new HLLToStrConverter(Names.COUNTER_VALS_FLD), new Fields("UniqueItems"))
.project(new Fields("UniqueItems"));
return topology.build();
}
示例13: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的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();
}
示例14: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc, StateFactory stateFactory) {
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();
topology.build();
TridentState wordCounts =
topology.newStream("spout1", spout)
.parallelismHint(16)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(stateFactory, new Fields("word"), new WordCount(), 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 SumWord(), new Fields("sum"))
;
return topology.build();
}
示例15: buildTopology
import storm.trident.operation.builtin.FilterNull; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
@SuppressWarnings("unchecked")
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();
}