Class AbstractForEachOperation<Original,K,V,S extends BaseStream<V,S>>
- java.lang.Object
-
- org.infinispan.stream.impl.termop.BaseTerminalOperation<Original>
-
- org.infinispan.stream.impl.termop.AbstractForEachOperation<Original,K,V,S>
-
- Type Parameters:
Original
- original stream typeK
- key type of underlying streamV
- value type of transformed streamS
- type of the transformed stream
- All Implemented Interfaces:
KeyTrackingTerminalOperation<Original,K,V>
,SegmentAwareOperation
- Direct Known Subclasses:
ForEachBiOperation
,ForEachFlatMapDoubleOperation
,ForEachFlatMapIntOperation
,ForEachFlatMapLongOperation
,ForEachFlatMapObjDoubleOperation
,ForEachFlatMapObjIntOperation
,ForEachFlatMapObjLongOperation
,ForEachOperation
public abstract class AbstractForEachOperation<Original,K,V,S extends BaseStream<V,S>> extends BaseTerminalOperation<Original> implements KeyTrackingTerminalOperation<Original,K,V>
This is a base operation class for the use of the for each terminal operator. This class can be used for any forEach configuration, however since it relies on generics it may not be as performant as a primitive based for each operation. This class assumes the stream is composed ofMap.Entry
instances where the key is typed the same as defined K type.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.stream.impl.KeyTrackingTerminalOperation
KeyTrackingTerminalOperation.IntermediateCollector<C>
-
-
Field Summary
-
Fields inherited from class org.infinispan.stream.impl.termop.BaseTerminalOperation
intermediateOperations, supplier
-
-
Constructor Summary
Constructors Constructor Description AbstractForEachOperation(Iterable<IntermediateOperation> intermediateOperations, Supplier<Stream<Original>> supplier, Function<? super Original,? extends K> toKeyFunction, int batchSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getBatchSize()
Function<? super Original,? extends K>
getToKeyFunction()
protected abstract void
handleList(List<V> list)
protected abstract void
handleStreamForEach(S stream, List<V> list)
boolean
lostSegment(boolean stopIfLost)
This method will be invoked when the operation is known to be performing on a given set of segments and this node no longer owns 1 or many of them.Collection<K>
performForEachOperation(KeyTrackingTerminalOperation.IntermediateCollector<Collection<K>> response)
Invoked when a key and rehash aware operation is desired.List<V>
performOperation(KeyTrackingTerminalOperation.IntermediateCollector<Collection<V>> response)
Invoked when a key aware operation is desired without rehash being enabled.-
Methods inherited from class org.infinispan.stream.impl.termop.BaseTerminalOperation
getIntermediateOperations, handleInjection, setSupplier
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.stream.impl.KeyTrackingTerminalOperation
handleInjection, setSupplier
-
-
-
-
Method Detail
-
lostSegment
public boolean lostSegment(boolean stopIfLost)
Description copied from interface:SegmentAwareOperation
This method will be invoked when the operation is known to be performing on a given set of segments and this node no longer owns 1 or many of them. Returns whether the lost segment affected the results or not. If stopIfLost is true then doneWithOperation will not be invoked as it would normally.- Specified by:
lostSegment
in interfaceSegmentAwareOperation
- Parameters:
stopIfLost
- argument to tell the operation that if this segment affects that it should not perform any more operations if possible as all segments have been lost.- Returns:
- whether or not this operation was affected by the loss of segments
-
performOperation
public List<V> performOperation(KeyTrackingTerminalOperation.IntermediateCollector<Collection<V>> response)
Description copied from interface:KeyTrackingTerminalOperation
Invoked when a key aware operation is desired without rehash being enabled.- Specified by:
performOperation
in interfaceKeyTrackingTerminalOperation<Original,K,V>
- Parameters:
response
- the collector that will be called back for any intermediate results- Returns:
- the final response from the remote node
-
performForEachOperation
public Collection<K> performForEachOperation(KeyTrackingTerminalOperation.IntermediateCollector<Collection<K>> response)
Description copied from interface:KeyTrackingTerminalOperation
Invoked when a key and rehash aware operation is desired.- Specified by:
performForEachOperation
in interfaceKeyTrackingTerminalOperation<Original,K,V>
- Parameters:
response
- the collector that will be called back for any intermediate results- Returns:
- the final response from the remote node
-
getBatchSize
public int getBatchSize()
-
-