Interface IntCacheStream
-
- All Superinterfaces:
AutoCloseable,BaseCacheStream<Integer,IntStream>,BaseStream<Integer,IntStream>,IntStream
public interface IntCacheStream extends IntStream, BaseCacheStream<Integer,IntStream>
AIntStreamthat has additional methods to allow for Serializable instances. Please seeCacheStreamfor additional details about various methods.- Since:
- 9.0
- Author:
- wburns
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.BaseCacheStream
BaseCacheStream.SegmentCompletionListener
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanallMatch(org.infinispan.util.function.SerializableIntPredicate predicate)Same asIntStream.allMatch(IntPredicate)except that the IntPredicate must also implementSerializabledefault booleananyMatch(org.infinispan.util.function.SerializableIntPredicate predicate)Same asIntStream.anyMatch(IntPredicate)except that the IntPredicate must also implementSerializableDoubleCacheStreamasDoubleStream()LongCacheStreamasLongStream()CacheStream<Integer>boxed()default <R> Rcollect(org.infinispan.util.function.SerializableSupplier<R> supplier, org.infinispan.util.function.SerializableObjIntConsumer<R> accumulator, org.infinispan.util.function.SerializableBiConsumer<R,R> combiner)Same asIntStream.collect(Supplier, ObjIntConsumer, BiConsumer)except that the arguments must also implementSerializableIntCacheStreamdisableRehashAware()Disables tracking of rehash events that could occur to the underlying cache.IntCacheStreamdistinct()IntCacheStreamdistributedBatchSize(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.IntCacheStreamfilter(IntPredicate predicate)default IntCacheStreamfilter(org.infinispan.util.function.SerializableIntPredicate predicate)Same asfilter(IntPredicate)except that the IntPredicate must also implementSerializableIntCacheStreamfilterKeys(Set<?> keys)Filters which entries are returned by only returning ones that map to the given key.IntCacheStreamfilterKeySegments(Set<Integer> segments)Filters which entries are returned by what segment they are present in.IntCacheStreamflatMap(IntFunction<? extends IntStream> mapper)default IntCacheStreamflatMap(org.infinispan.util.function.SerializableIntFunction<? extends IntStream> mapper)Same asflatMap(IntFunction)except that the IntFunction must also implementSerializable<K,V>
voidforEach(ObjIntConsumer<Cache<K,V>> action)Same asIntStream.forEach(IntConsumer)except that it takes anObjIntConsumerthat provides access to the underlyingCachethat is backing this stream.default voidforEach(org.infinispan.util.function.SerializableIntConsumer action)Same asIntStream.forEach(IntConsumer)except that the IntConsumer must also implementSerializabledefault <K,V>
voidforEach(org.infinispan.util.function.SerializableObjIntConsumer<Cache<K,V>> action)IntCacheStreamlimit(long maxSize)IntCacheStreammap(IntUnaryOperator mapper)default IntCacheStreammap(org.infinispan.util.function.SerializableIntUnaryOperator mapper)Same asmap(IntUnaryOperator)except that the IntUnaryOperator must also implementSerializableDoubleCacheStreammapToDouble(IntToDoubleFunction mapper)default DoubleCacheStreammapToDouble(org.infinispan.util.function.SerializableIntToDoubleFunction mapper)Same asmapToDouble(IntToDoubleFunction)except that the IntToIntFunction must also implementSerializableLongCacheStreammapToLong(IntToLongFunction mapper)default LongCacheStreammapToLong(org.infinispan.util.function.SerializableIntToLongFunction mapper)Same asmapToLong(IntToLongFunction)except that the IntToLongFunction must also implementSerializable<U> CacheStream<U>mapToObj(IntFunction<? extends U> mapper)default <U> CacheStream<U>mapToObj(org.infinispan.util.function.SerializableIntFunction<? extends U> mapper)Same asmapToObj(IntFunction)except that the IntFunction must also implementSerializabledefault booleannoneMatch(org.infinispan.util.function.SerializableIntPredicate predicate)Same asIntStream.noneMatch(IntPredicate)except that the IntPredicate must also implementSerializableIntCacheStreamonClose(Runnable closeHandler)IntCacheStreamparallel()IntCacheStreamparallelDistribution()This would enable sending requests to all other remote nodes when a terminal operator is performed.IntCacheStreampeek(IntConsumer action)default IntCacheStreampeek(org.infinispan.util.function.SerializableIntConsumer action)Same asflatMap(IntFunction)except that the IntFunction must also implementSerializabledefault intreduce(int identity, org.infinispan.util.function.SerializableIntBinaryOperator op)Same asIntStream.reduce(int, IntBinaryOperator)except that the IntBinaryOperator must also implementSerializabledefault OptionalIntreduce(org.infinispan.util.function.SerializableIntBinaryOperator op)Same asIntStream.reduce(IntBinaryOperator)except that the IntBinaryOperator must also implementSerializableIntCacheStreamsegmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)Allows registration of a segment completion listener that is notified when a segment has completed processing.IntCacheStreamsequential()IntCacheStreamsequentialDistribution()This would disable sending requests to all other remote nodes compared to one at a time.IntCacheStreamskip(long n)IntCacheStreamsorted()IntCacheStreamtimeout(long timeout, TimeUnit unit)Sets a given time to wait for a remote operation to respond by.IntCacheStreamunordered()-
Methods inherited from interface org.infinispan.BaseCacheStream
filterKeySegments
-
-
-
-
Method Detail
-
sequentialDistribution
IntCacheStream 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:
sequentialDistributionin interfaceBaseCacheStream<Integer,IntStream>- Returns:
- a stream with parallel distribution disabled.
-
parallelDistribution
IntCacheStream 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
CacheStream.iterator()andCacheStream.spliterator()- Specified by:
parallelDistributionin interfaceBaseCacheStream<Integer,IntStream>- Returns:
- a stream with parallel distribution enabled.
-
filterKeySegments
IntCacheStream 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 regularCacheStream.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:
filterKeySegmentsin interfaceBaseCacheStream<Integer,IntStream>- 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
IntCacheStream 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 regularCacheStream.filter(Predicate)if the filter is holding references to the same keys.- Specified by:
filterKeysin interfaceBaseCacheStream<Integer,IntStream>- Parameters:
keys- The keys that this stream will only operate on.- Returns:
- a stream with the keys filtered.
-
distributedBatchSize
IntCacheStream 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. 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:
distributedBatchSizein interfaceBaseCacheStream<Integer,IntStream>- Parameters:
batchSize- The size of each batch. This defaults to the state transfer chunk size.- Returns:
- a stream with the batch size updated
-
segmentCompletionListener
IntCacheStream 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 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:
segmentCompletionListenerin interfaceBaseCacheStream<Integer,IntStream>- Parameters:
listener- The listener that will be called back as segments are completed.- Returns:
- a stream with the listener registered.
-
disableRehashAware
IntCacheStream 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<Integer,IntStream>- Returns:
- a stream with rehash awareness disabled.
-
timeout
IntCacheStream 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
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<Integer,IntStream>- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- a stream with the timeout set
-
filter
IntCacheStream filter(IntPredicate predicate)
- Returns:
- the new cache int stream
-
filter
default IntCacheStream filter(org.infinispan.util.function.SerializableIntPredicate predicate)
Same asfilter(IntPredicate)except that the IntPredicate 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 int stream
-
map
IntCacheStream map(IntUnaryOperator mapper)
- Returns:
- the new cache int stream
-
map
default IntCacheStream map(org.infinispan.util.function.SerializableIntUnaryOperator mapper)
Same asmap(IntUnaryOperator)except that the IntUnaryOperator 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 cache int stream
-
mapToObj
<U> CacheStream<U> mapToObj(IntFunction<? extends U> mapper)
- Returns:
- the new cache stream
-
mapToObj
default <U> CacheStream<U> mapToObj(org.infinispan.util.function.SerializableIntFunction<? extends U> mapper)
Same asmapToObj(IntFunction)except that the IntFunction must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- 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
-
mapToDouble
DoubleCacheStream mapToDouble(IntToDoubleFunction mapper)
- Returns:
- the new cache double stream
-
mapToDouble
default DoubleCacheStream mapToDouble(org.infinispan.util.function.SerializableIntToDoubleFunction mapper)
Same asmapToDouble(IntToDoubleFunction)except that the IntToIntFunction 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 cache double stream
-
mapToLong
LongCacheStream mapToLong(IntToLongFunction mapper)
- Returns:
- the new cache long stream
-
mapToLong
default LongCacheStream mapToLong(org.infinispan.util.function.SerializableIntToLongFunction mapper)
Same asmapToLong(IntToLongFunction)except that the IntToLongFunction 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 cache long stream
-
flatMap
IntCacheStream flatMap(IntFunction<? extends IntStream> mapper)
- Returns:
- the new cache int stream
-
flatMap
default IntCacheStream flatMap(org.infinispan.util.function.SerializableIntFunction<? extends IntStream> mapper)
Same asflatMap(IntFunction)except that the IntFunction 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 aIntStreamof new values- Returns:
- the new cache int stream
-
distinct
IntCacheStream distinct()
- Returns:
- the new cache int stream
-
sorted
IntCacheStream sorted()
- Returns:
- the new cache int stream
-
peek
IntCacheStream peek(IntConsumer action)
- Returns:
- the new cache int stream
-
peek
default IntCacheStream peek(org.infinispan.util.function.SerializableIntConsumer action)
Same asflatMap(IntFunction)except that the IntFunction 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 cache int stream
-
limit
IntCacheStream limit(long maxSize)
- Returns:
- the new cache int stream
-
skip
IntCacheStream skip(long n)
- Returns:
- the new cache int stream
-
forEach
default void forEach(org.infinispan.util.function.SerializableIntConsumer action)
Same asIntStream.forEach(IntConsumer)except that the IntConsumer 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
-
forEach
<K,V> void forEach(ObjIntConsumer<Cache<K,V>> action)
Same asIntStream.forEach(IntConsumer)except that it takes anObjIntConsumerthat 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
default <K,V> void forEach(org.infinispan.util.function.SerializableObjIntConsumer<Cache<K,V>> action)
- 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
default int reduce(int identity, org.infinispan.util.function.SerializableIntBinaryOperator op)Same asIntStream.reduce(int, IntBinaryOperator)except that the IntBinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- 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
default OptionalInt reduce(org.infinispan.util.function.SerializableIntBinaryOperator op)
Same asIntStream.reduce(IntBinaryOperator)except that the IntBinaryOperator must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- 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.SerializableObjIntConsumer<R> accumulator, org.infinispan.util.function.SerializableBiConsumer<R,R> combiner)Same asIntStream.collect(Supplier, ObjIntConsumer, BiConsumer)except that the arguments must also implementSerializableThe compiler will pick this overload for lambda parameters, making them
Serializable- 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
default boolean anyMatch(org.infinispan.util.function.SerializableIntPredicate predicate)
Same asIntStream.anyMatch(IntPredicate)except that the IntPredicate 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- Returns:
trueif any elements of the stream match the provided predicate, otherwisefalse
-
allMatch
default boolean allMatch(org.infinispan.util.function.SerializableIntPredicate predicate)
Same asIntStream.allMatch(IntPredicate)except that the IntPredicate 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- Returns:
trueif either all elements of the stream match the provided predicate or the stream is empty, otherwisefalse
-
noneMatch
default boolean noneMatch(org.infinispan.util.function.SerializableIntPredicate predicate)
Same asIntStream.noneMatch(IntPredicate)except that the IntPredicate 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- Returns:
trueif either no elements of the stream match the provided predicate or the stream is empty, otherwisefalse
-
boxed
CacheStream<Integer> boxed()
- Returns:
- the new cache stream containing integers
-
asDoubleStream
DoubleCacheStream asDoubleStream()
- Returns:
- the cache double stream
-
asLongStream
LongCacheStream asLongStream()
- Returns:
- the cache long stream
-
sequential
IntCacheStream sequential()
- Returns:
- a sequential cache int stream
-
parallel
IntCacheStream parallel()
- Returns:
- a parallel cache int stream
-
unordered
IntCacheStream unordered()
- Returns:
- an unordered cache int stream
-
onClose
IntCacheStream onClose(Runnable closeHandler)
- Returns:
- a cache int stream with the handler applied
-
-