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.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 |
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, 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 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)
LongCacheStream
filter
in interface LongStream
filter
in interface LongCacheStream
public LongCacheStream filter(SerializableLongPredicate predicate)
LongCacheStream
LongCacheStream.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 LongCacheStream
predicate
- a non-interfering, stateless
predicate to apply to each element to determine if it
should be includedpublic LongCacheStream map(LongUnaryOperator mapper)
LongCacheStream
map
in interface LongStream
map
in interface LongCacheStream
public LongCacheStream map(SerializableLongUnaryOperator mapper)
LongCacheStream
LongCacheStream.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 LongCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic <U> CacheStream<U> mapToObj(LongFunction<? extends U> mapper)
LongCacheStream
mapToObj
in interface LongStream
mapToObj
in interface LongCacheStream
public <U> CacheStream<U> mapToObj(SerializableLongFunction<? extends U> mapper)
LongCacheStream
LongCacheStream.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 LongCacheStream
U
- the element type of the new streammapper
- a non-interfering, stateless
function to apply to each elementpublic IntCacheStream mapToInt(LongToIntFunction mapper)
LongCacheStream
mapToInt
in interface LongStream
mapToInt
in interface LongCacheStream
public IntCacheStream mapToInt(SerializableLongToIntFunction mapper)
LongCacheStream
LongCacheStream.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 LongCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic DoubleCacheStream mapToDouble(LongToDoubleFunction mapper)
LongCacheStream
mapToDouble
in interface LongStream
mapToDouble
in interface LongCacheStream
public DoubleCacheStream mapToDouble(SerializableLongToDoubleFunction mapper)
LongCacheStream
LongCacheStream.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 LongCacheStream
mapper
- a non-interfering, stateless
function to apply to each elementpublic LongCacheStream flatMap(LongFunction<? extends LongStream> mapper)
LongCacheStream
flatMap
in interface LongStream
flatMap
in interface LongCacheStream
public LongCacheStream flatMap(SerializableLongFunction<? extends LongStream> mapper)
LongCacheStream
LongCacheStream.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 LongCacheStream
mapper
- a non-interfering, stateless
function to apply to each element which produces a
LongStream
of new valuespublic LongCacheStream distinct()
LongCacheStream
distinct
in interface LongStream
distinct
in interface LongCacheStream
public LongCacheStream sorted()
LongCacheStream
sorted
in interface LongStream
sorted
in interface LongCacheStream
public LongCacheStream peek(LongConsumer action)
LongCacheStream
peek
in interface LongStream
peek
in interface LongCacheStream
public LongCacheStream peek(SerializableLongConsumer action)
LongCacheStream
LongCacheStream.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 LongCacheStream
action
- a non-interfering action to perform on the elements as
they are consumed from the streampublic DoubleCacheStream asDoubleStream()
LongCacheStream
asDoubleStream
in interface LongStream
asDoubleStream
in interface LongCacheStream
public CacheStream<Long> boxed()
LongCacheStream
boxed
in interface LongStream
boxed
in interface LongCacheStream
public LongCacheStream limit(long maxSize)
LongCacheStream
limit
in interface LongStream
limit
in interface LongCacheStream
public LongCacheStream skip(long n)
LongCacheStream
skip
in interface LongStream
skip
in interface LongCacheStream
public void forEach(LongConsumer action)
forEach
in interface LongStream
public void forEach(SerializableLongConsumer action)
LongCacheStream
LongStream.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 LongCacheStream
action
- a non-interfering action to perform on the elementspublic <K,V> void forEach(ObjLongConsumer<Cache<K,V>> action)
LongCacheStream
LongStream.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 LongCacheStream
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(SerializableObjLongConsumer<Cache<K,V>> action)
LongCacheStream
LongCacheStream.forEach(ObjLongConsumer)
except that the BiConsumer
must also implement
Serializable
forEach
in interface LongCacheStream
K
- 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 LongStream
public long[] toArray()
toArray
in interface LongStream
public long reduce(long identity, LongBinaryOperator op)
reduce
in interface LongStream
public OptionalLong reduce(LongBinaryOperator op)
reduce
in interface LongStream
public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R,R> combiner)
collect
in interface LongStream
public long sum()
sum
in interface LongStream
public OptionalLong min()
min
in interface LongStream
public OptionalLong max()
max
in interface LongStream
public OptionalDouble average()
average
in interface LongStream
public LongSummaryStatistics summaryStatistics()
summaryStatistics
in interface LongStream
public boolean anyMatch(LongPredicate predicate)
anyMatch
in interface LongStream
public boolean allMatch(LongPredicate predicate)
allMatch
in interface LongStream
public boolean noneMatch(LongPredicate predicate)
noneMatch
in interface LongStream
public OptionalLong findFirst()
findFirst
in interface LongStream
public OptionalLong findAny()
findAny
in interface LongStream
public PrimitiveIterator.OfLong iterator()
iterator
in interface BaseStream<Long,LongStream>
iterator
in interface LongStream
public Spliterator.OfLong spliterator()
spliterator
in interface BaseStream<Long,LongStream>
spliterator
in interface LongStream
public long count()
count
in interface LongStream
public LongCacheStream sequentialDistribution()
LongCacheStream
Parallel distribution is enabled by default except for CacheStream.iterator()
and
CacheStream.spliterator()
sequentialDistribution
in interface BaseCacheStream<Long,LongStream>
sequentialDistribution
in interface LongCacheStream
public LongCacheStream parallelDistribution()
BaseCacheStream
Parallel distribution is enabled by default except for CacheStream.iterator()
and
CacheStream.spliterator()
parallelDistribution
in interface BaseCacheStream<Long,LongStream>
parallelDistribution
in interface LongCacheStream
public LongCacheStream filterKeySegments(Set<Integer> segments)
LongCacheStream
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<Long,LongStream>
filterKeySegments
in interface LongCacheStream
segments
- The segments to use for this stream operation. Any segments not in this set will be ignored.public LongCacheStream 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<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)
LongCacheStream
CacheStream.filter(Predicate)
if the filter is holding references to the same
keys.filterKeys
in interface BaseCacheStream<Long,LongStream>
filterKeys
in interface LongCacheStream
keys
- The keys that this stream will only operate on.public LongCacheStream distributedBatchSize(int batchSize)
LongCacheStream
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<Long,LongStream>
distributedBatchSize
in interface LongCacheStream
batchSize
- The size of each batch. This defaults to the state transfer chunk size.public LongCacheStream segmentCompletionListener(BaseCacheStream.SegmentCompletionListener listener)
LongCacheStream
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<Long,LongStream>
segmentCompletionListener
in interface LongCacheStream
listener
- The listener that will be called back as segments are completed.public LongCacheStream disableRehashAware()
LongCacheStream
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<Long,LongStream>
disableRehashAware
in interface LongCacheStream
public LongCacheStream timeout(long timeout, TimeUnit unit)
LongCacheStream
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<Long,LongStream>
timeout
in interface LongCacheStream
timeout
- 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 © 2021 JBoss by Red Hat. All rights reserved.