Java Code Examples for java.util.stream.PipelineHelper

Following code examples demonstrate how to use java.util.stream.PipelineHelperfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use java.util.stream.PipelineHelperand various code implementation of this class.

            OfLong(Spliterator<P_IN> spliterator, PipelineHelper<Long> helper, long[] array) {
                super(spliterator, helper, array.length);
                this.array = array;
            } 


    
    public static <P_IN, P_OUT> java.util.stream.Node<P_OUT> collect(PipelineHelper<P_OUT> helper,
                                                                     Spliterator<P_IN> spliterator,
                                                                     boolean flattenTree,
                                                                     IntFunction<P_OUT[]> generator) {
        long size = helper.exactOutputSizeIfKnown(spliterator);
        if (size >= 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
            if (size >= MAX_ARRAY_SIZE)
                throw new IllegalArgumentException(BAD_SIZE);
            P_OUT[] array = generator.apply((int) size);
            new SizedCollectorTask.OfRef<>(spliterator, helper, array).invoke();
            return node(array);
        } else {
            java.util.stream.Node<P_OUT> node = new CollectorTask.OfRef<>(helper, generator, spliterator).invoke();
            return flattenTree ? flatten(node, generator) : node;
        }
    } 

            OfRef(Spliterator<P_IN> spliterator, PipelineHelper<P_OUT> helper, P_OUT[] array) {
                super(spliterator, helper, array.length);
                this.array = array;
            } 

            OfDouble(Spliterator<P_IN> spliterator, PipelineHelper<Double> helper, double[] array) {
                super(spliterator, helper, array.length);
                this.array = array;
            } 

    
    public static <P_IN> java.util.stream.Node.OfInt collectInt(PipelineHelper<Integer> helper,
                                                                Spliterator<P_IN> spliterator,
                                                                boolean flattenTree) {
        long size = helper.exactOutputSizeIfKnown(spliterator);
        if (size >= 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
            if (size >= MAX_ARRAY_SIZE)
                throw new IllegalArgumentException(BAD_SIZE);
            int[] array = new int[(int) size];
            new SizedCollectorTask.OfInt<>(spliterator, helper, array).invoke();
            return node(array);
        }
        else {
            java.util.stream.Node.OfInt node = new CollectorTask.OfInt<>(helper, spliterator).invoke();
            return flattenTree ? flattenInt(node) : node;
        }
    } 

    
    public static <P_IN> java.util.stream.Node.OfDouble collectDouble(PipelineHelper<Double> helper,
                                                                      Spliterator<P_IN> spliterator,
                                                                      boolean flattenTree) {
        long size = helper.exactOutputSizeIfKnown(spliterator);
        if (size >= 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
            if (size >= MAX_ARRAY_SIZE)
                throw new IllegalArgumentException(BAD_SIZE);
            double[] array = new double[(int) size];
            new SizedCollectorTask.OfDouble<>(spliterator, helper, array).invoke();
            return node(array);
        }
        else {
            java.util.stream.Node.OfDouble node = new CollectorTask.OfDouble<>(helper, spliterator).invoke();
            return flattenTree ? flattenDouble(node) : node;
        }
    } 

        public void copyInto(double[] array, int offset) {
            assert !building : "during building";
            super.copyInto(array, offset);
        } 

            OfInt(Spliterator<P_IN> spliterator, PipelineHelper<Integer> helper, int[] array) {
                super(spliterator, helper, array.length);
                this.array = array;
            } 

                extends CollectorTask<P_IN, P_OUT, java.util.stream.Node<P_OUT>, java.util.stream.Node.Builder<P_OUT>> {
            OfRef(PipelineHelper<P_OUT> helper,
                  IntFunction<P_OUT[]> generator,
                  Spliterator<P_IN> spliterator) {
                super(helper, spliterator, s -> builder(s, generator), ConcNode::new);
            }
        } 

    
    public static <P_IN> java.util.stream.Node.OfLong collectLong(PipelineHelper<Long> helper,
                                                                  Spliterator<P_IN> spliterator,
                                                                  boolean flattenTree) {
        long size = helper.exactOutputSizeIfKnown(spliterator);
        if (size >= 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
            if (size >= MAX_ARRAY_SIZE)
                throw new IllegalArgumentException(BAD_SIZE);
            long[] array = new long[(int) size];
            new SizedCollectorTask.OfLong<>(spliterator, helper, array).invoke();
            return node(array);
        }
        else {
            java.util.stream.Node.OfLong node = new CollectorTask.OfLong<>(helper, spliterator).invoke();
            return flattenTree ? flattenLong(node) : node;
        }
    } 

    
    default <P_IN> R evaluateParallel(PipelineHelper<E_IN> helper,
                                      Spliterator<P_IN> spliterator) {
        if (java.util.stream.Tripwire.ENABLED)
            java.util.stream.Tripwire.trip(getClass(), "{0} triggering TerminalOp.evaluateParallel serial default");
        return evaluateSequential(helper, spliterator);
    } 

    public final java.util.stream.Node<E_OUT> evaluateToArrayNode(java.util.function.IntFunction<E_OUT[]> r1) {
        
        throw new UnsupportedOperationException("Method not decompiled: java.util.stream.AbstractPipeline.evaluateToArrayNode(java.util.function.IntFunction):java.util.stream.Node<E_OUT>");
    } 

    public java.util.Spliterator<E_OUT> spliterator() {
        
        throw new UnsupportedOperationException("Method not decompiled: java.util.stream.AbstractPipeline.spliterator():java.util.Spliterator<E_OUT>");
    } 

    
    protected AbstractTask(PipelineHelper<P_OUT> helper,
                           Spliterator<P_IN> spliterator) {
        super(null);
        this.helper = helper;
        this.spliterator = spliterator;
        this.targetSize = 0L;
    } 

Advertisement
Javadoc
Helper class for executing stream pipelines, capturing all of the information about a stream pipeli

ne (output shape, intermediate operations, stream flags, parallelism, etc) in one place.

A 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 PipelineHelper. The PipelineHelper is passed to the TerminalOp#evaluateParallel(PipelineHelper, java.util.Spliterator), TerminalOp#evaluateSequential(PipelineHelper, java.util.Spliterator), and AbstractPipeline#opEvaluateParallel(PipelineHelper, java.util.Spliterator, java.util.function.IntFunction), methods, which can use the PipelineHelper to access information about the pipeline such as head shape, stream flags, and size, and use the helper methods such as #wrapAndCopyInto(Sink, Spliterator), #copyInto(Sink, Spliterator), and #wrapSink(Sink) to execute pipeline operations. @param type of output elements from the pipeline @since 1.8 @hide Visible for CTS testing only (OpenJDK8 tests).

Read More
Advertisement