+str #16610 applied the changes suggested by @drewhk
This commit is contained in:
parent
d690067fc9
commit
b420d6a472
9 changed files with 245 additions and 137 deletions
|
|
@ -641,6 +641,8 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* see also [[SubSource.batch]] [[SubSource.batchWeighted]]
|
||||
*
|
||||
* @param seed Provides the first state for a conflated value using the first unconsumed element as a start
|
||||
* @param aggregate Takes the currently aggregated value and the current pending element to produce a new aggregate
|
||||
*
|
||||
|
|
@ -649,8 +651,8 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
new SubSource(delegate.conflate(seed.apply)(aggregate.apply))
|
||||
|
||||
/**
|
||||
* Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into chunks
|
||||
* until the subscriber is ready to accept them. For example an aggregate step might store received elements in
|
||||
* Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into batches
|
||||
* until the subscriber is ready to accept them. For example a batch step might store received elements in
|
||||
* an array up to the allowed max limit if the upstream publisher is faster.
|
||||
*
|
||||
* This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not
|
||||
|
|
@ -658,47 +660,51 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
*
|
||||
* '''Emits when''' downstream stops backpressuring and there is an aggregated element available
|
||||
*
|
||||
* '''Backpressures when''' there are `max` aggregated elements and 1 pending element and downstream backpressures
|
||||
* '''Backpressures when''' there are `max` batched elements and 1 pending element and downstream backpressures
|
||||
*
|
||||
* '''Completes when''' upstream completes and there is no aggregated/pending element waiting
|
||||
* '''Completes when''' upstream completes and there is no batched/pending element waiting
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* @param max maximum number of elements to aggregate before backpressuring upstream (must be positive non-zero)
|
||||
* @param seed Provides the first state for an aggregated value using the first unconsumed element as a start
|
||||
* @param aggregate Takes the currently aggregated value and the current pending element to produce a new aggregate
|
||||
* See also [[SubSource.conflate]], [[SubSource.batchWeighted]]
|
||||
*
|
||||
* @param max maximum number of elements to batch before backpressuring upstream (must be positive non-zero)
|
||||
* @param seed Provides the first state for a batched value using the first unconsumed element as a start
|
||||
* @param aggregate Takes the currently batched value and the current pending element to produce a new aggregate
|
||||
*/
|
||||
def aggregate[S](max: Long, seed: function.Function[Out, S])(aggregate: function.Function2[S, Out, S]): SubSource[S, Mat] =
|
||||
new SubSource(delegate.aggregate(max, seed.apply)(aggregate.apply))
|
||||
def batch[S](max: Long, seed: function.Function[Out, S])(aggregate: function.Function2[S, Out, S]): SubSource[S, Mat] =
|
||||
new SubSource(delegate.batch(max, seed.apply)(aggregate.apply))
|
||||
|
||||
/**
|
||||
* Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into chunks
|
||||
* until the subscriber is ready to accept them. For example an aggregate step might concatenate `ByteString`
|
||||
* Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into batches
|
||||
* until the subscriber is ready to accept them. For example a batch step might concatenate `ByteString`
|
||||
* elements up to the allowed max limit if the upstream publisher is faster.
|
||||
*
|
||||
* This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not
|
||||
* duplicate elements.
|
||||
*
|
||||
* Aggregation will apply for all elements, even if a single element cost is greater than the total allowed limit.
|
||||
* In this case, previous aggregated elements will be emitted, then the "heavy" element will be emitted (after
|
||||
* being applied with the `seed` function) without aggregating further elements to it, and then the rest of the
|
||||
* incoming elemetns is aggregated.
|
||||
* Batching will apply for all elements, even if a single element cost is greater than the total allowed limit.
|
||||
* In this case, previous batched elements will be emitted, then the "heavy" element will be emitted (after
|
||||
* being applied with the `seed` function) without batching further elements with it, and then the rest of the
|
||||
* incoming elements are batched.
|
||||
*
|
||||
* '''Emits when''' downstream stops backpressuring and there is an aggregated element available
|
||||
* '''Emits when''' downstream stops backpressuring and there is a batched element available
|
||||
*
|
||||
* '''Backpressures when''' there are `max` aggregated elements and 1 pending element and downstream backpressures
|
||||
* '''Backpressures when''' there are `max` weighted batched elements + 1 pending element and downstream backpressures
|
||||
*
|
||||
* '''Completes when''' upstream completes and there is no aggregated/pending element waiting
|
||||
* '''Completes when''' upstream completes and there is no batched/pending element waiting
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* @param max maximum number of elements to aggregate before backpressuring upstream (must be positive non-zero)
|
||||
* See also [[SubSource.conflate]], [[SubSource.batch]]
|
||||
*
|
||||
* @param max maximum weight of elements to batch before backpressuring upstream (must be positive non-zero)
|
||||
* @param costFn a function to compute a single element weight
|
||||
* @param seed Provides the first state for an aggregated value using the first unconsumed element as a start
|
||||
* @param aggregate Takes the currently aggregated value and the current pending element to produce a new aggregate
|
||||
* @param seed Provides the first state for a batched value using the first unconsumed element as a start
|
||||
* @param aggregate Takes the currently batched value and the current pending element to produce a new batch
|
||||
*/
|
||||
def aggregateWeighted[S](max: Long, costFn: function.Function[Out, Long], seed: function.Function[Out, S])(aggregate: function.Function2[S, Out, S]): SubSource[S, Mat] =
|
||||
new SubSource(delegate.aggregateWeighted(max, costFn.apply, seed.apply)(aggregate.apply))
|
||||
def batchWeighted[S](max: Long, costFn: function.Function[Out, Long], seed: function.Function[Out, S])(aggregate: function.Function2[S, Out, S]): SubSource[S, Mat] =
|
||||
new SubSource(delegate.batchWeighted(max, costFn.apply, seed.apply)(aggregate.apply))
|
||||
|
||||
/**
|
||||
* Allows a faster downstream to progress independently of a slower publisher by extrapolating elements from an older
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue