Tabnine Logo
GroupedStream
Code IndexAdd Tabnine to your IDE (free)

How to use
GroupedStream
in
storm.trident.fluent

Best Java code snippets using storm.trident.fluent.GroupedStream (Showing top 20 results out of 315)

origin: alibaba/jstorm

public TridentState persistentAggregate(StateSpec spec, ReducerAggregator agg, Fields functionFields) {
  return persistentAggregate(spec, null, agg, functionFields);
}
origin: alibaba/jstorm

public Stream aggregate(ReducerAggregator agg, Fields functionFields) {
  return aggregate(null, agg, functionFields);
}
origin: alibaba/jstorm

public Stream stateQuery(TridentState state, QueryFunction function, Fields functionFields) {
  return stateQuery(state, null, function, functionFields);
}
origin: alibaba/jstorm

public Stream multiReduce(List<Fields> inputFields, List<GroupedStream> groupedStreams, GroupedMultiReducer function, Fields outputFields) {
  List<Fields> fullInputFields = new ArrayList<>();
  List<Stream> streams = new ArrayList<>();
  List<Fields> fullGroupFields = new ArrayList<>();
  for(int i=0; i<groupedStreams.size(); i++) {
    GroupedStream gs = groupedStreams.get(i);
    Fields groupFields = gs.getGroupFields();
    fullGroupFields.add(groupFields);
    streams.add(gs.toStream().partitionBy(groupFields));
    fullInputFields.add(TridentUtils.fieldsUnion(groupFields, inputFields.get(i)));
    
  }
  return multiReduce(fullInputFields, streams, new GroupedMultiReducerExecutor(function, fullGroupFields, inputFields), outputFields);
}

origin: alibaba/jstorm

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();
}

origin: eshioji/trident-tutorial

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();
}
origin: eshioji/trident-tutorial

private static StormTopology advancedPrimitives(FeederBatchSpout spout) throws IOException {
  TridentTopology topology = new TridentTopology();
  // What if we want more than one aggregation? For that, we can use "chained" aggregations.
  // Note how we calculate count and sum.
  // The aggregated values can then be processed further, in this case into mean
  topology
      .newStream("aggregation", spout)
      .groupBy(new Fields("city"))
      .chainedAgg()
      .aggregate(new Count(), new Fields("count"))
      .aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
      .chainEnd()
      .each(new Fields("age_sum", "count"), new DivideAsDouble(), new Fields("mean_age"))
      .each(new Fields("city", "mean_age"), new Print())
  ;
  // What if we want to persist results of an aggregation, but want to further process these
  // results? You can use "newValuesStream" for that
  topology
      .newStream("further",spout)
      .groupBy(new Fields("city"))
      .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
      .newValuesStream()
      .each(new Fields("city", "count"), new Print());
  return topology.build();
}
origin: lmco/streamflow

  aggregatableStream = groupedStream.each(
      new Fields(inputFields), function, new Fields(outputFields));
  setActiveStream(ActiveStream.AGGREGATABLE_STREAM);
  stream = groupedStream.aggregate(
      combinerAggregator, new Fields(outputFields));
  setActiveStream(ActiveStream.STREAM);
} else {
  stream = groupedStream.aggregate(
      new Fields(inputFields), combinerAggregator, new Fields(outputFields));
  setActiveStream(ActiveStream.STREAM);
  stream = groupedStream.aggregate(
      reducerAggregator, new Fields(outputFields));
  setActiveStream(ActiveStream.STREAM);
} else {
  stream = groupedStream.aggregate(
      new Fields(inputFields), reducerAggregator, new Fields(outputFields));
  setActiveStream(ActiveStream.STREAM);
  stream = groupedStream.aggregate(
      aggregator, new Fields(outputFields));
  setActiveStream(ActiveStream.STREAM);
} else {
  if (partitionAggregate) {
    aggregatableStream = groupedStream.partitionAggregate(
        new Fields(inputFields), aggregator, new Fields(outputFields));
    setActiveStream(ActiveStream.AGGREGATABLE_STREAM);
  } else {
origin: alibaba/jstorm

@Override
public IAggregatableStream each(Fields inputFields, Function function, Fields functionFields) {
  Stream s = _stream.each(inputFields, function, functionFields);
  return new GroupedStream(s, _groupFields);
}
origin: alibaba/jstorm

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();
}

origin: eshioji/trident-tutorial

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();
}
origin: eshioji/trident-tutorial

    .newStream("spout", spout)
    .groupBy(new Fields("actor","location"))
    .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"));
.each(new Fields("actor","location","age"), new Print())
.groupBy(new Fields("location"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("sum"))
origin: alibaba/jstorm

/**
 * ## Grouping Operation
 *
 * @param fields
 * @return
 */
public GroupedStream groupBy(Fields fields) {
  projectionValidation(fields);
  return new GroupedStream(this, fields);
}
origin: com.n3twork.storm/storm-core

public Stream multiReduce(List<Fields> inputFields, List<GroupedStream> groupedStreams, GroupedMultiReducer function, Fields outputFields) {
  List<Fields> fullInputFields = new ArrayList<Fields>();
  List<Stream> streams = new ArrayList<Stream>();
  List<Fields> fullGroupFields = new ArrayList<Fields>();
  for(int i=0; i<groupedStreams.size(); i++) {
    GroupedStream gs = groupedStreams.get(i);
    Fields groupFields = gs.getGroupFields();
    fullGroupFields.add(groupFields);
    streams.add(gs.toStream().partitionBy(groupFields));
    fullInputFields.add(TridentUtils.fieldsUnion(groupFields, inputFields.get(i)));
    
  }
  return multiReduce(fullInputFields, streams, new GroupedMultiReducerExecutor(function, fullGroupFields, inputFields), outputFields);
}

origin: alibaba/jstorm

public TridentState persistentAggregate(StateSpec spec, CombinerAggregator agg, Fields functionFields) {
  return persistentAggregate(spec, null, agg, functionFields);
}
origin: wurstmeister/storm-kafka-0.8-plus-test

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();
}
origin: eshioji/trident-tutorial

.newStream("aggregation", spout)
.groupBy(new Fields("actor"))
.aggregate(new Count(),new Fields("count"))
.each(new Fields("actor", "count"),new Print())
.newStream("aggregation", spout)
.groupBy(new Fields("actor"))
.persistentAggregate(new MemoryMapState.Factory(),new Count(),new Fields("count"))
origin: alibaba/jstorm

public Stream aggregate(Aggregator agg, Fields functionFields) {
  return aggregate(null, agg, functionFields);
}
origin: com.alibaba.jstorm/jstorm-core

public Stream stateQuery(TridentState state, QueryFunction function, Fields functionFields) {
  return stateQuery(state, null, function, functionFields);
}
origin: alibaba/jstorm

@Override
public IAggregatableStream aggPartition(GroupedStream s) {
  return new GroupedStream(s._stream.partitionBy(_groupFields), _groupFields);
}
storm.trident.fluentGroupedStream

Most used methods

  • persistentAggregate
  • aggregate
  • stateQuery
  • <init>
  • chainedAgg
  • getGroupFields
  • toStream
  • aggPartition
  • each
  • partitionAggregate

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSupportFragmentManager (FragmentActivity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now