Original
- original stream typepublic class DistributedIntCacheStream<Original> extends AbstractCacheStream<Original,Integer,IntStream,IntCacheStream> implements IntCacheStream
IntStream
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.IntStream.Builder
BaseCacheStream.SegmentCompletionListener
closeRunnable, cpm, distributedBatchSize, dm, executor, includeLoader, intermediateOperations, invocationContext, iteratorOperation, keyPartitioner, keysToFilter, localAddress, parallel, parallelDistribution, partition, registry, rehashAware, segmentCompletionListener, segmentsToFilter, stateTransferLock, supplier, timeout, timeoutUnit, toKeyFunction
Modifier | Constructor and Description |
---|---|
protected |
DistributedIntCacheStream(AbstractCacheStream other)
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, LongStream etc.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allMatch(IntPredicate predicate) |
boolean |
anyMatch(IntPredicate predicate) |
DoubleCacheStream |
asDoubleStream() |
LongCacheStream |
asLongStream() |
OptionalDouble |
average() |
CacheStream<Integer> |
boxed() |
protected <R> DistributedCacheStream<Original,R> |
cacheStream() |
<R> R |
collect(Supplier<R> supplier,
ObjIntConsumer<R> accumulator,
BiConsumer<R,R> combiner) |
long |
count() |
IntCacheStream |
disableRehashAware()
Disables tracking of rehash events that could occur to the underlying cache.
|
IntCacheStream |
distinct() |
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.
|
protected DistributedDoubleCacheStream<Original> |
doubleCacheStream() |
IntCacheStream |
filter(IntPredicate predicate) |
IntCacheStream |
filter(SerializableIntPredicate predicate)
Same as
IntCacheStream.filter(IntPredicate) except that the IntPredicate must also
implement Serializable |
IntCacheStream |
filterKeys(Set<?> keys)
Filters which entries are returned by only returning ones that map to the given key.
|
IntCacheStream |
filterKeySegments(IntSet segments)
Filters which entries are returned by what segment they are present in.
|
IntCacheStream |
filterKeySegments(Set<Integer> segments)
Filters which entries are returned by what segment they are present in.
|
OptionalInt |
findAny() |
OptionalInt |
findFirst() |
IntCacheStream |
flatMap(IntFunction<? extends IntStream> mapper) |
IntCacheStream |
flatMap(SerializableIntFunction<? extends IntStream> mapper)
Same as
IntCacheStream.flatMap(IntFunction) except that the IntFunction must also
implement Serializable |
void |
forEach(IntConsumer action) |
<K,V> void |
forEach(ObjIntConsumer<Cache<K,V>> action)
Same as
IntStream.forEach(IntConsumer) except that it takes an ObjIntConsumer that
provides access to the underlying Cache that is backing this stream. |
void |
forEach(SerializableIntConsumer action)
Same as
IntStream.forEach(IntConsumer) except that the IntConsumer must also
implement Serializable |
<K,V> void |
forEach(SerializableObjIntConsumer<Cache<K,V>> action)
Same as
IntCacheStream.forEach(ObjIntConsumer) except that the BiConsumer must also implement
Serializable |
void |
forEachOrdered(IntConsumer action) |
protected Log |
getLog() |
PrimitiveIterator.OfInt |
iterator() |
IntCacheStream |
limit(long maxSize) |
protected DistributedLongCacheStream<Original> |
longCacheStream() |
IntCacheStream |
map(IntUnaryOperator mapper) |
IntCacheStream |
map(SerializableIntUnaryOperator mapper)
Same as
IntCacheStream.map(IntUnaryOperator) except that the IntUnaryOperator must also
implement Serializable |
DoubleCacheStream |
mapToDouble(IntToDoubleFunction mapper) |
DoubleCacheStream |
mapToDouble(SerializableIntToDoubleFunction mapper)
Same as
IntCacheStream.mapToDouble(IntToDoubleFunction) except that the IntToIntFunction must also
implement Serializable |
LongCacheStream |
mapToLong(IntToLongFunction mapper) |
LongCacheStream |
mapToLong(SerializableIntToLongFunction mapper)
Same as
IntCacheStream.mapToLong(IntToLongFunction) except that the IntToLongFunction must also
implement Serializable |
<U> CacheStream<U> |
mapToObj(IntFunction<? extends U> mapper) |
<U> CacheStream<U> |
mapToObj(SerializableIntFunction<? extends U> mapper)
Same as
IntCacheStream.mapToObj(IntFunction) except that the IntFunction must also
implement Serializable |
OptionalInt |
max() |
OptionalInt |
min() |
boolean |
noneMatch(IntPredicate predicate) |
IntCacheStream |
parallelDistribution()
This would enable sending requests to all other remote nodes when a terminal operator is performed.
|
IntCacheStream |
peek(IntConsumer action) |
IntCacheStream |
peek(SerializableIntConsumer action)
Same as
IntCacheStream.flatMap(IntFunction) except that the IntFunction must also
implement Serializable |
OptionalInt |
reduce(IntBinaryOperator op) |
int |
reduce(int identity,
IntBinaryOperator op) |
IntCacheStream |
segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)
Allows registration of a segment completion listener that is notified when a segment has completed
processing.
|
IntCacheStream |
sequentialDistribution()
This would disable sending requests to all other remote nodes compared to one at a time.
|
IntCacheStream |
skip(long n) |
IntCacheStream |
sorted() |
Spliterator.OfInt |
spliterator() |
int |
sum() |
IntSummaryStatistics |
summaryStatistics() |
IntCacheStream |
timeout(long timeout,
TimeUnit unit)
Sets a given time to wait for a remote operation to respond by.
|
int[] |
toArray() |
protected DistributedIntCacheStream |
unwrap() |
addIntermediateOperation, addIntermediateOperation, addIntermediateOperationMap, close, composeWithExceptions, isParallel, isPrimaryOwner, onClose, parallel, sequential, unordered
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allMatch, anyMatch, collect, noneMatch, onClose, parallel, reduce, reduce, sequential, unordered
builder, concat, empty, generate, iterate, of, of, range, rangeClosed
close, isParallel
protected DistributedIntCacheStream(AbstractCacheStream other)
other
- other instance of AbstractCacheStream
to copy details fromprotected Log getLog()
getLog
in class AbstractCacheStream<Original,Integer,IntStream,IntCacheStream>
protected DistributedIntCacheStream unwrap()
unwrap
in class AbstractCacheStream<Original,Integer,IntStream,IntCacheStream>
public IntCacheStream filter(IntPredicate predicate)
IntCacheStream
filter
in interface IntStream
filter
in interface IntCacheStream
public IntCacheStream filter(SerializableIntPredicate predicate)
IntCacheStream
IntCacheStream.filter(IntPredicate)
except that the IntPredicate must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
filter
in interface IntCacheStream
predicate
- a non-interfering, stateless
predicate to apply to each element to determine if it
should be includedpublic IntCacheStream map(IntUnaryOperator mapper)
IntCacheStream
map
in interface IntStream
map
in interface IntCacheStream
public IntCacheStream map(SerializableIntUnaryOperator mapper)
IntCacheStream
IntCacheStream.map(IntUnaryOperator)
except that the IntUnaryOperator must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
map
in interface IntCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic <U> CacheStream<U> mapToObj(IntFunction<? extends U> mapper)
IntCacheStream
mapToObj
in interface IntStream
mapToObj
in interface IntCacheStream
public <U> CacheStream<U> mapToObj(SerializableIntFunction<? extends U> mapper)
IntCacheStream
IntCacheStream.mapToObj(IntFunction)
except that the IntFunction must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
mapToObj
in interface IntCacheStream
U
- the element type of the new streammapper
- a non-interfering, stateless
function to apply to each elementpublic LongCacheStream mapToLong(IntToLongFunction mapper)
IntCacheStream
mapToLong
in interface IntStream
mapToLong
in interface IntCacheStream
public LongCacheStream mapToLong(SerializableIntToLongFunction mapper)
IntCacheStream
IntCacheStream.mapToLong(IntToLongFunction)
except that the IntToLongFunction must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
mapToLong
in interface IntCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic DoubleCacheStream mapToDouble(IntToDoubleFunction mapper)
IntCacheStream
mapToDouble
in interface IntStream
mapToDouble
in interface IntCacheStream
public DoubleCacheStream mapToDouble(SerializableIntToDoubleFunction mapper)
IntCacheStream
IntCacheStream.mapToDouble(IntToDoubleFunction)
except that the IntToIntFunction must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
mapToDouble
in interface IntCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic IntCacheStream flatMap(IntFunction<? extends IntStream> mapper)
IntCacheStream
flatMap
in interface IntStream
flatMap
in interface IntCacheStream
public IntCacheStream flatMap(SerializableIntFunction<? extends IntStream> mapper)
IntCacheStream
IntCacheStream.flatMap(IntFunction)
except that the IntFunction must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
flatMap
in interface IntCacheStream
mapper
- a non-interfering, stateless
function to apply to each element which produces a
IntStream
of new valuespublic IntCacheStream distinct()
IntCacheStream
distinct
in interface IntStream
distinct
in interface IntCacheStream
public IntCacheStream sorted()
IntCacheStream
sorted
in interface IntStream
sorted
in interface IntCacheStream
public IntCacheStream peek(IntConsumer action)
IntCacheStream
peek
in interface IntStream
peek
in interface IntCacheStream
public IntCacheStream peek(SerializableIntConsumer action)
IntCacheStream
IntCacheStream.flatMap(IntFunction)
except that the IntFunction must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
peek
in interface IntCacheStream
action
- a non-interfering action to perform on the elements as
they are consumed from the streampublic IntCacheStream limit(long maxSize)
IntCacheStream
limit
in interface IntStream
limit
in interface IntCacheStream
public IntCacheStream skip(long n)
IntCacheStream
skip
in interface IntStream
skip
in interface IntCacheStream
public LongCacheStream asLongStream()
IntCacheStream
asLongStream
in interface IntStream
asLongStream
in interface IntCacheStream
public DoubleCacheStream asDoubleStream()
IntCacheStream
asDoubleStream
in interface IntStream
asDoubleStream
in interface IntCacheStream
public CacheStream<Integer> boxed()
IntCacheStream
boxed
in interface IntStream
boxed
in interface IntCacheStream
public void forEach(IntConsumer action)
public void forEach(SerializableIntConsumer action)
IntCacheStream
IntStream.forEach(IntConsumer)
except that the IntConsumer must also
implement Serializable
The compiler will pick this overload for lambda parameters, making them Serializable
forEach
in interface IntCacheStream
action
- a non-interfering action to perform on the elementspublic <K,V> void forEach(ObjIntConsumer<Cache<K,V>> action)
IntCacheStream
IntStream.forEach(IntConsumer)
except that it takes an ObjIntConsumer
that
provides access to the underlying Cache
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.
forEach
in interface IntCacheStream
K
- key type of the cacheV
- value type of the cacheaction
- consumer to be ran for each element in the streampublic <K,V> void forEach(SerializableObjIntConsumer<Cache<K,V>> action)
IntCacheStream
IntCacheStream.forEach(ObjIntConsumer)
except that the BiConsumer
must also implement
Serializable
forEach
in interface IntCacheStream
K
- key type of the cacheV
- value type of the cacheaction
- consumer to be ran for each element in the streampublic void forEachOrdered(IntConsumer action)
forEachOrdered
in interface IntStream
public int reduce(int identity, IntBinaryOperator op)
public OptionalInt reduce(IntBinaryOperator op)
public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R,R> combiner)
public OptionalInt min()
public OptionalInt max()
public OptionalDouble average()
public IntSummaryStatistics summaryStatistics()
summaryStatistics
in interface IntStream
public boolean anyMatch(IntPredicate predicate)
public boolean allMatch(IntPredicate predicate)
public boolean noneMatch(IntPredicate predicate)
public OptionalInt findFirst()
public OptionalInt findAny()
public PrimitiveIterator.OfInt iterator()
public Spliterator.OfInt spliterator()
spliterator
in interface BaseStream<Integer,IntStream>
spliterator
in interface IntStream
public IntCacheStream sequentialDistribution()
IntCacheStream
Parallel distribution is enabled by default except for CacheStream.iterator()
and
CacheStream.spliterator()
sequentialDistribution
in interface BaseCacheStream<Integer,IntStream>
sequentialDistribution
in interface IntCacheStream
public IntCacheStream parallelDistribution()
BaseCacheStream
Parallel distribution is enabled by default except for CacheStream.iterator()
and
CacheStream.spliterator()
parallelDistribution
in interface BaseCacheStream<Integer,IntStream>
parallelDistribution
in interface IntCacheStream
public IntCacheStream filterKeySegments(Set<Integer> segments)
IntCacheStream
CacheStream.filter(Predicate)
method as this can control what nodes are
asked for data and what entries are read from the underlying CacheStore if present.filterKeySegments
in interface BaseCacheStream<Integer,IntStream>
filterKeySegments
in interface IntCacheStream
segments
- The segments to use for this stream operation. Any segments not in this set will be ignored.public IntCacheStream filterKeySegments(IntSet segments)
BaseCacheStream
CacheStream.filter(Predicate)
method as this can control what nodes are
asked for data and what entries are read from the underlying CacheStore if present.filterKeySegments
in interface BaseCacheStream<Integer,IntStream>
segments
- The segments to use for this stream operation. Any segments not in this set will be ignored.public IntCacheStream filterKeys(Set<?> keys)
IntCacheStream
CacheStream.filter(Predicate)
if the filter is holding references to the same
keys.filterKeys
in interface BaseCacheStream<Integer,IntStream>
filterKeys
in interface IntCacheStream
keys
- The keys that this stream will only operate on.public IntCacheStream distributedBatchSize(int batchSize)
IntCacheStream
CacheStream.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.
distributedBatchSize
in interface BaseCacheStream<Integer,IntStream>
distributedBatchSize
in interface IntCacheStream
batchSize
- The size of each batch. This defaults to the state transfer chunk size.public IntCacheStream segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)
IntCacheStream
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 see CacheStream.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.
segmentCompletionListener
in interface BaseCacheStream<Integer,IntStream>
segmentCompletionListener
in interface IntCacheStream
listener
- The listener that will be called back as segments are completed.public IntCacheStream disableRehashAware()
IntCacheStream
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.
disableRehashAware
in interface BaseCacheStream<Integer,IntStream>
disableRehashAware
in interface IntCacheStream
public IntCacheStream timeout(long timeout, TimeUnit unit)
IntCacheStream
If a timeout does occur then a TimeoutException
is thrown from the terminal
operation invoking thread or on the next call to the Iterator
or Spliterator
.
Note that if a rehash occurs this timeout value is reset for the subsequent retry if rehash aware is enabled.
timeout
in interface BaseCacheStream<Integer,IntStream>
timeout
in interface IntCacheStream
timeout
- the maximum time to waitunit
- the time unit of the timeout argumentprotected <R> DistributedCacheStream<Original,R> cacheStream()
protected DistributedDoubleCacheStream<Original> doubleCacheStream()
protected DistributedLongCacheStream<Original> longCacheStream()
Copyright © 2021 JBoss by Red Hat. All rights reserved.