BaseStream
An AbstractPipeline represents an initial portion of a stream
pipeline, encapsulating a stream source and zero or more intermediate
operations. The individual AbstractPipeline objects are often
referred to as stages, where each stage describes either the stream
source or an intermediate operation.
A concrete intermediate stage is generally built from an
AbstractPipeline, a shape-specific pipeline class which extends it
(e.g., IntPipeline) which is also abstract, and an operation-specific
concrete class which extends that. AbstractPipeline contains most of
the mechanics of evaluating the pipeline, and implements methods that will be
used by the operation; the shape-specific classes add helper methods for
dealing with collection of results into the appropriate shape-specific
containers.
After chaining a new intermediate operation, or executing a terminal operation, the stream is considered to be consumed, and no more intermediate or terminal operations are permitted on this stream instance.
Implementation Note
For sequential streams, and parallel streams without stateful intermediate operations, parallel streams, pipeline evaluation is done in a single pass that "jams" all the operations together. For parallel streams with stateful operations, execution is divided into segments, where each stateful operations marks the end of a segment, and each segment is evaluated separately and the result used as the input to the next segment. In all cases, the source data is not consumed until a terminal operation begins.
| Modifier and Type | Field and Description |
|---|---|
| private int | combinedFlags
The combined source and operation flags for the source and all operations up to and including the operation represented by this pipeline object. |
| private int | depth
The number of intermediate operations between this pipeline object and the stream source if sequential, or the previous stateful if parallel. |
| private boolean | linkedOrConsumed
True if this pipeline has been linked or consumed |
| private static final String | |
| private static final String | |
| private AbstractPipeline | nextStage
The next stage in the pipeline, or null if this is the last stage. |
| private boolean | parallel
True if pipeline is parallel, otherwise the pipeline is sequential; only valid for the source stage. |
| protected final AbstractPipeline | previousStage
The "upstream" pipeline, or null if this is the source stage. |
| private Runnable | |
| protected final int | sourceOrOpFlags
The operation flags for the intermediate operation represented by this pipeline object. |
| private Spliterator | sourceSpliterator
The source spliterator. |
| private final AbstractPipeline | sourceStage
Backlink to the head of the pipeline chain (self if this is the source stage). |
| private Supplier | sourceSupplier
The source supplier. |
| Access | Constructor and Description |
|---|---|
| pack-priv | AbstractPipeline(Supplier<? extends Spliterator<?>>
Supplier<Spliterator> describing the stream sourceThe source flags for the stream source, described in
sourceFlags, boolean StreamOpFlagTrue if the pipeline is parallel parallel)Constructor for the head of a stream pipeline. |
| pack-priv | AbstractPipeline(Spliterator<?>
Spliterator describing the stream sourcethe source flags for the stream source, described in
sourceFlags, boolean StreamOpFlagtrue if the pipeline is parallelConstructor for the head of a stream pipeline. |
| pack-priv | AbstractPipeline(AbstractPipeline<?, E_IN, ?>
the upstream pipeline stage previousStage, int the operation flags for the new stage, described in
opFlags)StreamOpFlagConstructor for appending an intermediate operation stage onto an existing pipeline. |
| protected | AbstractPipeline(AbstractPipeline<?, E_IN, ?>
the upstream pipeline stage of the upstream pipeline stage previousPreviousStage, AbstractPipeline<?, E_IN, ?> the upstream pipeline stage previousStage, int the operation flags for the new stage, described in
opFlags)StreamOpFlagConstructor for replacing an intermediate operation stage onto an existing pipeline. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Closes this stream, causing all close handlers for this stream pipeline to be called. |
| pack-priv final <P_IN> void | copyInto(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)
Implements abstract java. Pushes elements obtained from the |
| pack-priv final <P_IN> boolean | copyIntoWithCancel(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator)
Implements abstract java. Pushes elements obtained from the |
| pack-priv final < the type of result R> R | Returns: the resultthe terminal operation to be applied to the pipeline. terminalOp)Evaluate the pipeline with a terminal operation to produce a result. |
| pack-priv final <P_IN> Node | evaluate(Spliterator<P_IN> spliterator, boolean flatten, IntFunction<E_OUT[]> generator)
Implements abstract java. Collects all output elements resulting from applying the pipeline stages
to the source |
| pack-priv final Node | Returns: a flat array-backed Node that holds the collected output elementsthe array generator to be used to create array instances generator)Collect the elements output from the pipeline stage. |
| pack-priv abstract <P_IN> Node | Returns: a Node holding the output of the pipelinethe pipeline helper describing the pipeline stages helper, Spliterator<P_IN> the source spliterator spliterator, boolean true if the returned node should be flattened flattenTree, IntFunction<E_OUT[]> the array generator generator)Collect elements output from a pipeline into a Node that holds elements of this shape. |
| pack-priv long | Returns: the output size of this stagethe exact size reported by the previous stage previousSize)Returns the exact output size of the pipeline given the exact size reported by the previous stage. |
| pack-priv final <P_IN> long | exactOutputSizeIfKnown(Spliterator<P_IN> spliterator)
Implements abstract java. Returns the exact output size of the portion of the output resulting from
applying the pipeline stages described by this |
| pack-priv abstract boolean | Returns: true if the cancellation was requestedthe spliterator to pull elements from spliterator, Sink<E_OUT> the sink to push elements to sink)Traverse the elements of a spliterator compatible with this stream shape, pushing those elements into a sink. |
| pack-priv abstract StreamShape | |
| pack-priv final StreamShape | getSourceShape()
Implements abstract java. Gets the stream shape for the source of the pipeline segment. |
| pack-priv final int | getStreamAndOpFlags()
Implements abstract java. Gets the combined stream and operation flags for the output of the described pipeline. |
| pack-priv final int | Returns: the composition of stream flags of the stream source and all intermediate operationsReturns the composition of stream flags of the stream source and all intermediate operations. |
| protected final boolean | Returns: true if any stage in this segment is stateful,
false if not.Returns whether any of the stages of the current segment is stateful or not. |
| pack-priv final boolean | |
| public final boolean | isParallel()
Implements java. Returns whether this stream, if a terminal operation were to be executed, would execute in parallel. |
| protected final boolean | Returns: true if any stage in this pipeline is short-circuiting,
false if not.Returns whether any of the stages in the (entire) pipeline is short-circuiting or not. |
| pack-priv abstract Spliterator | lazySpliterator(Supplier<? extends Spliterator<E_OUT>>
the supplier of a spliterator supplier)Create a lazy spliterator that wraps and obtains the supplied the spliterator when a method is invoked on the lazy spliterator. |
| protected void | linkOrConsume()
Checks that the current stage has not been already linked or consumed, and then sets this stage as being linked or consumed. |
| pack-priv abstract Node. | Returns: a node builderif >=0, then a node builder will be
created that has a fixed capacity of at most sizeIfKnown elements. If
< 0, then the node builder has an unfixed capacity. A fixed
capacity node builder will throw exceptions if an element is added after
builder has reached capacity, or is built before the builder has reached
capacity. exactSizeIfKnown, IntFunction<E_OUT[]> the array generator to be used to create instances of a
T[] array. For implementations supporting primitive nodes, this parameter
may be ignored. generator)Implements abstract java. Make a node builder compatible with this stream shape. |
| public S | onClose(Runnable closeHandler)
Implements java. Returns an equivalent stream with an additional close handler. |
| pack-priv <P_IN> Node | Returns: aNode describing the result of the evaluationthe pipeline helper describing the pipeline stages helper, Spliterator<P_IN> the source spliterator, IntFunction<E_OUT[]> Spliteratorthe array generator generator)Performs a parallel evaluation of the operation using the specified
|
| pack-priv <P_IN> Spliterator | Returns: aSpliterator describing the result of the evaluationthe pipeline helper helper, Spliterator<P_IN> the source spliterator)SpliteratorReturns a |
| pack-priv abstract boolean | Returns: true if this operation is statefulReturns whether this operation is stateful or not. |
| pack-priv abstract Sink | Returns: a sink which accepts elements, perform the operation upon each element, and passes the results (if any) to the providedSink.The combined stream and operation flags up to, but not
including, this operation flags, Sink<E_OUT> sink to which elements should be sent after processing sink)Accepts a |
| public final S | parallel()
Implements java. Returns an equivalent stream that is parallel. |
| public final S | sequential()
Implements java. Returns an equivalent stream that is sequential. |
| protected Spliterator | |
| pack-priv final Spliterator | Returns: the source stage spliteratorGets the source stage spliterator if this pipeline stage is the source stage. |
| public Spliterator | spliterator()
Implements java. Returns a spliterator for the elements of this stream. |
| pack-priv abstract <P_IN> Spliterator | Returns: a wrapping spliterator compatible with this shapethe pipeline helper describing the pipeline stages ph, Supplier<Spliterator<P_IN>> the supplier of a spliterator supplier, boolean isParallel)Create a spliterator that wraps a source spliterator, compatible with
this stream shape, and operations associated with a |
| pack-priv final <P_IN, S extends Sink | wrapAndCopyInto(S sink, Spliterator<P_IN> spliterator)
Implements abstract java. Applies the pipeline stages described by this |
| pack-priv final <P_IN> Sink | wrapSink(Sink<E_OUT> sink)
Implements abstract java. Takes a |
| pack-priv final <P_IN> Spliterator | wrapSpliterator(Spliterator<P_IN> sourceSpliterator)
Implements abstract java.
|
| combinedFlags | back to summary |
|---|---|
| private int combinedFlags The combined source and operation flags for the source and all operations up to and including the operation represented by this pipeline object. Valid at the point of pipeline preparation for evaluation. | |
| depth | back to summary |
|---|---|
| private int depth The number of intermediate operations between this pipeline object and the stream source if sequential, or the previous stateful if parallel. Valid at the point of pipeline preparation for evaluation. | |
| linkedOrConsumed | back to summary |
|---|---|
| private boolean linkedOrConsumed True if this pipeline has been linked or consumed | |
| MSG_CONSUMED | back to summary |
|---|---|
| private static final String MSG_CONSUMED | |
| MSG_STREAM_LINKED | back to summary |
|---|---|
| private static final String MSG_STREAM_LINKED | |
| nextStage | back to summary |
|---|---|
| private AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> nextStage The next stage in the pipeline, or null if this is the last stage. Effectively final at the point of linking to the next pipeline.
| |
| parallel | back to summary |
|---|---|
| private boolean parallel True if pipeline is parallel, otherwise the pipeline is sequential; only valid for the source stage. | |
| previousStage | back to summary |
|---|---|
| protected final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> previousStage The "upstream" pipeline, or null if this is the source stage.
| |
| sourceCloseAction | back to summary |
|---|---|
| private Runnable sourceCloseAction | |
| sourceOrOpFlags | back to summary |
|---|---|
| protected final int sourceOrOpFlags The operation flags for the intermediate operation represented by this pipeline object. | |
| sourceSpliterator | back to summary |
|---|---|
| private Spliterator<?> sourceSpliterator The source spliterator. Only valid for the head pipeline.
Before the pipeline is consumed if non-null then | |
| sourceStage | back to summary |
|---|---|
| private final AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> sourceStage Backlink to the head of the pipeline chain (self if this is the source stage).
| |
| sourceSupplier | back to summary |
|---|---|
| private Supplier<? extends Spliterator<?>> sourceSupplier The source supplier. Only valid for the head pipeline. Before the
pipeline is consumed if non-null then | |
| AbstractPipeline | back to summary |
|---|---|
| pack-priv AbstractPipeline(Supplier<? extends Spliterator<?>> source, int sourceFlags, boolean parallel) Constructor for the head of a stream pipeline.
| |
| AbstractPipeline | back to summary |
|---|---|
| pack-priv AbstractPipeline(Spliterator<?> source, int sourceFlags, boolean parallel) Constructor for the head of a stream pipeline.
| |
| AbstractPipeline | back to summary |
|---|---|
| pack-priv AbstractPipeline(AbstractPipeline<?, E_IN, ?> previousStage, int opFlags) Constructor for appending an intermediate operation stage onto an existing pipeline. The previous stage must be unlinked and unconsumed.
| |
| AbstractPipeline | back to summary |
|---|---|
| protected AbstractPipeline(AbstractPipeline<?, E_IN, ?> previousPreviousStage, AbstractPipeline<?, E_IN, ?> previousStage, int opFlags) Constructor for replacing an intermediate operation stage onto an existing pipeline.
| |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this stream, causing all close handlers for this stream pipeline to be called.
| |
| copyInto | back to summary |
|---|---|
| pack-priv final <P_IN> void copyInto(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator) Implements abstract java. Doc from java. Pushes elements obtained from the
| |
| copyIntoWithCancel | back to summary |
|---|---|
| pack-priv final <P_IN> boolean copyIntoWithCancel(Sink<P_IN> wrappedSink, Spliterator<P_IN> spliterator) Implements abstract java. Doc from java. Pushes elements obtained from the
| |
| evaluate | back to summary |
|---|---|
| pack-priv final <R> R evaluate(TerminalOp<E_OUT, R> terminalOp) Evaluate the pipeline with a terminal operation to produce a result.
| |
| evaluate | back to summary |
|---|---|
| pack-priv final <P_IN> Node Implements abstract java. Doc from java. Collects all output elements resulting from applying the pipeline stages
to the source
| |
| evaluateToArrayNode | back to summary |
|---|---|
| pack-priv final Node Collect the elements output from the pipeline stage.
| |
| evaluateToNode | back to summary |
|---|---|
| pack-priv abstract <P_IN> Node Collect elements output from a pipeline into a Node that holds elements of this shape.
| |
| exactOutputSize | back to summary |
|---|---|
| pack-priv long exactOutputSize(long previousSize) Returns the exact output size of the pipeline given the exact size reported by the previous stage.
| |
| exactOutputSizeIfKnown | back to summary |
|---|---|
| pack-priv final <P_IN> long exactOutputSizeIfKnown(Spliterator<P_IN> spliterator) Implements abstract java. Doc from java. Returns the exact output size of the portion of the output resulting from
applying the pipeline stages described by this
| |
| forEachWithCancel | back to summary |
|---|---|
| pack-priv abstract boolean forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink) Traverse the elements of a spliterator compatible with this stream shape, pushing those elements into a sink. If the sink requests cancellation, no further elements will be pulled or pushed.
| |
| getOutputShape | back to summary |
|---|---|
| pack-priv abstract StreamShape getOutputShape() Get the output shape of the pipeline. If the pipeline is the head, then its output shape corresponds to the shape of the source. Otherwise, its output shape corresponds to the output shape of the associated operation.
| |
| getSourceShape | back to summary |
|---|---|
| pack-priv final StreamShape getSourceShape() Implements abstract java. Doc from java. Gets the stream shape for the source of the pipeline segment.
| |
| getStreamAndOpFlags | back to summary |
|---|---|
| pack-priv final int getStreamAndOpFlags() Implements abstract java. Doc from java. Gets the combined stream and operation flags for the output of the described pipeline. This will incorporate stream flags from the stream source, all the intermediate operations and the terminal operation.
| |
| getStreamFlags | back to summary |
|---|---|
| pack-priv final int getStreamFlags() Returns the composition of stream flags of the stream source and all intermediate operations.
| |
| hasAnyStateful | back to summary |
|---|---|
| protected final boolean hasAnyStateful() Returns whether any of the stages of the current segment is stateful or not.
| |
| isOrdered | back to summary |
|---|---|
| pack-priv final boolean isOrdered() | |
| isParallel | back to summary |
|---|---|
| public final boolean isParallel() Implements java. Doc from java. Returns whether this stream, if a terminal operation were to be executed, would execute in parallel. Calling this method after invoking an terminal stream operation method may yield unpredictable results.
| |
| isShortCircuitingPipeline | back to summary |
|---|---|
| protected final boolean isShortCircuitingPipeline() Returns whether any of the stages in the (entire) pipeline is short-circuiting or not.
| |
| lazySpliterator | back to summary |
|---|---|
| pack-priv abstract Spliterator Create a lazy spliterator that wraps and obtains the supplied the spliterator when a method is invoked on the lazy spliterator.
| |
| linkOrConsume | back to summary |
|---|---|
| protected void linkOrConsume() Checks that the current stage has not been already linked or consumed, and then sets this stage as being linked or consumed. | |
| makeNodeBuilder | back to summary |
|---|---|
| pack-priv abstract Node. Implements abstract java. Make a node builder compatible with this stream shape.
| |
| onClose | back to summary |
|---|---|
| public S onClose(Runnable closeHandler) Implements java. Doc from java. Returns an equivalent stream with an additional close handler. Close
handlers are run when the This is an intermediate operation.
| |
| opEvaluateParallel | back to summary |
|---|---|
| pack-priv <P_IN> Node Performs a parallel evaluation of the operation using the specified
Implementation Specification The default implementation always throw
| |
| opEvaluateParallelLazy | back to summary |
|---|---|
| pack-priv <P_IN> Spliterator Returns a Implementation Specification The default implementation behaves as if:
and is suitable for implementations that cannot do better than a full
synchronous evaluation.
| |
| opIsStateful | back to summary |
|---|---|
| pack-priv abstract boolean opIsStateful() Returns whether this operation is stateful or not. If it is stateful,
then the method
| |
| opWrapSink | back to summary |
|---|---|
| pack-priv abstract Sink Accepts a API Note The implementation may use the
| |
| parallel | back to summary |
|---|---|
| public final S parallel() Implements java. Doc from java. Returns an equivalent stream that is parallel. May return itself, either because the stream was already parallel, or because the underlying stream state was modified to be parallel. This is an intermediate operation.
| |
| sequential | back to summary |
|---|---|
| public final S sequential() Implements java. Doc from java. Returns an equivalent stream that is sequential. May return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential. This is an intermediate operation.
| |
| sourceSpliterator | back to summary |
|---|---|
| protected Spliterator Get the source spliterator for this pipeline stage. For a sequential or stateless parallel pipeline, this is the source spliterator. For a stateful parallel pipeline, this is a spliterator describing the results of all computations up to and including the most recent stateful operation.
| |
| sourceStageSpliterator | back to summary |
|---|---|
| pack-priv final Spliterator Gets the source stage spliterator if this pipeline stage is the source stage. The pipeline is consumed after this method is called and returns successfully.
| |
| spliterator | back to summary |
|---|---|
| public Spliterator Implements java. Doc from java. Returns a spliterator for the elements of this stream. This is a terminal operation.
| |
| wrap | back to summary |
|---|---|
| pack-priv abstract <P_IN> Spliterator Create a spliterator that wraps a source spliterator, compatible with
this stream shape, and operations associated with a
| |
| wrapAndCopyInto | back to summary |
|---|---|
| pack-priv final <P_IN, S extends Sink Implements abstract java. Doc from java. Applies the pipeline stages described by this
| |
| wrapSink | back to summary |
|---|---|
| pack-priv final <P_IN> Sink Implements abstract java. Doc from java. Takes a
| |
| wrapSpliterator | back to summary |
|---|---|
| pack-priv final <P_IN> Spliterator Implements abstract java.
| |