Interface LongCacheStream

    • Method Detail

      • filterKeySegments

        LongCacheStream filterKeySegments​(Set<Integer> segments)
        Filters which entries are returned by what segment they are present in. This method can be substantially more efficient than using a regular CacheStream.filter(Predicate) method as this can control what nodes are asked for data and what entries are read from the underlying CacheStore if present.
        Specified by:
        filterKeySegments in interface BaseCacheStream<Long,​LongStream>
        Parameters:
        segments - The segments to use for this stream operation. Any segments not in this set will be ignored.
        Returns:
        a stream with the segments filtered.
      • filterKeys

        LongCacheStream filterKeys​(Set<?> keys)
        Filters which entries are returned by only returning ones that map to the given key. This method will be faster than a regular CacheStream.filter(Predicate) if the filter is holding references to the same keys.
        Specified by:
        filterKeys in interface BaseCacheStream<Long,​LongStream>
        Parameters:
        keys - The keys that this stream will only operate on.
        Returns:
        a stream with the keys filtered.
      • segmentCompletionListener

        LongCacheStream segmentCompletionListener​(BaseCacheStream.SegmentCompletionListener listener)
        Allows registration of a segment completion listener that is notified when a segment has completed processing. If the terminal operator has a short circuit this listener may never be called.

        This method is designed for the sole purpose of use with the CacheStream.iterator() to allow for a user to track completion of segments as they are returned from the iterator. Behavior of other methods is not specified. Please see CacheStream.iterator() for more information.

        Multiple listeners may be registered upon multiple invocations of this method. The ordering of notified listeners is not specified.

        This is only used if this stream did not invoke BaseCacheStream.disableRehashAware() and has no flat map based operations. If this is done no segments will be notified.

        Specified by:
        segmentCompletionListener in interface BaseCacheStream<Long,​LongStream>
        Parameters:
        listener - The listener that will be called back as segments are completed.
        Returns:
        a stream with the listener registered.
      • disableRehashAware

        LongCacheStream disableRehashAware()
        Disables tracking of rehash events that could occur to the underlying cache. If a rehash event occurs while a terminal operation is being performed it is possible for some values that are in the cache to not be found. Note that you will never have an entry duplicated when rehash awareness is disabled, only lost values.

        Most terminal operations will run faster with rehash awareness disabled even without a rehash occuring. However if a rehash occurs with this disabled be prepared to possibly receive only a subset of values.

        Specified by:
        disableRehashAware in interface BaseCacheStream<Long,​LongStream>
        Returns:
        a stream with rehash awareness disabled.
      • timeout

        LongCacheStream timeout​(long timeout,
                                TimeUnit unit)
        Sets a given time to wait for a remote operation to respond by. This timeout does nothing if the terminal operation does not go remote.

        If a timeout does occur then a TimeoutException is thrown from the terminal operation invoking thread or on the next call to the Iterator or Spliterator.

        Note that if a rehash occurs this timeout value is reset for the subsequent retry if rehash aware is enabled.

        Specified by:
        timeout in interface BaseCacheStream<Long,​LongStream>
        Parameters:
        timeout - the maximum time to wait
        unit - the time unit of the timeout argument
        Returns:
        a stream with the timeout set
      • filter

        default LongCacheStream filter​(org.infinispan.util.function.SerializableLongPredicate predicate)
        Same as filter(LongPredicate) except that the LongPredicate must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be included
        Returns:
        the new cache long stream
      • map

        default LongCacheStream map​(org.infinispan.util.function.SerializableLongUnaryOperator mapper)
        Same as map(LongUnaryOperator) except that the LongUnaryOperator must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element
        Returns:
        the new cache long stream
      • mapToObj

        default <U> CacheStream<U> mapToObj​(org.infinispan.util.function.SerializableLongFunction<? extends U> mapper)
        Same as mapToObj(LongFunction) except that the LongFunction must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Type Parameters:
        U - the element type of the new stream
        Parameters:
        mapper - a non-interfering, stateless function to apply to each element
        Returns:
        the new cache stream
      • mapToInt

        default IntCacheStream mapToInt​(org.infinispan.util.function.SerializableLongToIntFunction mapper)
        Same as mapToInt(LongToIntFunction) except that the LongToIntFunction must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element
        Returns:
        the new cache int stream
      • mapToDouble

        default DoubleCacheStream mapToDouble​(org.infinispan.util.function.SerializableLongToDoubleFunction mapper)
        Same as mapToDouble(LongToDoubleFunction) except that the LongToLongFunction must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element
        Returns:
        the new cache double stream
      • flatMap

        default LongCacheStream flatMap​(org.infinispan.util.function.SerializableLongFunction<? extends LongStream> mapper)
        Same as flatMap(LongFunction) except that the LongFunction must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        mapper - a non-interfering, stateless function to apply to each element which produces a LongStream of new values
        Returns:
        the new cache long stream
      • peek

        default LongCacheStream peek​(org.infinispan.util.function.SerializableLongConsumer action)
        Same as flatMap(LongFunction) except that the LongFunction must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        action - a non-interfering action to perform on the elements as they are consumed from the stream
        Returns:
        the new cache long stream
      • limit

        LongCacheStream limit​(long maxSize)
        Returns:
        the new cache long stream
      • skip

        LongCacheStream skip​(long n)
        Returns:
        the new cache long stream
      • forEach

        default void forEach​(org.infinispan.util.function.SerializableLongConsumer action)
        Same as LongStream.forEach(LongConsumer) except that the LongConsumer must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        action - a non-interfering action to perform on the elements
      • forEach

        <K,​V> void forEach​(ObjLongConsumer<Cache<K,​V>> action)
        Same as LongStream.forEach(LongConsumer) except that it takes an ObjLongConsumer that provides access to the underlying Cache that is backing this stream.

        Note that the CacheAware interface is not supported for injection using this method as the cache is provided in the consumer directly.

        Type Parameters:
        K - key type of the cache
        V - value type of the cache
        Parameters:
        action - consumer to be ran for each element in the stream
      • forEach

        default <K,​V> void forEach​(org.infinispan.util.function.SerializableObjLongConsumer<Cache<K,​V>> action)
        Same as forEach(ObjLongConsumer) except that the BiConsumer must also implement Serializable
        Type Parameters:
        K - key type of the cache
        V - value type of the cache
        Parameters:
        action - consumer to be ran for each element in the stream
      • reduce

        default long reduce​(long identity,
                            org.infinispan.util.function.SerializableLongBinaryOperator op)
        Same as LongStream.reduce(long, LongBinaryOperator) except that the LongBinaryOperator must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        identity - the identity value for the accumulating function
        op - an associative, non-interfering, stateless function for combining two values
        Returns:
        the result of the reduction
      • reduce

        default OptionalLong reduce​(org.infinispan.util.function.SerializableLongBinaryOperator op)
        Same as LongStream.reduce(LongBinaryOperator) except that the LongBinaryOperator must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        op - an associative, non-interfering, stateless function for combining two values
        Returns:
        the result of the reduction
      • collect

        default <R> R collect​(org.infinispan.util.function.SerializableSupplier<R> supplier,
                              org.infinispan.util.function.SerializableObjLongConsumer<R> accumulator,
                              org.infinispan.util.function.SerializableBiConsumer<R,​R> combiner)
        Same as LongStream.collect(Supplier, ObjLongConsumer, BiConsumer) except that the arguments must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Type Parameters:
        R - type of the result
        Parameters:
        supplier - a function that creates a new result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.
        accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result
        combiner - an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
        Returns:
        the result of the reduction
      • anyMatch

        default boolean anyMatch​(org.infinispan.util.function.SerializableLongPredicate predicate)
        Same as LongStream.anyMatch(LongPredicate) except that the LongPredicate must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements of this stream
        Returns:
        true if any elements of the stream match the provided predicate, otherwise false
      • allMatch

        default boolean allMatch​(org.infinispan.util.function.SerializableLongPredicate predicate)
        Same as LongStream.allMatch(LongPredicate) except that the LongPredicate must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements of this stream
        Returns:
        true if either all elements of the stream match the provided predicate or the stream is empty, otherwise false
      • noneMatch

        default boolean noneMatch​(org.infinispan.util.function.SerializableLongPredicate predicate)
        Same as LongStream.noneMatch(LongPredicate) except that the LongPredicate must also implement Serializable.

        This method will be used automatically by lambdas, which prevents users from having to manually cast to a Serializable lambda.

        Parameters:
        predicate - a non-interfering, stateless predicate to apply to elements of this stream
        Returns:
        true if either no elements of the stream match the provided predicate or the stream is empty, otherwise false
      • boxed

        CacheStream<Long> boxed()
        Returns:
        the new cache stream containing longs
      • asDoubleStream

        DoubleCacheStream asDoubleStream()
        Returns:
        the cache double stream
      • sequential

        LongCacheStream sequential()
        Returns:
        a sequential cache long stream
      • parallel

        LongCacheStream parallel()
        Returns:
        a parallel cache long stream
      • unordered

        LongCacheStream unordered()
        Returns:
        an unordered cache long stream
      • onClose

        LongCacheStream onClose​(Runnable closeHandler)
        Returns:
        a cache long stream with the handler applied