Interface LongCacheStream
- All Superinterfaces:
AutoCloseable
,BaseCacheStream<Long,
,LongStream> BaseStream<Long,
,LongStream> LongStream
- All Known Implementing Classes:
DistributedLongCacheStream
,IntermediateLongCacheStream
LongStream
that has additional methods to allow for Serializable instances. Please see
CacheStream
for additional details about various methods.- Since:
- 9.0
- Author:
- wburns
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.BaseCacheStream
BaseCacheStream.SegmentCompletionListener
Nested classes/interfaces inherited from interface java.util.stream.LongStream
LongStream.Builder, LongStream.LongMapMultiConsumer
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
allMatch
(SerializableLongPredicate predicate) Same asLongStream.allMatch(LongPredicate)
except that the LongPredicate must also implement Serializable.default boolean
anyMatch
(SerializableLongPredicate predicate) Same asLongStream.anyMatch(LongPredicate)
except that the LongPredicate must also implement Serializable.boxed()
default <R> R
collect
(SerializableSupplier<R> supplier, SerializableObjLongConsumer<R> accumulator, SerializableBiConsumer<R, R> combiner) Same asLongStream.collect(Supplier, ObjLongConsumer, BiConsumer)
except that the arguments must also implement Serializable.Disables tracking of rehash events that could occur to the underlying cache.distinct()
distributedBatchSize
(int batchSize) Controls how many keys are returned from a remote node when using a stream terminal operation with a distributed cache to back this stream.filter
(LongPredicate predicate) default LongCacheStream
filter
(SerializableLongPredicate predicate) Same asfilter(LongPredicate)
except that the LongPredicate must also implement Serializable.filterKeys
(Set<?> keys) Filters which entries are returned by only returning ones that map to the given key.flatMap
(LongFunction<? extends LongStream> mapper) default LongCacheStream
flatMap
(SerializableLongFunction<? extends LongStream> mapper) Same asflatMap(LongFunction)
except that the LongFunction must also implement Serializable.<K,
V> void forEach
(ObjLongConsumer<Cache<K, V>> action) Same asLongStream.forEach(LongConsumer)
except that it takes anObjLongConsumer
that provides access to the underlyingCache
that is backing this stream.default void
forEach
(SerializableLongConsumer action) Same asLongStream.forEach(LongConsumer)
except that the LongConsumer must also implement Serializable.default <K,
V> void forEach
(SerializableObjLongConsumer<Cache<K, V>> action) limit
(long maxSize) map
(LongUnaryOperator mapper) default LongCacheStream
map
(SerializableLongUnaryOperator mapper) Same asmap(LongUnaryOperator)
except that the LongUnaryOperator must also implement Serializable.mapToDouble
(LongToDoubleFunction mapper) default DoubleCacheStream
Same asmapToDouble(LongToDoubleFunction)
except that the LongToLongFunction must also implement Serializable.mapToInt
(LongToIntFunction mapper) default IntCacheStream
Same asmapToInt(LongToIntFunction)
except that the LongToIntFunction must also implement Serializable.<U> CacheStream
<U> mapToObj
(LongFunction<? extends U> mapper) default <U> CacheStream
<U> mapToObj
(SerializableLongFunction<? extends U> mapper) Same asmapToObj(LongFunction)
except that the LongFunction must also implement Serializable.default boolean
noneMatch
(SerializableLongPredicate predicate) Same asLongStream.noneMatch(LongPredicate)
except that the LongPredicate must also implement Serializable.parallel()
This would enable sending requests to all other remote nodes when a terminal operator is performed.peek
(LongConsumer action) default LongCacheStream
peek
(SerializableLongConsumer action) Same asflatMap(LongFunction)
except that the LongFunction must also implement Serializable.default long
reduce
(long identity, SerializableLongBinaryOperator op) Same asLongStream.reduce(long, LongBinaryOperator)
except that the LongBinaryOperator must also implement Serializable.default OptionalLong
Same asLongStream.reduce(LongBinaryOperator)
except that the LongBinaryOperator must also implement Serializable.Allows registration of a segment completion listener that is notified when a segment has completed processing.This would disable sending requests to all other remote nodes compared to one at a time.skip
(long n) sorted()
Sets a given time to wait for a remote operation to respond by.Methods inherited from interface org.infinispan.BaseCacheStream
filterKeySegments
Methods inherited from interface java.util.stream.BaseStream
close, isParallel
-
Method Details
-
sequentialDistribution
LongCacheStream sequentialDistribution()This would disable sending requests to all other remote nodes compared to one at a time. This can reduce memory pressure on the originator node at the cost of performance.Parallel distribution is enabled by default except for
CacheStream.iterator()
andCacheStream.spliterator()
- Specified by:
sequentialDistribution
in interfaceBaseCacheStream<Long,
LongStream> - Returns:
- a stream with parallel distribution disabled.
-
parallelDistribution
LongCacheStream parallelDistribution()Description copied from interface:BaseCacheStream
This would enable sending requests to all other remote nodes when a terminal operator is performed. This requires additional overhead as it must process results concurrently from various nodes, but should perform faster in the majority of cases.Parallel distribution is enabled by default except for
CacheStream.iterator()
andCacheStream.spliterator()
- Specified by:
parallelDistribution
in interfaceBaseCacheStream<Long,
LongStream> - Returns:
- a stream with parallel distribution enabled.
-
filterKeys
Filters which entries are returned by only returning ones that map to the given key. This method will be faster than a regularCacheStream.filter(Predicate)
if the filter is holding references to the same keys.- Specified by:
filterKeys
in interfaceBaseCacheStream<Long,
LongStream> - Parameters:
keys
- The keys that this stream will only operate on.- Returns:
- a stream with the keys filtered.
-
distributedBatchSize
Controls how many keys are returned from a remote node when using a stream terminal operation with a distributed cache to back this stream. This value is ignored when terminal operators that don't track keys are used. Key tracking terminal operators areCacheStream.iterator()
,CacheStream.spliterator()
,CacheStream.forEach(Consumer)
. Please see those methods for additional information on how this value may affect them.This value may be used in the case of a a terminal operator that doesn't track keys if an intermediate operation is performed that requires bringing keys locally to do computations. Examples of such intermediate operations are
CacheStream.sorted()
,CacheStream.sorted(Comparator)
,CacheStream.distinct()
,CacheStream.limit(long)
,CacheStream.skip(long)
This value is always ignored when this stream is backed by a cache that is not distributed as all values are already local.
- Specified by:
distributedBatchSize
in interfaceBaseCacheStream<Long,
LongStream> - Parameters:
batchSize
- The size of each batch. This defaults to the state transfer chunk size.- Returns:
- a stream with the batch size updated
-
segmentCompletionListener
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 seeCacheStream.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 interfaceBaseCacheStream<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 interfaceBaseCacheStream<Long,
LongStream> - Returns:
- a stream with rehash awareness disabled.
-
timeout
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 theIterator
orSpliterator
.Note that if a rehash occurs this timeout value is reset for the subsequent retry if rehash aware is enabled.
- Specified by:
timeout
in interfaceBaseCacheStream<Long,
LongStream> - Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Returns:
- a stream with the timeout set
-
filter
- Specified by:
filter
in interfaceLongStream
- Returns:
- the new cache long stream
-
filter
Same asfilter(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
- Specified by:
map
in interfaceLongStream
- Returns:
- the new cache long stream
-
map
Same asmap(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
- Specified by:
mapToObj
in interfaceLongStream
- Returns:
- the new cache stream
-
mapToObj
Same asmapToObj(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
- Specified by:
mapToInt
in interfaceLongStream
- Returns:
- the new cache int stream
-
mapToInt
Same asmapToInt(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
- Specified by:
mapToDouble
in interfaceLongStream
- Returns:
- the new cache double stream
-
mapToDouble
Same asmapToDouble(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
- Specified by:
flatMap
in interfaceLongStream
- Returns:
- the new cache long stream
-
flatMap
Same asflatMap(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 aLongStream
of new values- Returns:
- the new cache long stream
-
distinct
LongCacheStream distinct()- Specified by:
distinct
in interfaceLongStream
- Returns:
- the new cache long stream
-
sorted
LongCacheStream sorted()- Specified by:
sorted
in interfaceLongStream
- Returns:
- the new cache long stream
-
peek
- Specified by:
peek
in interfaceLongStream
- Returns:
- the new cache long stream
-
peek
Same asflatMap(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
- Specified by:
limit
in interfaceLongStream
- Returns:
- the new cache long stream
-
skip
- Specified by:
skip
in interfaceLongStream
- Returns:
- the new cache long stream
-
forEach
Same asLongStream.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
Same asLongStream.forEach(LongConsumer)
except that it takes anObjLongConsumer
that provides access to the underlyingCache
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 cacheV
- value type of the cache- Parameters:
action
- consumer to be ran for each element in the stream
-
forEach
- Type Parameters:
K
- key type of the cacheV
- value type of the cache- Parameters:
action
- consumer to be ran for each element in the stream
-
reduce
Same asLongStream.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 functionop
- an associative, non-interfering, stateless function for combining two values- Returns:
- the result of the reduction
-
reduce
Same asLongStream.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(SerializableSupplier<R> supplier, SerializableObjLongConsumer<R> accumulator, SerializableBiConsumer<R, R> combiner) Same asLongStream.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 resultcombiner
- 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
Same asLongStream.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, otherwisefalse
-
allMatch
Same asLongStream.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, otherwisefalse
-
noneMatch
Same asLongStream.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, otherwisefalse
-
boxed
CacheStream<Long> boxed()- Specified by:
boxed
in interfaceLongStream
- Returns:
- the new cache stream containing longs
-
asDoubleStream
DoubleCacheStream asDoubleStream()- Specified by:
asDoubleStream
in interfaceLongStream
- Returns:
- the cache double stream
-
sequential
LongCacheStream sequential()- Specified by:
sequential
in interfaceBaseStream<Long,
LongStream> - Specified by:
sequential
in interfaceLongStream
- Returns:
- a sequential cache long stream
-
parallel
LongCacheStream parallel()- Specified by:
parallel
in interfaceBaseStream<Long,
LongStream> - Specified by:
parallel
in interfaceLongStream
- Returns:
- a parallel cache long stream
-
unordered
LongCacheStream unordered()- Specified by:
unordered
in interfaceBaseStream<Long,
LongStream> - Returns:
- an unordered cache long stream
-
onClose
- Specified by:
onClose
in interfaceBaseStream<Long,
LongStream> - Returns:
- a cache long stream with the handler applied
-