Interface CacheStream<R>
- Type Parameters:
R- The type of the stream
- All Superinterfaces:
AutoCloseable,BaseCacheStream<R,,Stream<R>> BaseStream<R,,Stream<R>> Stream<R>
- All Known Implementing Classes:
AbstractDelegatingCacheStream,DistributedCacheStream,IntermediateCacheStream
Stream that has additional operations to monitor or control behavior when used from a Cache.
Whenever the iterator or spliterator methods are used the user must close the Stream
that the method was invoked on after completion of its operation. Failure to do so may cause a thread leakage if
the iterator or spliterator are not fully consumed.
When using stream that is backed by a distributed cache these operations will be performed using remote distribution controlled by the segments that each key maps to. All intermediate operations are lazy, even the special cases described in later paragraphs and are not evaluated until a final terminal operation is invoked on the stream. Essentially each set of intermediate operations is shipped to each remote node where they are applied to a local stream there and finally the terminal operation is completed. If this stream is parallel the processing on remote nodes is also done using a parallel stream.
Parallel distribution is enabled by default for all operations except for iterator() and
spliterator(). Please see sequentialDistribution() and
parallelDistribution(). With this disabled only a single node will process the operation
at a time (includes locally).
Rehash aware is enabled by default for all operations. Any intermediate or terminal operation may be invoked
multiple times during a rehash and thus you should ensure the are idempotent. This can be problematic for
forEach(Consumer) as it may be difficult to implement with such requirements, please see it for
more information. If you wish to disable rehash aware operations you can disable them by calling
disableRehashAware() which should provide better performance for some operations. The
performance is most affected for the key aware operations iterator(),
spliterator(), forEach(Consumer). Disabling rehash can cause
incorrect results if the terminal operation is invoked and a rehash occurs before the operation completes. If
incorrect results do occur it is guaranteed that it will only be that entries were missed and no entries are
duplicated.
Any stateful intermediate operation requires pulling all information up to that point local to operate properly. Each of these methods may have slightly different behavior, so make sure you check the method you are utilizing.
An example of such an operation is using distinct intermediate operation. What will happen
is upon calling the terminal operation a remote retrieval operation will be ran using all of
the intermediate operations up to the distinct operation remotely. This retrieval is then used to fuel a local
stream where all of the remaining intermediate operations are performed and then finally the terminal operation is
applied as normal. Note in this case the intermediate iterator still obeys the
distributedBatchSize(int) setting irrespective of the terminal operator.
- Since:
- 8.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.BaseCacheStream
BaseCacheStream.SegmentCompletionListenerNested classes/interfaces inherited from interface java.util.stream.Stream
Stream.Builder<T extends Object> -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanallMatch(SerializablePredicate<? super R> predicate) Same asStream.allMatch(Predicate)except that the Predicate must also implementSerializabledefault booleananyMatch(SerializablePredicate<? super R> predicate) Same asStream.anyMatch(Predicate)except that the Predicate must also implementSerializabledefault <R1> R1Performs a mutable reduction operation on the elements of this stream using aCollectorthat is lazily created from theSupplierprovided.<R1> R1collect(Supplier<R1> supplier, BiConsumer<R1, ? super R> accumulator, BiConsumer<R1, R1> combiner) <R1,A> R1 default <R1> R1collect(SerializableSupplier<Collector<? super R, ?, R1>> supplier) Performs a mutable reduction operation on the elements of this stream using aCollectorthat is lazily created from theSerializableSupplierprovided.default <R1> R1collect(SerializableSupplier<R1> supplier, SerializableBiConsumer<R1, ? super R> accumulator, SerializableBiConsumer<R1, R1> combiner) Same ascollect(Supplier, BiConsumer, BiConsumer)except that the various arguments must also implementSerializableDisables 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.default CacheStream<R>filter(SerializablePredicate<? super R> predicate) Same asfilter(Predicate)except that the Predicate must also implementSerializablefilterKeys(Set<?> keys) Filters which entries are returned by only returning ones that map to the given key.filterKeySegments(Set<Integer> segments) Deprecated.filterKeySegments(IntSet segments) Filters which entries are returned by what segment they are present in.<R1> CacheStream<R1>default <R1> CacheStream<R1>flatMap(SerializableFunction<? super R, ? extends Stream<? extends R1>> mapper) Same asflatMap(Function)except that the Function must also implementSerializableflatMapToDouble(Function<? super R, ? extends DoubleStream> mapper) default DoubleCacheStreamflatMapToDouble(SerializableFunction<? super R, ? extends DoubleStream> mapper) Same asflatMapToDouble(Function)except that the Function must also implementSerializableflatMapToInt(Function<? super R, ? extends IntStream> mapper) default IntCacheStreamflatMapToInt(SerializableFunction<? super R, ? extends IntStream> mapper) Same asflatMapToInt(Function)except that the Function must also implementSerializableflatMapToLong(Function<? super R, ? extends LongStream> mapper) default LongCacheStreamflatMapToLong(SerializableFunction<? super R, ? extends LongStream> mapper) Same asflatMapToLong(Function)except that the Function must also implementSerializable<K,V> void forEach(BiConsumer<Cache<K, V>, ? super R> action) Same asforEach(Consumer)except that it takes aBiConsumerthat provides access to the underlyingCachethat is backing this stream.voiddefault <K,V> void forEach(SerializableBiConsumer<Cache<K, V>, ? super R> action) default voidforEach(SerializableConsumer<? super R> action) Same asforEach(Consumer)except that the Consumer must also implementSerializableiterator()limit(long maxSize) <R1> CacheStream<R1>default <R1> CacheStream<R1>map(SerializableFunction<? super R, ? extends R1> mapper) Same asmap(Function)except that the Function must also implementSerializablemapToDouble(ToDoubleFunction<? super R> mapper) default DoubleCacheStreammapToDouble(SerializableToDoubleFunction<? super R> mapper) Same asmapToDouble(ToDoubleFunction)except that the ToDoubleFunction must also implementSerializablemapToInt(ToIntFunction<? super R> mapper) default IntCacheStreammapToInt(SerializableToIntFunction<? super R> mapper) Same asmapToInt(ToIntFunction)except that the ToIntFunction must also implementSerializablemapToLong(ToLongFunction<? super R> mapper) default LongCacheStreammapToLong(SerializableToLongFunction<? super R> mapper) Same asmapToLong(ToLongFunction)except that the ToLongFunction must also implementSerializablemax(SerializableComparator<? super R> comparator) Same asStream.max(Comparator)except that the Comparator must also implementSerializablemin(SerializableComparator<? super R> comparator) Same asStream.min(Comparator)except that the Comparator must also implementSerializabledefault booleannoneMatch(SerializablePredicate<? super R> predicate) Same asStream.noneMatch(Predicate)except that the Predicate must also implementSerializableparallel()This would enable sending requests to all other remote nodes when a terminal operator is performed.default CacheStream<R>peek(SerializableConsumer<? super R> action) Same aspeek(Consumer)except that the Consumer must also implementSerializablereduce(SerializableBinaryOperator<R> accumulator) Same asStream.reduce(BinaryOperator)except that the BinaryOperator must also implementSerializabledefault Rreduce(R identity, SerializableBinaryOperator<R> accumulator) Same asStream.reduce(Object, BinaryOperator)except that the BinaryOperator must also implementSerializabledefault <U> Ureduce(U identity, SerializableBiFunction<U, ? super R, U> accumulator, SerializableBinaryOperator<U> combiner) Same asStream.reduce(Object, BiFunction, BinaryOperator)except that the BinaryOperator must also implementSerializableAllows 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()sorted(Comparator<? super R> comparator) default CacheStream<R>sorted(SerializableComparator<? super R> comparator) Same assorted(Comparator)except that the Comparator must also implementSerializableSets a given time to wait for a remote operation to respond by.default <A> A[]toArray(SerializableIntFunction<A[]> generator) Same asStream.toArray(IntFunction)except that the BinaryOperator must also implementSerializableMethods inherited from interface java.util.stream.BaseStream
close, isParallel
-
Method Details
-
sequentialDistribution
CacheStream<R> 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
iterator()andspliterator()- Specified by:
sequentialDistributionin interfaceBaseCacheStream<R,Stream<R>> - Returns:
- a stream with parallel distribution disabled.
-
parallelDistribution
CacheStream<R> parallelDistribution()Description copied from interface:BaseCacheStreamThis 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
iterator()andspliterator()- Specified by:
parallelDistributionin interfaceBaseCacheStream<R,Stream<R>> - Returns:
- a stream with parallel distribution enabled.
-
filterKeySegments
Deprecated.This is to be replaced byfilterKeySegments(IntSet)Filters which entries are returned by what segment they are present in. This method can be substantially more efficient than using a regularfilter(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:
filterKeySegmentsin interfaceBaseCacheStream<R,Stream<R>> - 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.
-
filterKeySegments
Filters which entries are returned by what segment they are present in. This method can be substantially more efficient than using a regularfilter(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:
filterKeySegmentsin interfaceBaseCacheStream<R,Stream<R>> - 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
Filters which entries are returned by only returning ones that map to the given key. This method will be faster than a regularfilter(Predicate)if the filter is holding references to the same keys.- Specified by:
filterKeysin interfaceBaseCacheStream<R,Stream<R>> - 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 areiterator(),spliterator(),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
sorted(),sorted(Comparator),distinct(),limit(long),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:
distributedBatchSizein interfaceBaseCacheStream<R,Stream<R>> - 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
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 seeiterator()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:
segmentCompletionListenerin interfaceBaseCacheStream<R,Stream<R>> - Parameters:
listener- The listener that will be called back as segments are completed.- Returns:
- a stream with the listener registered.
-
disableRehashAware
CacheStream<R> 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:
disableRehashAwarein interfaceBaseCacheStream<R,Stream<R>> - 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
TimeoutExceptionis thrown from the terminal operation invoking thread or on the next call to theIteratororSpliterator.Note that if a rehash occurs this timeout value is reset for the subsequent retry if rehash aware is enabled.
- Specified by:
timeoutin interfaceBaseCacheStream<R,Stream<R>> - Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- a stream with the timeout set
-
forEach
This operation is performed remotely on the node that is the primary owner for the key tied to the entry(s) in this stream.
NOTE: This method while being rehash aware has the lowest consistency of all of the operators. This operation will be performed on every entry at least once in the cluster, as long as the originator doesn't go down while it is being performed. This is due to how the distributed action is performed. Essentially the
distributedBatchSize(int)value controls how many elements are processed per node at a time when rehash is enabled. After those are complete the keys are sent to the originator to confirm that those were processed. If that node goes down during/before the response those keys will be processed a second time.It is possible to have the cache local to each node injected into this instance if the provided Consumer also implements the
CacheAwareinterface. This method will be invoked before the consumeraccept()method is invoked.This method is ran distributed by default with a distributed backing cache. However if you wish for this operation to run locally you can use the
stream().iterator().forEachRemaining(action)for a single threaded variant. If you wish to have a parallel variant you can useStreamSupport.stream(Spliterator, boolean)passing in the spliterator from the stream. In either case remember you must close the stream after you are done processing the iterator or spliterator.. -
forEach
Same asforEach(Consumer)except that the Consumer must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
action- consumer to be ran for each element in the stream
-
forEach
Same asforEach(Consumer)except that it takes aBiConsumerthat provides access to the underlyingCachethat is backing this stream.Note that the
CacheAwareinterface 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
-
iterator
Usage of this operator requires closing this stream after you are done with the iterator. The preferred usage is to use a try with resource block on the stream.
This method has special usage with the
BaseCacheStream.SegmentCompletionListenerin that as entries are retrieved from the next method it will complete segments.This method obeys the
distributedBatchSize(int). Note that when using methods such asflatMap(Function)that you will have possibly more than 1 element mapped to a given key so this doesn't guarantee that many number of entries are returned per batch.Note that the
Iterator.remove()method is only supported if no intermediate operations have been applied to the stream and this is not a stream created from aCache.values()collection.- Specified by:
iteratorin interfaceBaseStream<R,Stream<R>> - Returns:
- the element iterator for this stream
-
spliterator
Spliterator<R> spliterator()Usage of this operator requires closing this stream after you are done with the spliterator. The preferred usage is to use a try with resource block on the stream.
- Specified by:
spliteratorin interfaceBaseStream<R,Stream<R>> - Returns:
- the element spliterator for this stream
-
sorted
CacheStream<R> sorted()This operation is performed entirely on the local node irrespective of the backing cache. This operation will act as an intermediate iterator operation requiring data be brought locally for proper behavior. Beware this means it will require having all entries of this cache into memory at one time. This is described in more detail at
CacheStreamAny subsequent intermediate operations and the terminal operation are also performed locally.
-
sorted
This operation is performed entirely on the local node irrespective of the backing cache. This operation will act as an intermediate iterator operation requiring data be brought locally for proper behavior. Beware this means it will require having all entries of this cache into memory at one time. This is described in more detail at
CacheStreamAny subsequent intermediate operations and the terminal operation are then performed locally.
-
sorted
Same assorted(Comparator)except that the Comparator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
comparator- a non-interfering, statelessComparatorto be used to compare stream elements- Returns:
- the new stream
-
limit
This intermediate operation will be performed both remotely and locally to reduce how many elements are sent back from each node. More specifically this operation is applied remotely on each node to only return up to the maxSize value and then the aggregated results are limited once again on the local node.
This operation will act as an intermediate iterator operation requiring data be brought locally for proper behavior. This is described in more detail in the
CacheStreamdocumentationAny subsequent intermediate operations and the terminal operation are then performed locally.
-
skip
This operation is performed entirely on the local node irrespective of the backing cache. This operation will act as an intermediate iterator operation requiring data be brought locally for proper behavior. This is described in more detail in the
CacheStreamdocumentationDepending on the terminal operator this may or may not require all entries or a subset after skip is applied to be in memory all at once.
Any subsequent intermediate operations and the terminal operation are then performed locally.
-
peek
-
peek
Same aspeek(Consumer)except that the Consumer must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
action- a non-interfering action to perform on the elements as they are consumed from the stream- Returns:
- the new stream
-
distinct
CacheStream<R> distinct()This operation will be invoked both remotely and locally when used with a distributed cache backing this stream. This operation will act as an intermediate iterator operation requiring data be brought locally for proper behavior. This is described in more detail in the
CacheStreamdocumentationThis intermediate iterator operation will be performed locally and remotely requiring possibly a subset of all elements to be in memory
Any subsequent intermediate operations and the terminal operation are then performed locally.
-
collect
Note when using a distributed backing cache for this stream the collector must be marshallable. This prevents the usage of
Collectorsclass. However you can use theCacheCollectorsstatic factory methods to create a serializable wrapper, which then creates the actual collector lazily after being deserialized. This is useful to use any method from theCollectorsclass as you would normally. Alternatively, you can callcollect(SerializableSupplier)too.Note: The collector is applied on each node until all the local stream's values are reduced into a single object. Because of marshalling limitations, the final result of the collector on remote nodes is limited to a size of 2GB. If you need to process more than 2GB of data, you must force the collector to run on the originator with
spliterator():StreamSupport.stream(stream.filter(entry -> ...) .map(entry -> ...) .spliterator(), false) .collect(Collectors.toList()); -
collect
Performs a mutable reduction operation on the elements of this stream using aCollectorthat is lazily created from theSerializableSupplierprovided. This method behaves exactly the same ascollect(Collector)with the enhanced capability of working even when the mutable reduction operation has to run in a remote node and the operation is notSerializableor otherwise marshallable. So, this method is specially designed for situations when the user wants to use aCollectorinstance that has been created byCollectorsstatic factory methods. In this particular case, the function that instantiates theCollectorwill be marshalled according to theSerializablerules.Note: The collector is applied on each node until all the local stream's values are reduced into a single object. Because of marshalling limitations, the final result of the collector on remote nodes is limited to a size of 2GB. If you need to process more than 2GB of data, you must force the collector to run on the originator with
spliterator():StreamSupport.stream(stream.filter(entry -> ...) .map(entry -> ...) .spliterator(), false) .collect(Collectors.toList());- Type Parameters:
R1- The resulting type of the collector- Parameters:
supplier- The supplier to create the collector that is specifically serializable- Returns:
- the collected value
- Since:
- 9.2
-
collect
Performs a mutable reduction operation on the elements of this stream using aCollectorthat is lazily created from theSupplierprovided. This method behaves exactly the same ascollect(Collector)with the enhanced capability of working even when the mutable reduction operation has to run in a remote node and the operation is notSerializableor otherwise marshallable. So, this method is specially designed for situations when the user wants to use aCollectorinstance that has been created byCollectorsstatic factory methods. In this particular case, the function that instantiates theCollectorwill be marshalled using InfinispanExternalizerclass or one of its subtypes.Note: The collector is applied on each node until all the local stream's values are reduced into a single object. Because of marshalling limitations, the final result of the collector on remote nodes is limited to a size of 2GB. If you need to process more than 2GB of data, you must force the collector to run on the originator with
spliterator():StreamSupport.stream(stream.filter(entry -> ...) .map(entry -> ...) .spliterator(), false) .collect(Collectors.toList());- Type Parameters:
R1- The resulting type of the collector- Parameters:
supplier- The supplier to create the collector- Returns:
- the collected value
- Since:
- 9.2
-
collect
default <R1> R1 collect(SerializableSupplier<R1> supplier, SerializableBiConsumer<R1, ? super R> accumulator, SerializableBiConsumer<R1, R1> combiner) Same ascollect(Supplier, BiConsumer, BiConsumer)except that the various arguments must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Type Parameters:
R1- 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. Must be serializableaccumulator- an associative, non-interfering, stateless function for incorporating an additional element into a result and must be serializablecombiner- an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function and serializable- Returns:
- the result of the reduction
-
collect
<R1> R1 collect(Supplier<R1> supplier, BiConsumer<R1, ? super R> accumulator, BiConsumer<R1, R1> combiner) Note: The accumulator and combiner are applied on each node until all the local stream's values are reduced into a single object. Because of marshalling limitations, the final result of the collector on remote nodes is limited to a size of 2GB. If you need to process more than 2GB of data, you must force the collector to run on the originator with
spliterator():StreamSupport.stream(stream.filter(entry -> ...) .map(entry -> ...) .spliterator(), false) .collect(Collectors.toList()); -
allMatch
Same asStream.allMatch(Predicate)except that the Predicate must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
predicate- a non-interfering, stateless predicate to apply to elements of this stream that is serializable- Returns:
trueif either all elements of the stream match the provided predicate or the stream is empty, otherwisefalse
-
noneMatch
Same asStream.noneMatch(Predicate)except that the Predicate must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
predicate- a non-interfering, stateless predicate to apply to elements of this stream that is serializable- Returns:
trueif either no elements of the stream match the provided predicate or the stream is empty, otherwisefalse
-
anyMatch
Same asStream.anyMatch(Predicate)except that the Predicate must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
predicate- a non-interfering, stateless predicate to apply to elements of this stream that is serializable- Returns:
trueif any elements of the stream match the provided predicate, otherwisefalse
-
max
Same asStream.max(Comparator)except that the Comparator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
comparator- a non-interfering, statelessComparatorto compare elements of this stream that is also serializable- Returns:
- an
Optionaldescribing the maximum element of this stream, or an emptyOptionalif the stream is empty
-
min
Same asStream.min(Comparator)except that the Comparator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
comparator- a non-interfering, statelessComparatorto compare elements of this stream that is also serializable- Returns:
- an
Optionaldescribing the minimum element of this stream, or an emptyOptionalif the stream is empty
-
reduce
Same asStream.reduce(BinaryOperator)except that the BinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
accumulator- an associative, non-interfering, stateless function for combining two values that is also serializable- Returns:
- an
Optionaldescribing the result of the reduction
-
reduce
Same asStream.reduce(Object, BinaryOperator)except that the BinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
identity- the identity value for the accumulating functionaccumulator- an associative, non-interfering, stateless function for combining two values that is also serializable- Returns:
- the result of the reduction
-
reduce
default <U> U reduce(U identity, SerializableBiFunction<U, ? super R, U> accumulator, SerializableBinaryOperator<U> combiner) Same asStream.reduce(Object, BiFunction, BinaryOperator)except that the BinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
SerializableJust like in the cache,
nullvalues are not supported.- Type Parameters:
U- The type of the result- Parameters:
identity- the identity value for the combiner functionaccumulator- an associative, non-interfering, stateless function for incorporating an additional element into a result that is also serializablecombiner- an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function that is also serializable- Returns:
- the result of the reduction
-
toArray
Same asStream.toArray(IntFunction)except that the BinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Type Parameters:
A- the element type of the resulting array- Parameters:
generator- a function which produces a new array of the desired type and the provided length that is also serializable- Returns:
- an array containing the elements in this stream
-
filter
-
filter
Same asfilter(Predicate)except that the Predicate must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
predicate- a non-interfering, stateless predicate to apply to each element to determine if it should be included- Returns:
- the new cache stream
-
map
Just like in the cache,
nullvalues are not supported. -
map
Same asmap(Function)except that the Function must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Type Parameters:
R1- The element type of the new stream- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new cache stream
-
mapToDouble
- Specified by:
mapToDoublein interfaceStream<R>- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new double cache stream
-
mapToDouble
Same asmapToDouble(ToDoubleFunction)except that the ToDoubleFunction must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new stream
-
mapToInt
-
mapToInt
Same asmapToInt(ToIntFunction)except that the ToIntFunction must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new stream
-
mapToLong
-
mapToLong
Same asmapToLong(ToLongFunction)except that the ToLongFunction must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new stream
-
flatMap
-
flatMap
default <R1> CacheStream<R1> flatMap(SerializableFunction<? super R, ? extends Stream<? extends R1>> mapper) Same asflatMap(Function)except that the Function must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Type Parameters:
R1- The element type of the new stream- Parameters:
mapper- a non-interfering, stateless function to apply to each element which produces a stream of new values- Returns:
- the new cache stream
-
flatMapToDouble
- Specified by:
flatMapToDoublein interfaceStream<R>- Returns:
- the new cache stream
-
flatMapToDouble
default DoubleCacheStream flatMapToDouble(SerializableFunction<? super R, ? extends DoubleStream> mapper) Same asflatMapToDouble(Function)except that the Function must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element which produces a stream of new values- Returns:
- the new stream
-
flatMapToInt
- Specified by:
flatMapToIntin interfaceStream<R>- Returns:
- the new cache stream
-
flatMapToInt
Same asflatMapToInt(Function)except that the Function must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element which produces a stream of new values- Returns:
- the new stream
-
flatMapToLong
- Specified by:
flatMapToLongin interfaceStream<R>- Returns:
- the new cache stream
-
flatMapToLong
Same asflatMapToLong(Function)except that the Function must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- Parameters:
mapper- a non-interfering, stateless function to apply to each element which produces a stream of new values- Returns:
- the new stream
-
parallel
CacheStream<R> parallel()- Specified by:
parallelin interfaceBaseStream<R,Stream<R>> - Returns:
- a parallel cache stream
-
sequential
CacheStream<R> sequential()- Specified by:
sequentialin interfaceBaseStream<R,Stream<R>> - Returns:
- a sequential cache stream
-
unordered
CacheStream<R> unordered()- Specified by:
unorderedin interfaceBaseStream<R,Stream<R>> - Returns:
- an unordered cache stream
-
onClose
- Specified by:
onClosein interfaceBaseStream<R,Stream<R>> - Parameters:
closeHandler-- Returns:
- a cache stream with the handler applied
-
filterKeySegments(IntSet)