Class Stream<T>
- Type Parameters:
- T- the type of the value
- Direct Known Subclasses:
- PairStream
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescription<A,R> Stream<R> aggregate(CombinerAggregator<? super T, A, ? extends R> aggregator) Aggregates the values in this stream using the aggregator.<R> Stream<R>aggregate(R initialValue, BiFunction<? super R, ? super T, ? extends R> accumulator, BiFunction<? super R, ? super R, ? extends R> combiner) Aggregates the values in this stream using the given initial value, accumulator and combiner.Returns an array of streams by splitting the given stream into multiple branches based on the given predicates.count()Counts the number of values in this stream.Returns a stream consisting of the elements of this stream that matches the given filter.<R> Stream<R>flatMap(FlatMapFunction<? super T, ? extends R> function) Returns a stream consisting of the results of replacing each value of this stream with the contents produced by applying the provided mapping function to each value.<K,V> PairStream<K, V> flatMapToPair(PairFlatMapFunction<? super T, ? extends K, ? extends V> function) Returns a stream consisting of the results of replacing each value of this stream with the key-value pairs produced by applying the provided mapping function to each value.voidPerforms an action for each element of this stream.<R> Stream<R>Returns a stream consisting of the result of applying the given mapping function to the values of this stream.<K,V> PairStream<K, V> mapToPair(PairFunction<? super T, ? extends K, ? extends V> function) Returns a stream of key-value pairs by applying aPairFunctionon each value of this stream.partitionBy(Fields fields, int parallelism) Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as they are consumed from the resulting stream.voidprint()Print the values in this stream.Performs a reduction on the elements of this stream, by repeatedly applying the reducer.repartition(int parallelism) Returns a new stream with the given value of parallelism.<V> PairStream<T,V> stateQuery(StreamState<T, V> streamState) Queries the given stream state with the values in this stream as the keys.voidto(IBasicBolt bolt) Sends the elements of this stream to a bolt.voidto(IBasicBolt bolt, int parallelism) Sends the elements of this stream to a bolt.voidSends the elements of this stream to a bolt.voidSends the elements of this stream to a bolt.Returns a new stream consisting of the elements that fall within the window as specified by the window parameter.
- 
Field Details- 
KEY
- 
VALUE
- 
KEY_VALUE
- 
streamBuilder
- 
nodeprotected final org.apache.storm.streams.Node node
- 
stream
 
- 
- 
Method Details- 
filterReturns a stream consisting of the elements of this stream that matches the given filter.- Parameters:
- predicate- the predicate to apply to each element to determine if it should be included
- Returns:
- the new stream
 
- 
mapReturns a stream consisting of the result of applying the given mapping function to the values of this stream.- Parameters:
- function- a mapping function to be applied to each value in this stream.
- Returns:
- the new stream
 
- 
mapToPairReturns a stream of key-value pairs by applying aPairFunctionon each value of this stream.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- function- the mapping function to be applied to each value in this stream
- Returns:
- the new stream of key-value pairs
 
- 
flatMapReturns a stream consisting of the results of replacing each value of this stream with the contents produced by applying the provided mapping function to each value. This has the effect of applying a one-to-many transformation to the values of the stream, and then flattening the resulting elements into a new stream.- Parameters:
- function- a mapping function to be applied to each value in this stream which produces new values.
- Returns:
- the new stream
 
- 
flatMapToPairpublic <K,V> PairStream<K,V> flatMapToPair(PairFlatMapFunction<? super T, ? extends K, ? extends V> function) Returns a stream consisting of the results of replacing each value of this stream with the key-value pairs produced by applying the provided mapping function to each value.- Type Parameters:
- K- the key type
- V- the value type
- Parameters:
- function- the mapping function to be applied to each value in this stream which produces new key-value pairs.
- Returns:
- the new stream of key-value pairs
- See Also:
 
- 
windowReturns a new stream consisting of the elements that fall within the window as specified by the window parameter. TheWindowspecification could be used to specify sliding or tumbling windows based on time duration or event count. For example,// time duration based sliding window stream.window(SlidingWindows.of(Duration.minutes(10), Duration.minutes(1)); // count based sliding window stream.window(SlidingWindows.of(Count.(10), Count.of(2))); // time duration based tumbling window stream.window(TumblingWindows.of(Duration.seconds(10)); - Parameters:
- window- the window configuration
- Returns:
- the new stream
- See Also:
 
