|
Java example source code file (PipelineHelper.java)
The PipelineHelper.java Java example source code/* * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.util.stream; import java.util.Spliterator; import java.util.function.IntFunction; /** * Helper class for executing <a href="package-summary.html#StreamOps"> * stream pipelines</a>, capturing all of the information about a stream * pipeline (output shape, intermediate operations, stream flags, parallelism, * etc) in one place. * * <p> * A {@code PipelineHelper} describes the initial segment of a stream pipeline, * including its source, intermediate operations, and may additionally * incorporate information about the terminal (or stateful) operation which * follows the last intermediate operation described by this * {@code PipelineHelper}. The {@code PipelineHelper} is passed to the * {@link TerminalOp#evaluateParallel(PipelineHelper, java.util.Spliterator)}, * {@link TerminalOp#evaluateSequential(PipelineHelper, java.util.Spliterator)}, * and {@link AbstractPipeline#opEvaluateParallel(PipelineHelper, java.util.Spliterator, * java.util.function.IntFunction)}, methods, which can use the * {@code PipelineHelper} to access information about the pipeline such as * head shape, stream flags, and size, and use the helper methods * such as {@link #wrapAndCopyInto(Sink, Spliterator)}, * {@link #copyInto(Sink, Spliterator)}, and {@link #wrapSink(Sink)} to execute * pipeline operations. * * @param <P_OUT> type of output elements from the pipeline * @since 1.8 */ abstract class PipelineHelper<P_OUT> { /** * Gets the stream shape for the source of the pipeline segment. * * @return the stream shape for the source of the pipeline segment. */ abstract StreamShape getSourceShape(); /** * 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. * * @return the combined stream and operation flags * @see StreamOpFlag */ abstract int getStreamAndOpFlags(); /** * Returns the exact output size of the portion of the output resulting from * applying the pipeline stages described by this {@code PipelineHelper} to * the the portion of the input described by the provided * {@code Spliterator}, if known. If not known or known infinite, will * return {@code -1}. * * @apiNote * The exact output size is known if the {@code Spliterator} has the * {@code SIZED} characteristic, and the operation flags * {@link StreamOpFlag#SIZED} is known on the combined stream and operation * flags. * * @param spliterator the spliterator describing the relevant portion of the * source data * @return the exact size if known, or -1 if infinite or unknown */ abstract<P_IN> long exactOutputSizeIfKnown(Spliterator Other Java examples (source code examples)Here is a short list of links related to this Java PipelineHelper.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.