Class DistributedLongCacheStream<Original>
- Type Parameters:
Original- original stream type
- All Implemented Interfaces:
AutoCloseable,BaseStream<Long,,LongStream> LongStream,BaseCacheStream<Long,,LongStream> LongCacheStream
LongStream that utilizes a lazily evaluated distributed back end execution. Note this
class is only able to be created using CacheStream.mapToInt(ToIntFunction) or similar
methods from the CacheStream interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.BaseCacheStream
BaseCacheStream.SegmentCompletionListenerNested classes/interfaces inherited from interface java.util.stream.LongStream
LongStream.Builder -
Field Summary
Fields inherited from class org.infinispan.stream.impl.AbstractCacheStream
closeRunnable, cpm, distributedBatchSize, executor, explicitFlags, intermediateOperations, invocationContext, iteratorOperation, keyPartitioner, keysToFilter, localAddress, parallel, parallelDistribution, partition, registry, rehashAware, segmentCompletionListener, segmentsToFilter, stateTransferLock, timeout, timeoutUnit, toKeyFunction -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThis constructor is to be used only when a user calls a map or flat map method changing to an IntStream from a CacheStream, Stream, DoubleStream, IntStream etc. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallMatch(LongPredicate predicate) booleananyMatch(LongPredicate predicate) average()boxed()protected <R> DistributedCacheStream<Original,R> <R> Rcollect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) longcount()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.protected DistributedDoubleCacheStream<Original>filter(LongPredicate predicate) filter(SerializableLongPredicate predicate) Same asLongCacheStream.filter(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.filterKeySegments(Set<Integer> segments) Filters which entries are returned by what segment they are present in.filterKeySegments(IntSet segments) Filters which entries are returned by what segment they are present in.findAny()flatMap(LongFunction<? extends LongStream> mapper) flatMap(SerializableLongFunction<? extends LongStream> mapper) Same asLongCacheStream.flatMap(LongFunction)except that the LongFunction must also implement Serializable.voidforEach(LongConsumer action) <K,V> void forEach(ObjLongConsumer<Cache<K, V>> action) Same asLongStream.forEach(LongConsumer)except that it takes anObjLongConsumerthat provides access to the underlyingCachethat is backing this stream.voidforEach(SerializableLongConsumer action) Same asLongStream.forEach(LongConsumer)except that the LongConsumer must also implement Serializable.<K,V> void forEach(SerializableObjLongConsumer<Cache<K, V>> action) Same asLongCacheStream.forEach(ObjLongConsumer)except that theBiConsumermust also implementSerializablevoidforEachOrdered(LongConsumer action) protected org.infinispan.util.logging.LoggetLog()protected DistributedIntCacheStream<Original>iterator()limit(long maxSize) map(LongUnaryOperator mapper) map(SerializableLongUnaryOperator mapper) Same asLongCacheStream.map(LongUnaryOperator)except that the LongUnaryOperator must also implement Serializable.mapToDouble(LongToDoubleFunction mapper) Same asLongCacheStream.mapToDouble(LongToDoubleFunction)except that the LongToLongFunction must also implement Serializable.mapToInt(LongToIntFunction mapper) Same asLongCacheStream.mapToInt(LongToIntFunction)except that the LongToIntFunction must also implement Serializable.<U> CacheStream<U>mapToObj(LongFunction<? extends U> mapper) <U> CacheStream<U>mapToObj(SerializableLongFunction<? extends U> mapper) Same asLongCacheStream.mapToObj(LongFunction)except that the LongFunction must also implement Serializable.max()min()booleannoneMatch(LongPredicate predicate) This would enable sending requests to all other remote nodes when a terminal operator is performed.peek(LongConsumer action) peek(SerializableLongConsumer action) Same asLongCacheStream.flatMap(LongFunction)except that the LongFunction must also implement Serializable.longreduce(long identity, LongBinaryOperator op) 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()longsum()Sets a given time to wait for a remote operation to respond by.long[]toArray()protected LongCacheStreamunwrap()Methods inherited from class org.infinispan.stream.impl.AbstractCacheStream
addIntermediateOperation, addIntermediateOperation, addIntermediateOperationMap, close, composeWithExceptions, isParallel, isPrimaryOwner, onClose, parallel, sequential, unorderedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.stream.BaseStream
close, isParallelMethods inherited from interface org.infinispan.LongCacheStream
allMatch, anyMatch, collect, noneMatch, onClose, parallel, reduce, reduce, sequential, unorderedMethods inherited from interface java.util.stream.LongStream
dropWhile, takeWhile
-
Constructor Details
-
DistributedLongCacheStream
This constructor is to be used only when a user calls a map or flat map method changing to an IntStream from a CacheStream, Stream, DoubleStream, IntStream etc.- Parameters:
other- other instance ofAbstractCacheStreamto copy details from
-
-
Method Details
-
getLog
protected org.infinispan.util.logging.Log getLog()- Specified by:
getLogin classAbstractCacheStream<Original,Long, LongStream, LongCacheStream>
-
unwrap
- Specified by:
unwrapin classAbstractCacheStream<Original,Long, LongStream, LongCacheStream>
-
filter
Description copied from interface:LongCacheStream- Specified by:
filterin interfaceLongCacheStream- Specified by:
filterin interfaceLongStream- Returns:
- the new cache long stream
-
filter
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
filterin interfaceLongCacheStream- 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
Description copied from interface:LongCacheStream- Specified by:
mapin interfaceLongCacheStream- Specified by:
mapin interfaceLongStream- Returns:
- the new cache long stream
-
map
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
mapin interfaceLongCacheStream- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new cache long stream
-
mapToObj
Description copied from interface:LongCacheStream- Specified by:
mapToObjin interfaceLongCacheStream- Specified by:
mapToObjin interfaceLongStream- Returns:
- the new cache stream
-
mapToObj
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
mapToObjin interfaceLongCacheStream- 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
Description copied from interface:LongCacheStream- Specified by:
mapToIntin interfaceLongCacheStream- Specified by:
mapToIntin interfaceLongStream- Returns:
- the new cache int stream
-
mapToInt
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
mapToIntin interfaceLongCacheStream- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new cache int stream
-
mapToDouble
Description copied from interface:LongCacheStream- Specified by:
mapToDoublein interfaceLongCacheStream- Specified by:
mapToDoublein interfaceLongStream- Returns:
- the new cache double stream
-
mapToDouble
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
mapToDoublein interfaceLongCacheStream- Parameters:
mapper- a non-interfering, stateless function to apply to each element- Returns:
- the new cache double stream
-
flatMap
Description copied from interface:LongCacheStream- Specified by:
flatMapin interfaceLongCacheStream- Specified by:
flatMapin interfaceLongStream- Returns:
- the new cache long stream
-
flatMap
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
flatMapin interfaceLongCacheStream- Parameters:
mapper- a non-interfering, stateless function to apply to each element which produces aLongStreamof new values- Returns:
- the new cache long stream
-
distinct
Description copied from interface:LongCacheStream- Specified by:
distinctin interfaceLongCacheStream- Specified by:
distinctin interfaceLongStream- Returns:
- the new cache long stream
-
sorted
Description copied from interface:LongCacheStream- Specified by:
sortedin interfaceLongCacheStream- Specified by:
sortedin interfaceLongStream- Returns:
- the new cache long stream
-
peek
Description copied from interface:LongCacheStream- Specified by:
peekin interfaceLongCacheStream- Specified by:
peekin interfaceLongStream- Returns:
- the new cache long stream
-
peek
Description copied from interface:LongCacheStreamSame asLongCacheStream.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.
- Specified by:
peekin interfaceLongCacheStream- Parameters:
action- a non-interfering action to perform on the elements as they are consumed from the stream- Returns:
- the new cache long stream
-
asDoubleStream
Description copied from interface:LongCacheStream- Specified by:
asDoubleStreamin interfaceLongCacheStream- Specified by:
asDoubleStreamin interfaceLongStream- Returns:
- the cache double stream
-
boxed
Description copied from interface:LongCacheStream- Specified by:
boxedin interfaceLongCacheStream- Specified by:
boxedin interfaceLongStream- Returns:
- the new cache stream containing longs
-
limit
Description copied from interface:LongCacheStream- Specified by:
limitin interfaceLongCacheStream- Specified by:
limitin interfaceLongStream- Returns:
- the new cache long stream
-
skip
Description copied from interface:LongCacheStream- Specified by:
skipin interfaceLongCacheStream- Specified by:
skipin interfaceLongStream- Returns:
- the new cache long stream
-
forEach
- Specified by:
forEachin interfaceLongStream
-
forEach
Description copied from interface:LongCacheStreamSame 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.
- Specified by:
forEachin interfaceLongCacheStream- Parameters:
action- a non-interfering action to perform on the elements
-
forEach
Description copied from interface:LongCacheStreamSame asLongStream.forEach(LongConsumer)except that it takes anObjLongConsumerthat 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.- Specified by:
forEachin interfaceLongCacheStream- 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
Description copied from interface:LongCacheStreamSame asLongCacheStream.forEach(ObjLongConsumer)except that theBiConsumermust also implementSerializable- Specified by:
forEachin interfaceLongCacheStream- 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
-
forEachOrdered
- Specified by:
forEachOrderedin interfaceLongStream
-
toArray
public long[] toArray()- Specified by:
toArrayin interfaceLongStream
-
reduce
- Specified by:
reducein interfaceLongStream
-
reduce
- Specified by:
reducein interfaceLongStream
-
collect
public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) - Specified by:
collectin interfaceLongStream
-
sum
public long sum()- Specified by:
sumin interfaceLongStream
-
min
- Specified by:
minin interfaceLongStream
-
max
- Specified by:
maxin interfaceLongStream
-
average
- Specified by:
averagein interfaceLongStream
-
summaryStatistics
- Specified by:
summaryStatisticsin interfaceLongStream
-
anyMatch
- Specified by:
anyMatchin interfaceLongStream
-
allMatch
- Specified by:
allMatchin interfaceLongStream
-
noneMatch
- Specified by:
noneMatchin interfaceLongStream
-
findFirst
- Specified by:
findFirstin interfaceLongStream
-
findAny
- Specified by:
findAnyin interfaceLongStream
-
iterator
- Specified by:
iteratorin interfaceBaseStream<Long,LongStream> - Specified by:
iteratorin interfaceLongStream
-
spliterator
- Specified by:
spliteratorin interfaceBaseStream<Long,LongStream> - Specified by:
spliteratorin interfaceLongStream
-
count
public long count()- Specified by:
countin interfaceLongStream
-
sequentialDistribution
Description copied from interface:LongCacheStreamThis 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<Long,LongStream> - Specified by:
sequentialDistributionin interfaceLongCacheStream- Returns:
- a stream with parallel distribution disabled.
-
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<Long,LongStream> - Specified by:
parallelDistributionin interfaceLongCacheStream- Returns:
- a stream with parallel distribution enabled.
-
filterKeySegments
Description copied from interface:LongCacheStreamFilters 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<Long,LongStream> - Specified by:
filterKeySegmentsin interfaceLongCacheStream- 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
Description copied from interface:BaseCacheStreamFilters 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<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
Description copied from interface:LongCacheStreamFilters 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<Long,LongStream> - Specified by:
filterKeysin interfaceLongCacheStream- Parameters:
keys- The keys that this stream will only operate on.- Returns:
- a stream with the keys filtered.
-
distributedBatchSize
Description copied from interface:LongCacheStreamControls 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<Long,LongStream> - Specified by:
distributedBatchSizein interfaceLongCacheStream- Parameters:
batchSize- The size of each batch. This defaults to the state transfer chunk size.- Returns:
- a stream with the batch size updated
-
segmentCompletionListener
public LongCacheStream segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener) Description copied from interface:LongCacheStreamAllows 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<Long,LongStream> - Specified by:
segmentCompletionListenerin interfaceLongCacheStream- Parameters:
listener- The listener that will be called back as segments are completed.- Returns:
- a stream with the listener registered.
-
disableRehashAware
Description copied from interface:LongCacheStreamDisables 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<Long,LongStream> - Specified by:
disableRehashAwarein interfaceLongCacheStream- Returns:
- a stream with rehash awareness disabled.
-
timeout
Description copied from interface:LongCacheStreamSets 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<Long,LongStream> - Specified by:
timeoutin interfaceLongCacheStream- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- a stream with the timeout set
-
cacheStream
-
doubleCacheStream
-
intCacheStream
-