Class DistributedDoubleCacheStream<Original>
- Type Parameters:
Original
- original stream type
- All Implemented Interfaces:
AutoCloseable
,BaseStream<Double,
,DoubleStream> DoubleStream
,BaseCacheStream<Double,
,DoubleStream> DoubleCacheStream
DoubleStream
that utilizes a lazily evaluated distributed back end execution. Note this
class is only able to be created using CacheStream.mapToDouble(ToDoubleFunction)
or similar
methods from the CacheStream
interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.BaseCacheStream
BaseCacheStream.SegmentCompletionListener
Nested classes/interfaces inherited from interface java.util.stream.DoubleStream
DoubleStream.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
ModifierConstructorDescriptionprotected
This constructor is to be used only when a user calls a map or flat map method changing to a DoubleStream from a CacheStream, Stream, IntStream, LongStream etc. -
Method Summary
Modifier and TypeMethodDescriptionboolean
allMatch
(DoublePredicate predicate) boolean
anyMatch
(DoublePredicate predicate) average()
boxed()
protected <R> DistributedCacheStream
<Original, R> <R> R
collect
(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) long
count()
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
(DoublePredicate predicate) filter
(SerializableDoublePredicate predicate) Same asDoubleCacheStream.filter(DoublePredicate)
except that the DoublePredicate must also implementSerializable
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
(DoubleFunction<? extends DoubleStream> mapper) flatMap
(SerializableDoubleFunction<? extends DoubleStream> mapper) Same asDoubleCacheStream.flatMap(DoubleFunction)
except that the DoubleFunction must also implementSerializable
void
forEach
(DoubleConsumer action) <K,
V> void forEach
(ObjDoubleConsumer<Cache<K, V>> action) Same asDoubleStream.forEach(DoubleConsumer)
except that it takes anObjDoubleConsumer
that provides access to the underlyingCache
that is backing this stream.void
forEach
(SerializableDoubleConsumer action) Same asDoubleStream.forEach(DoubleConsumer)
except that the DoubleConsumer must also implementSerializable
<K,
V> void forEach
(SerializableObjDoubleConsumer<Cache<K, V>> action) Same asDoubleCacheStream.forEach(ObjDoubleConsumer)
except that theBiConsumer
must also implementSerializable
void
forEachOrdered
(DoubleConsumer action) protected org.infinispan.util.logging.Log
getLog()
protected DistributedIntCacheStream
<Original> iterator()
limit
(long maxSize) protected DistributedLongCacheStream
<Original> map
(DoubleUnaryOperator mapper) map
(SerializableDoubleUnaryOperator mapper) Same asDoubleCacheStream.map(DoubleUnaryOperator)
except that the DoubleUnaryOperator must also implementSerializable
mapToInt
(DoubleToIntFunction mapper) Same asDoubleCacheStream.mapToInt(DoubleToIntFunction)
except that the DoubleToIntFunction must also implementSerializable
mapToLong
(DoubleToLongFunction mapper) Same asDoubleCacheStream.mapToLong(DoubleToLongFunction)
except that the DoubleToLongFunction must also implementSerializable
<U> CacheStream
<U> mapToObj
(DoubleFunction<? extends U> mapper) <U> CacheStream
<U> mapToObj
(SerializableDoubleFunction<? extends U> mapper) Same asDoubleCacheStream.mapToObj(DoubleFunction)
except that the DoubleFunction must also implementSerializable
max()
min()
boolean
noneMatch
(DoublePredicate predicate) This would enable sending requests to all other remote nodes when a terminal operator is performed.peek
(DoubleConsumer action) peek
(SerializableDoubleConsumer action) Same asDoubleCacheStream.flatMap(DoubleFunction)
except that the DoubleFunction must also implementSerializable
double
reduce
(double identity, DoubleBinaryOperator 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()
double
sum()
Sets a given time to wait for a remote operation to respond by.double[]
toArray()
protected DoubleCacheStream
unwrap()
Methods inherited from class org.infinispan.stream.impl.AbstractCacheStream
addIntermediateOperation, addIntermediateOperation, addIntermediateOperationMap, close, composeWithExceptions, isParallel, isPrimaryOwner, onClose, parallel, sequential, unordered
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.stream.BaseStream
close, isParallel
Methods inherited from interface org.infinispan.DoubleCacheStream
allMatch, anyMatch, collect, noneMatch, onClose, parallel, reduce, reduce, sequential, unordered
Methods inherited from interface java.util.stream.DoubleStream
dropWhile, takeWhile
-
Constructor Details
-
DistributedDoubleCacheStream
This constructor is to be used only when a user calls a map or flat map method changing to a DoubleStream from a CacheStream, Stream, IntStream, LongStream etc.- Parameters:
other
- other instance ofAbstractCacheStream
to copy details from
-
-
Method Details
-
getLog
protected org.infinispan.util.logging.Log getLog()- Specified by:
getLog
in classAbstractCacheStream<Original,
Double, DoubleStream, DoubleCacheStream>
-
unwrap
- Specified by:
unwrap
in classAbstractCacheStream<Original,
Double, DoubleStream, DoubleCacheStream>
-
filter
Description copied from interface:DoubleCacheStream
- Specified by:
filter
in interfaceDoubleCacheStream
- Specified by:
filter
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
filter
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.filter(DoublePredicate)
except that the DoublePredicate must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
filter
in interfaceDoubleCacheStream
- Parameters:
predicate
- a non-interfering, stateless predicate to apply to each element to determine if it should be included- Returns:
- the new cache double stream
-
map
Description copied from interface:DoubleCacheStream
- Specified by:
map
in interfaceDoubleCacheStream
- Specified by:
map
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
map
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.map(DoubleUnaryOperator)
except that the DoubleUnaryOperator must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
map
in interfaceDoubleCacheStream
- Parameters:
mapper
- a non-interfering, stateless function to apply to each element- Returns:
- the new cache double stream
-
mapToObj
Description copied from interface:DoubleCacheStream
- Specified by:
mapToObj
in interfaceDoubleCacheStream
- Specified by:
mapToObj
in interfaceDoubleStream
- Returns:
- the new cache stream
-
mapToObj
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.mapToObj(DoubleFunction)
except that the DoubleFunction must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
mapToObj
in interfaceDoubleCacheStream
- 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:DoubleCacheStream
- Specified by:
mapToInt
in interfaceDoubleCacheStream
- Specified by:
mapToInt
in interfaceDoubleStream
- Returns:
- the new cache int stream
-
mapToInt
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.mapToInt(DoubleToIntFunction)
except that the DoubleToIntFunction must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
mapToInt
in interfaceDoubleCacheStream
- Parameters:
mapper
- a non-interfering, stateless function to apply to each element- Returns:
- the new cache int stream
-
mapToLong
Description copied from interface:DoubleCacheStream
- Specified by:
mapToLong
in interfaceDoubleCacheStream
- Specified by:
mapToLong
in interfaceDoubleStream
- Returns:
- the new cache long stream
-
mapToLong
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.mapToLong(DoubleToLongFunction)
except that the DoubleToLongFunction must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
mapToLong
in interfaceDoubleCacheStream
- Parameters:
mapper
- a non-interfering, stateless function to apply to each element- Returns:
- the new cache long stream
-
flatMap
Description copied from interface:DoubleCacheStream
- Specified by:
flatMap
in interfaceDoubleCacheStream
- Specified by:
flatMap
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
flatMap
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.flatMap(DoubleFunction)
except that the DoubleFunction must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
flatMap
in interfaceDoubleCacheStream
- Parameters:
mapper
- a non-interfering, stateless function to apply to each element which produces aDoubleStream
of new values- Returns:
- the new cache double stream
-
distinct
Description copied from interface:DoubleCacheStream
- Specified by:
distinct
in interfaceDoubleCacheStream
- Specified by:
distinct
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
sorted
Description copied from interface:DoubleCacheStream
- Specified by:
sorted
in interfaceDoubleCacheStream
- Specified by:
sorted
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
peek
Description copied from interface:DoubleCacheStream
- Specified by:
peek
in interfaceDoubleCacheStream
- Specified by:
peek
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
peek
Description copied from interface:DoubleCacheStream
Same asDoubleCacheStream.flatMap(DoubleFunction)
except that the DoubleFunction must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
peek
in interfaceDoubleCacheStream
- Parameters:
action
- a non-interfering action to perform on the elements as they are consumed from the stream- Returns:
- the new cache double stream
-
limit
Description copied from interface:DoubleCacheStream
- Specified by:
limit
in interfaceDoubleCacheStream
- Specified by:
limit
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
skip
Description copied from interface:DoubleCacheStream
- Specified by:
skip
in interfaceDoubleCacheStream
- Specified by:
skip
in interfaceDoubleStream
- Returns:
- the new cache double stream
-
boxed
Description copied from interface:DoubleCacheStream
- Specified by:
boxed
in interfaceDoubleCacheStream
- Specified by:
boxed
in interfaceDoubleStream
- Returns:
- the new cache stream containing doubles
-
forEach
- Specified by:
forEach
in interfaceDoubleStream
-
forEach
Description copied from interface:DoubleCacheStream
Same asDoubleStream.forEach(DoubleConsumer)
except that the DoubleConsumer must also implementSerializable
The compiler will pick this overload for lambda parameters, making them
Serializable
- Specified by:
forEach
in interfaceDoubleCacheStream
- Parameters:
action
- a non-interfering action to perform on the elements
-
forEach
Description copied from interface:DoubleCacheStream
Same asDoubleStream.forEach(DoubleConsumer)
except that it takes anObjDoubleConsumer
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.- Specified by:
forEach
in interfaceDoubleCacheStream
- 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:DoubleCacheStream
Same asDoubleCacheStream.forEach(ObjDoubleConsumer)
except that theBiConsumer
must also implementSerializable
- Specified by:
forEach
in interfaceDoubleCacheStream
- 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:
forEachOrdered
in interfaceDoubleStream
-
toArray
public double[] toArray()- Specified by:
toArray
in interfaceDoubleStream
-
reduce
- Specified by:
reduce
in interfaceDoubleStream
-
reduce
- Specified by:
reduce
in interfaceDoubleStream
-
collect
public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) - Specified by:
collect
in interfaceDoubleStream
-
sum
public double sum()- Specified by:
sum
in interfaceDoubleStream
-
min
- Specified by:
min
in interfaceDoubleStream
-
max
- Specified by:
max
in interfaceDoubleStream
-
average
- Specified by:
average
in interfaceDoubleStream
-
summaryStatistics
- Specified by:
summaryStatistics
in interfaceDoubleStream
-
anyMatch
- Specified by:
anyMatch
in interfaceDoubleStream
-
allMatch
- Specified by:
allMatch
in interfaceDoubleStream
-
noneMatch
- Specified by:
noneMatch
in interfaceDoubleStream
-
findFirst
- Specified by:
findFirst
in interfaceDoubleStream
-
findAny
- Specified by:
findAny
in interfaceDoubleStream
-
iterator
- Specified by:
iterator
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
iterator
in interfaceDoubleStream
-
spliterator
- Specified by:
spliterator
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
spliterator
in interfaceDoubleStream
-
count
public long count()- Specified by:
count
in interfaceDoubleStream
-
sequentialDistribution
Description copied from interface:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
sequentialDistribution
in interfaceDoubleCacheStream
- Returns:
- a stream with parallel distribution disabled.
-
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<Double,
DoubleStream> - Specified by:
parallelDistribution
in interfaceDoubleCacheStream
- Returns:
- a stream with parallel distribution enabled.
-
filterKeySegments
Description copied from interface:DoubleCacheStream
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:
filterKeySegments
in interfaceBaseCacheStream<Double,
DoubleStream> - Specified by:
filterKeySegments
in interfaceDoubleCacheStream
- 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:BaseCacheStream
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:
filterKeySegments
in interfaceBaseCacheStream<Double,
DoubleStream> - 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:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
filterKeys
in interfaceDoubleCacheStream
- Parameters:
keys
- The keys that this stream will only operate on.- Returns:
- a stream with the keys filtered.
-
distributedBatchSize
Description copied from interface:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
distributedBatchSize
in interfaceDoubleCacheStream
- 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 DoubleCacheStream segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener) Description copied from interface:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
segmentCompletionListener
in interfaceDoubleCacheStream
- 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:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
disableRehashAware
in interfaceDoubleCacheStream
- Returns:
- a stream with rehash awareness disabled.
-
timeout
Description copied from interface:DoubleCacheStream
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<Double,
DoubleStream> - Specified by:
timeout
in interfaceDoubleCacheStream
- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Returns:
- a stream with the timeout set
-
cacheStream
-
intCacheStream
-
longCacheStream
-