Original - original stream typepublic class DistributedLongCacheStream<Original> extends AbstractCacheStream<Original,Long,LongStream,LongCacheStream> implements 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.LongStream.BuilderBaseCacheStream.SegmentCompletionListenercloseRunnable, 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 |
DistributedLongCacheStream(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, IntStream etc.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
allMatch(LongPredicate predicate) |
boolean |
anyMatch(LongPredicate predicate) |
DoubleCacheStream |
asDoubleStream() |
OptionalDouble |
average() |
CacheStream<Long> |
boxed() |
protected <R> DistributedCacheStream<Original,R> |
cacheStream() |
<R> R |
collect(Supplier<R> supplier,
ObjLongConsumer<R> accumulator,
BiConsumer<R,R> combiner) |
long |
count() |
LongCacheStream |
disableRehashAware()
Disables tracking of rehash events that could occur to the underlying cache.
|
LongCacheStream |
distinct() |
LongCacheStream |
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() |
LongCacheStream |
filter(LongPredicate predicate) |
LongCacheStream |
filter(SerializableLongPredicate predicate)
Same as
LongCacheStream.filter(LongPredicate) except that the LongPredicate must also
implement Serializable. |
LongCacheStream |
filterKeys(Set<?> keys)
Filters which entries are returned by only returning ones that map to the given key.
|
LongCacheStream |
filterKeySegments(IntSet segments)
Filters which entries are returned by what segment they are present in.
|
LongCacheStream |
filterKeySegments(Set<Integer> segments)
Filters which entries are returned by what segment they are present in.
|
OptionalLong |
findAny() |
OptionalLong |
findFirst() |
LongCacheStream |
flatMap(LongFunction<? extends LongStream> mapper) |
LongCacheStream |
flatMap(SerializableLongFunction<? extends LongStream> mapper)
Same as
LongCacheStream.flatMap(LongFunction) except that the LongFunction must also
implement Serializable. |
void |
forEach(LongConsumer action) |
<K,V> void |
forEach(ObjLongConsumer<Cache<K,V>> action)
Same as
LongStream.forEach(LongConsumer) except that it takes an ObjLongConsumer that
provides access to the underlying Cache that is backing this stream. |
void |
forEach(SerializableLongConsumer action)
Same as
LongStream.forEach(LongConsumer) except that the LongConsumer must also
implement Serializable. |
<K,V> void |
forEach(SerializableObjLongConsumer<Cache<K,V>> action)
Same as
LongCacheStream.forEach(ObjLongConsumer) except that the BiConsumer must also implement
Serializable |
void |
forEachOrdered(LongConsumer action) |
protected Log |
getLog() |
protected DistributedIntCacheStream<Original> |
intCacheStream() |
PrimitiveIterator.OfLong |
iterator() |
LongCacheStream |
limit(long maxSize) |
LongCacheStream |
map(LongUnaryOperator mapper) |
LongCacheStream |
map(SerializableLongUnaryOperator mapper)
Same as
LongCacheStream.map(LongUnaryOperator) except that the LongUnaryOperator must also
implement Serializable. |
DoubleCacheStream |
mapToDouble(LongToDoubleFunction mapper) |
DoubleCacheStream |
mapToDouble(SerializableLongToDoubleFunction mapper)
Same as
LongCacheStream.mapToDouble(LongToDoubleFunction) except that the LongToLongFunction must also
implement Serializable. |
IntCacheStream |
mapToInt(LongToIntFunction mapper) |
IntCacheStream |
mapToInt(SerializableLongToIntFunction mapper)
Same as
LongCacheStream.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 as
LongCacheStream.mapToObj(LongFunction) except that the LongFunction must also
implement Serializable. |
OptionalLong |
max() |
OptionalLong |
min() |
boolean |
noneMatch(LongPredicate predicate) |
LongCacheStream |
parallelDistribution()
This would enable sending requests to all other remote nodes when a terminal operator is performed.
|
LongCacheStream |
peek(LongConsumer action) |
LongCacheStream |
peek(SerializableLongConsumer action)
Same as
LongCacheStream.flatMap(LongFunction) except that the LongFunction must also
implement Serializable. |
OptionalLong |
reduce(LongBinaryOperator op) |
long |
reduce(long identity,
LongBinaryOperator op) |
LongCacheStream |
segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)
Allows registration of a segment completion listener that is notified when a segment has completed
processing.
|
LongCacheStream |
sequentialDistribution()
This would disable sending requests to all other remote nodes compared to one at a time.
|
LongCacheStream |
skip(long n) |
LongCacheStream |
sorted() |
Spliterator.OfLong |
spliterator() |
long |
sum() |
LongSummaryStatistics |
summaryStatistics() |
LongCacheStream |
timeout(long timeout,
TimeUnit unit)
Sets a given time to wait for a remote operation to respond by.
|
long[] |
toArray() |
protected LongCacheStream |
unwrap() |
addIntermediateOperation, addIntermediateOperation, addIntermediateOperationMap, close, composeWithExceptions, isParallel, isPrimaryOwner, onClose, parallel, sequential, unorderedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitallMatch, anyMatch, collect, noneMatch, onClose, parallel, reduce, reduce, sequential, unorderedbuilder, concat, empty, generate, iterate, of, of, range, rangeClosedclose, isParallelprotected DistributedLongCacheStream(AbstractCacheStream other)
other - other instance of AbstractCacheStream to copy details fromprotected Log getLog()
getLog in class AbstractCacheStream<Original,Long,LongStream,LongCacheStream>protected LongCacheStream unwrap()
unwrap in class AbstractCacheStream<Original,Long,LongStream,LongCacheStream>public LongCacheStream filter(LongPredicate predicate)
LongCacheStreamfilter in interface LongStreamfilter in interface LongCacheStreampublic LongCacheStream filter(SerializableLongPredicate predicate)
LongCacheStreamLongCacheStream.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.
filter in interface LongCacheStreampredicate - a non-interfering, stateless
predicate to apply to each element to determine if it
should be includedpublic LongCacheStream map(LongUnaryOperator mapper)
LongCacheStreammap in interface LongStreammap in interface LongCacheStreampublic LongCacheStream map(SerializableLongUnaryOperator mapper)
LongCacheStreamLongCacheStream.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.
map in interface LongCacheStreammapper - a non-interfering, stateless
function to apply to each elementpublic <U> CacheStream<U> mapToObj(LongFunction<? extends U> mapper)
LongCacheStreammapToObj in interface LongStreammapToObj in interface LongCacheStreampublic <U> CacheStream<U> mapToObj(SerializableLongFunction<? extends U> mapper)
LongCacheStreamLongCacheStream.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.
mapToObj in interface LongCacheStreamU - the element type of the new streammapper - a non-interfering, stateless
function to apply to each elementpublic IntCacheStream mapToInt(LongToIntFunction mapper)
LongCacheStreammapToInt in interface LongStreammapToInt in interface LongCacheStreampublic IntCacheStream mapToInt(SerializableLongToIntFunction mapper)
LongCacheStreamLongCacheStream.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.
mapToInt in interface LongCacheStreammapper - a non-interfering, stateless
function to apply to each elementpublic DoubleCacheStream mapToDouble(LongToDoubleFunction mapper)
LongCacheStreammapToDouble in interface LongStreammapToDouble in interface LongCacheStreampublic DoubleCacheStream mapToDouble(SerializableLongToDoubleFunction mapper)
LongCacheStreamLongCacheStream.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.
mapToDouble in interface LongCacheStreammapper - a non-interfering, stateless
function to apply to each elementpublic LongCacheStream flatMap(LongFunction<? extends LongStream> mapper)
LongCacheStreamflatMap in interface LongStreamflatMap in interface LongCacheStreampublic LongCacheStream flatMap(SerializableLongFunction<? extends LongStream> mapper)
LongCacheStreamLongCacheStream.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.
flatMap in interface LongCacheStreammapper - a non-interfering, stateless
function to apply to each element which produces a
LongStream of new valuespublic LongCacheStream distinct()
LongCacheStreamdistinct in interface LongStreamdistinct in interface LongCacheStreampublic LongCacheStream sorted()
LongCacheStreamsorted in interface LongStreamsorted in interface LongCacheStreampublic LongCacheStream peek(LongConsumer action)
LongCacheStreampeek in interface LongStreampeek in interface LongCacheStreampublic LongCacheStream peek(SerializableLongConsumer action)
LongCacheStreamLongCacheStream.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.
peek in interface LongCacheStreamaction - a non-interfering action to perform on the elements as
they are consumed from the streampublic DoubleCacheStream asDoubleStream()
LongCacheStreamasDoubleStream in interface LongStreamasDoubleStream in interface LongCacheStreampublic CacheStream<Long> boxed()
LongCacheStreamboxed in interface LongStreamboxed in interface LongCacheStreampublic LongCacheStream limit(long maxSize)
LongCacheStreamlimit in interface LongStreamlimit in interface LongCacheStreampublic LongCacheStream skip(long n)
LongCacheStreamskip in interface LongStreamskip in interface LongCacheStreampublic void forEach(LongConsumer action)
forEach in interface LongStreampublic void forEach(SerializableLongConsumer action)
LongCacheStreamLongStream.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.
forEach in interface LongCacheStreamaction - a non-interfering action to perform on the elementspublic <K,V> void forEach(ObjLongConsumer<Cache<K,V>> action)
LongCacheStreamLongStream.forEach(LongConsumer) except that it takes an ObjLongConsumer 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 LongCacheStreamK - key type of the cacheV - value type of the cacheaction - consumer to be ran for each element in the streampublic <K,V> void forEach(SerializableObjLongConsumer<Cache<K,V>> action)
LongCacheStreamLongCacheStream.forEach(ObjLongConsumer) except that the BiConsumer must also implement
SerializableforEach in interface LongCacheStreamK - key type of the cacheV - value type of the cacheaction - consumer to be ran for each element in the streampublic void forEachOrdered(LongConsumer action)
forEachOrdered in interface LongStreampublic long[] toArray()
toArray in interface LongStreampublic long reduce(long identity,
LongBinaryOperator op)
reduce in interface LongStreampublic OptionalLong reduce(LongBinaryOperator op)
reduce in interface LongStreampublic <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R,R> combiner)
collect in interface LongStreampublic long sum()
sum in interface LongStreampublic OptionalLong min()
min in interface LongStreampublic OptionalLong max()
max in interface LongStreampublic OptionalDouble average()
average in interface LongStreampublic LongSummaryStatistics summaryStatistics()
summaryStatistics in interface LongStreampublic boolean anyMatch(LongPredicate predicate)
anyMatch in interface LongStreampublic boolean allMatch(LongPredicate predicate)
allMatch in interface LongStreampublic boolean noneMatch(LongPredicate predicate)
noneMatch in interface LongStreampublic OptionalLong findFirst()
findFirst in interface LongStreampublic OptionalLong findAny()
findAny in interface LongStreampublic PrimitiveIterator.OfLong iterator()
iterator in interface BaseStream<Long,LongStream>iterator in interface LongStreampublic Spliterator.OfLong spliterator()
spliterator in interface BaseStream<Long,LongStream>spliterator in interface LongStreampublic long count()
count in interface LongStreampublic LongCacheStream sequentialDistribution()
LongCacheStreamParallel distribution is enabled by default except for CacheStream.iterator() and
CacheStream.spliterator()
sequentialDistribution in interface BaseCacheStream<Long,LongStream>sequentialDistribution in interface LongCacheStreampublic LongCacheStream parallelDistribution()
BaseCacheStreamParallel distribution is enabled by default except for CacheStream.iterator() and
CacheStream.spliterator()
parallelDistribution in interface BaseCacheStream<Long,LongStream>parallelDistribution in interface LongCacheStreampublic LongCacheStream filterKeySegments(Set<Integer> segments)
LongCacheStreamCacheStream.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<Long,LongStream>filterKeySegments in interface LongCacheStreamsegments - The segments to use for this stream operation. Any segments not in this set will be ignored.public LongCacheStream filterKeySegments(IntSet segments)
BaseCacheStreamCacheStream.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<Long,LongStream>segments - The segments to use for this stream operation. Any segments not in this set will be ignored.public LongCacheStream filterKeys(Set<?> keys)
LongCacheStreamCacheStream.filter(Predicate) if the filter is holding references to the same
keys.filterKeys in interface BaseCacheStream<Long,LongStream>filterKeys in interface LongCacheStreamkeys - The keys that this stream will only operate on.public LongCacheStream distributedBatchSize(int batchSize)
LongCacheStreamCacheStream.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<Long,LongStream>distributedBatchSize in interface LongCacheStreambatchSize - The size of each batch. This defaults to the state transfer chunk size.public LongCacheStream segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)
LongCacheStreamThis 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<Long,LongStream>segmentCompletionListener in interface LongCacheStreamlistener - The listener that will be called back as segments are completed.public LongCacheStream disableRehashAware()
LongCacheStreamMost 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<Long,LongStream>disableRehashAware in interface LongCacheStreampublic LongCacheStream timeout(long timeout, TimeUnit unit)
LongCacheStreamIf 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<Long,LongStream>timeout in interface LongCacheStreamtimeout - the maximum time to waitunit - the time unit of the timeout argumentprotected <R> DistributedCacheStream<Original,R> cacheStream()
protected DistributedDoubleCacheStream<Original> doubleCacheStream()
protected DistributedIntCacheStream<Original> intCacheStream()
Copyright © 2022 JBoss by Red Hat. All rights reserved.