- 
forEachPerforms an action for each element of this stream.- Parameters:
- action- an action to perform on the elements
 
- 
peekReturns a stream consisting of the elements of this stream, additionally performing the provided action on each element as they are consumed from the resulting stream.- Parameters:
- action- the action to perform on the element as they are consumed from the stream
- Returns:
- the new stream
 
- 
aggregateAggregates the values in this stream using the aggregator. This does a global aggregation of values across all partitions.If the stream is windowed, the aggregate result is emitted after each window activation and represents the aggregate of elements that fall within that window. If the stream is not windowed, the aggregate result is emitted as each new element in the stream is processed. - Type Parameters:
- A- the accumulator type
- R- the result type
- Parameters:
- aggregator- the aggregator
- Returns:
- the new stream
 
- 
aggregatepublic <R> Stream<R> aggregate(R initialValue, BiFunction<? super R, ? super T, ? extends R> accumulator, BiFunction<? super R, ? super R, ? extends R> combiner) Aggregates the values in this stream using the given initial value, accumulator and combiner. This does a global aggregation of values across all partitions.If the stream is windowed, the aggregate result is emitted after each window activation and represents the aggregate of elements that fall within that window. If the stream is not windowed, the aggregate result is emitted as each new element in the stream is processed. - Type Parameters:
- R- the result type
- Parameters:
- initialValue- the initial value of the result
- accumulator- the accumulator
- combiner- the combiner
- Returns:
- the new stream
 
- 
countCounts the number of values in this stream. This does a global count of values across all partitions.If the stream is windowed, the counts are emitted after each window activation and represents the count of elements that fall within that window. If the stream is not windowed, the count is emitted as each new element in the stream is processed. - Returns:
- the new stream
 
- 
reducePerforms a reduction on the elements of this stream, by repeatedly applying the reducer. This does a global reduction of values across all partitions.If the stream is windowed, the result is emitted after each window activation and represents the reduction of elements that fall within that window. If the stream is not windowed, the result is emitted as each new element in the stream is processed. - Parameters:
- reducer- the reducer
- Returns:
- the new stream
 
- 
repartitionReturns a new stream with the given value of parallelism. Further operations on this stream would execute at this level of parallelism.- Parameters:
- parallelism- the parallelism value
- Returns:
- the new stream
 
- 
branchReturns an array of streams by splitting the given stream into multiple branches based on the given predicates. The predicates are applied in the given order to the values of this stream and the result is forwarded to the corresponding (index based) result stream based on the (index of) predicate that matches.Note: If none of the predicates match a value, that value is dropped. - Parameters:
- predicates- the predicates
- Returns:
- an array of result streams (branches) corresponding to the given predicates
 
- 
printpublic void print()Print the values in this stream.
- 
toSends the elements of this stream to a bolt. This could be used to plug in existing bolts as sinks in the stream, for e.g. aRedisStoreBolt. The bolt would have a parallelism of 1.Note: This would provide guarantees only based on what the bolt provides. - Parameters:
- bolt- the bolt
 
- 
toSends the elements of this stream to a bolt. This could be used to plug in existing bolts as sinks in the stream, for e.g. aRedisStoreBolt.Note: This would provide guarantees only based on what the bolt provides. - Parameters:
- bolt- the bolt
- parallelism- the parallelism of the bolt
 
- 
toSends the elements of this stream to a bolt. This could be used to plug in existing bolts as sinks in the stream, for e.g. aRedisStoreBolt. The bolt would have a parallelism of 1.Note: This would provide guarantees only based on what the bolt provides. - Parameters:
- bolt- the bolt
 
- 
toSends the elements of this stream to a bolt. This could be used to plug in existing bolts as sinks in the stream, for e.g. aRedisStoreBolt.Note: This would provide guarantees only based on what the bolt provides. - Parameters:
- bolt- the bolt
- parallelism- the parallelism of the bolt
 
- 
stateQueryQueries the given stream state with the values in this stream as the keys.- Type Parameters:
- V- the value type
- Parameters:
- streamState- the stream state
- Returns:
- the result stream
 
- 
partitionBy
 
-