A sink that collects first n
elements into a chunk.
A sink that collects first n
elements into a chunk. Note that the chunk
is preallocated and must fit in memory.
A sink that collects all of its inputs into a map.
A sink that collects all of its inputs into a map. The keys are extracted
from inputs using the keying function key
; if multiple inputs use the
same key, they are merged using the f
function.
A sink that collects first n
keys into a map.
A sink that collects first n
keys into a map. The keys are calculated
from inputs using the keying function key
; if multiple inputs use the the
same key, they are merged using the f
function.
A sink that collects all of its inputs into a set.
A sink that collects first n
distinct inputs into a set.
Accumulates incoming elements into a chunk until predicate p
is
satisfied.
Accumulates incoming elements into a chunk until effectful predicate p
is
satisfied.
Accumulates incoming elements into a chunk as long as they verify predicate
p
.
Accumulates incoming elements into a chunk as long as they verify effectful
predicate p
.
A sink that counts the number of elements fed to it.
Creates a sink halting with the specified Throwable
.
Creates a sink halting with the specified message, wrapped in a
RuntimeException
.
A sink that ignores its inputs.
Drops incoming elements until the predicate p
is satisfied.
Drops incoming elements until the effectful predicate p
is satisfied.
Drops incoming elements as long as the predicate p
is satisfied.
Drops incoming elements as long as the effectful predicate p
is
satisfied.
Accesses the whole environment of the sink.
Accesses the environment of the sink.
Accesses the environment of the sink in the context of a sink.
Accesses the environment of the sink in the context of an effect.
A sink that always fails with the specified error.
Creates a sink halting with a specified cause.
A sink that folds its inputs with the provided function, termination predicate and initial state.
A sink that folds its input chunks with the provided function, termination predicate and initial state.
A sink that folds its input chunks with the provided function, termination
predicate and initial state. contFn
condition is checked only for the
initial value and at the end of processing of each chunk. f
and contFn
must preserve chunking-invariance.
A sink that effectfully folds its input chunks with the provided function, termination predicate and initial state.
A sink that effectfully folds its input chunks with the provided function,
termination predicate and initial state. contFn
condition is checked only
for the initial value and at the end of processing of each chunk. f
and
contFn
must preserve chunking-invariance.
A sink that folds its inputs with the provided function and initial state.
A sink that folds its input chunks with the provided function and initial state.
A sink that folds its input chunks with the provided function and initial
state. f
must preserve chunking-invariance.
A sink that effectfully folds its input chunks with the provided function and initial state.
A sink that effectfully folds its input chunks with the provided function
and initial state. f
must preserve chunking-invariance.
A sink that effectfully folds its inputs with the provided function and initial state.
Creates a sink that folds elements of type In
into a structure of type
S
until max
elements have been folded.
Creates a sink that folds elements of type In
into a structure of type
S
until max
elements have been folded.
Like foldWeighted, but with a constant cost function of 1.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
until max
elements have been folded.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
until max
elements have been folded.
Like foldWeightedZIO, but with a constant cost function of 1.
Creates a sink that folds elements of type In
into a structure of type
S
, until max
worth of elements (determined by the costFn
) have been
folded.
Creates a sink that folds elements of type In
into a structure of type
S
, until max
worth of elements (determined by the costFn
) have been
folded.
Elements that have an individual cost larger than max
will force the
sink to cross the max
cost. See foldWeightedDecompose for a variant
that can handle these cases.
Creates a sink that folds elements of type In
into a structure of type
S
, until max
worth of elements (determined by the costFn
) have been
folded.
Creates a sink that folds elements of type In
into a structure of type
S
, until max
worth of elements (determined by the costFn
) have been
folded.
The decompose
function will be used for decomposing elements that cause
an S
aggregate to cross max
into smaller elements. For example:
Stream(1, 5, 1) .transduce( ZSink .foldWeightedDecompose(List[Int]())((i: Int) => i.toLong, 4, (i: Int) => Chunk(i - 1, 1)) { (acc, el) => el :: acc } .map(_.reverse) ) .runCollect
The stream would emit the elements List(1), List(4), List(1, 1)
.
Be vigilant with this function, it has to generate "simpler" values or the
fold may never end. A value is considered indivisible if decompose
yields
the empty chunk or a single-valued chunk. In these cases, there is no other
choice than to yield a value that will cross the threshold.
The foldWeightedDecomposeZIO allows the decompose function to return a
ZIO
value, and consequently it allows the sink to fail.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
The decompose
function will be used for decomposing elements that cause
an S
aggregate to cross max
into smaller elements. Be vigilant with
this function, it has to generate "simpler" values or the fold may never
end. A value is considered indivisible if decompose
yields the empty
chunk or a single-valued chunk. In these cases, there is no other choice
than to yield a value that will cross the threshold.
See foldWeightedDecompose for an example.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Creates a sink that effectfully folds elements of type In
into a
structure of type S
, until max
worth of elements (determined by the
costFn
) have been folded.
Elements that have an individual cost larger than max
will force the
sink to cross the max
cost. See foldWeightedDecomposeZIO for a
variant that can handle these cases.
A sink that effectfully folds its inputs with the provided function, termination predicate and initial state.
A sink that executes the provided effectful function for every element fed to it.
A sink that executes the provided effectful function for every chunk fed to it.
A sink that executes the provided effectful function for every chunk fed to
it until f
evaluates to false
.
A sink that executes the provided effectful function for every element fed
to it until f
evaluates to false
.
Creates a sink from a zio.stream.ZChannel
Create a sink which publishes each element to the specified hub.
Create a sink which publishes each element to the specified hub.
Create a sink which publishes each element to the specified hub. The hub will be shutdown once the stream is closed.
Creates a sink from a chunk processing function.
Create a sink which enqueues each element into the specified queue.
Create a sink which enqueues each element into the specified queue.
Create a sink which enqueues each element into the specified queue. The queue will be shutdown once the stream is closed.
Creates a single-value sink produced from an effect
Creates a sink containing the first value.
Creates a sink containing the last value.
Creates a sink that does not consume any input but provides the given chunk as its leftovers
Logs the specified message at the current log level.
Annotates each log in streams composed after this with the specified log annotation.
Annotates each log in streams composed after this with the specified log annotation.
Annotates each log in streams composed after this with the specified log annotation.
Retrieves the log annotations associated with the current scope.
Logs the specified message at the debug log level.
Logs the specified message at the error log level.
Logs the specified cause as an error.
Logs the specified message at the fatal log level.
Logs the specified message at the informational log level.
Sets the log level for streams composed after this.
Adjusts the label for the logging span for streams composed after this.
Logs the specified message at the trace log level.
Logs the specified message at the warning log level.
Accesses the specified service in the environment of the effect.
Accesses the service corresponding to the specified key in the environment.
Accesses the specified service in the environment of the sink.
Accesses the specified service in the environment of the sink in the context of a sink.
Accesses the specified service in the environment of the sink in the context of an effect.
A sink that immediately ends with the specified value.
A sink that sums incoming numeric values.
Returns a lazily constructed sink that may require effects for its creation.
A sink that takes the specified number of values.
Creates a sink produced from an effect.
Creates a sink produced from a scoped effect.