Interface MDoubleStream

  • All Superinterfaces:
    AutoCloseable
    All Known Implementing Classes:
    LocalMDoubleStream

    public interface MDoubleStream
    extends AutoCloseable

    A facade for double stream classes, such as Java's DoubleStream and Spark's DoubleRDD objects. Provides a common interface to working with an manipulating streams regardless of their backend implementation.

    Author:
    David B. Bracewell
    • Method Detail

      • allMatch

        boolean allMatch​(SerializableDoublePredicate predicate)
        Determines if all doubles in the stream evaluate to true with the given predicate
        Parameters:
        predicate - the predicate to test double entries with
        Returns:
        True if all elements in the stream evaluate to true
      • anyMatch

        boolean anyMatch​(SerializableDoublePredicate predicate)
        Determines if any of the doubles in the stream evaluate to true with the given predicate
        Parameters:
        predicate - the predicate to test double entries with
        Returns:
        True if any of the elements in the stream evaluate to true
      • cache

        MDoubleStream cache()
        Caches the stream.
        Returns:
        the cached stream
      • count

        long count()
        The number of items in the stream
        Returns:
        the number of items in the stream
      • distinct

        MDoubleStream distinct()
        Removes duplicates from the stream
        Returns:
        the new stream without duplicates
      • first

        OptionalDouble first()
        Gets the first item in the stream
        Returns:
        the optional containing the first item
      • flatMap

        MDoubleStream flatMap​(SerializableDoubleFunction<double[]> mapper)
        Maps the doubles in this stream to one or more new doubles using the given function.
        Parameters:
        mapper - the function to use to map objects
        Returns:
        the new stream
      • forEach

        void forEach​(SerializableDoubleConsumer consumer)
        Performs an operation on each item in the stream
        Parameters:
        consumer - the consumer action to perform
      • getContext

        StreamingContext getContext()
        Gets the context used to create the stream
        Returns:
        the context
      • isEmpty

        boolean isEmpty()
        Determines if the stream is empty or not
        Returns:
        True if empty, False otherwise
      • limit

        MDoubleStream limit​(int n)
        Limits the stream to the first number items.
        Parameters:
        n - the number of items desired
        Returns:
        the new stream of size number
      • mapToObj

        <T> MStream<T> mapToObj​(SerializableDoubleFunction<? extends T> function)
        Maps the doubles in the stream to objects using the given function
        Type Parameters:
        T - the component type of the returning stream
        Parameters:
        function - the function to use to map doubles
        Returns:
        the new stream
      • max

        OptionalDouble max()
        Returns the max item in the stream.
        Returns:
        the optional containing the max value
      • mean

        double mean()
        The mean value of the stream
        Returns:
        the mean value
      • min

        OptionalDouble min()
        Returns the min item in the stream.
        Returns:
        the optional containing the min value
      • noneMatch

        boolean noneMatch​(SerializableDoublePredicate predicate)
        Determines if none of the doubles in the stream evaluate to true with the given predicate
        Parameters:
        predicate - the predicate to test double entries with
        Returns:
        True if none of the elements in the stream evaluate to true
      • onClose

        MDoubleStream onClose​(SerializableRunnable onCloseHandler)
        Sets the handler to call when the stream is closed. Typically, this is to clean up any open resources, such as file handles.
        Parameters:
        onCloseHandler - the handler to run when the stream is closed.
      • isDistributed

        boolean isDistributed()
      • parallel

        MDoubleStream parallel()
        Ensures that the stream is parallel or distributed.
        Returns:
        the new stream
      • reduce

        OptionalDouble reduce​(SerializableDoubleBinaryOperator operator)
        Performs a reduction on the elements of this stream using the given binary operator.
        Parameters:
        operator - the binary operator used to combine two objects
        Returns:
        the optional describing the reduction
      • reduce

        double reduce​(double zeroValue,
                      SerializableDoubleBinaryOperator operator)
        Performs a reduction on the elements of this stream using the given binary operator.
        Parameters:
        zeroValue - the starting value for the reduction
        operator - the binary operator used to combine two objects
        Returns:
        the optional describing the reduction
      • repartition

        MDoubleStream repartition​(int numberOfPartition)
        Repartitions the stream to the given number of partitions. This may be a no-op for some streams, i.e. Local Streams.
        Parameters:
        numberOfPartition - the number of partitions the stream should have
        Returns:
        the new stream
      • skip

        MDoubleStream skip​(int n)
        Skips the first n items in the stream
        Parameters:
        n - the number of items in the stream
        Returns:
        the new stream
      • sorted

        MDoubleStream sorted​(boolean ascending)
        Sorts the double stream in ascending order.
        Parameters:
        ascending - determines if the items should be sorted in ascending (true) or descending (false) order
        Returns:
        the new double stream
      • statistics

        EnhancedDoubleStatistics statistics()
        Calculates a number of useful statistics over the elements in the stream
        Returns:
        the statistics
      • stddev

        double stddev()
        Calculates the standard deviation of the stream
        Returns:
        the standard deviation
      • sum

        double sum()
        Calculates the sum of the stream
        Returns:
        the sum
      • toArray

        double[] toArray()
        Collects the values of the stream as a double array.
        Returns:
        the double array
      • union

        MDoubleStream union​(MDoubleStream other)
        Unions this stream with another
        Parameters:
        other - the other stream to append to this one
        Returns:
        the new double stream
      • updateConfig

        default void updateConfig()
        Updates the config instance used for this String