Class ConditionalCollector<T,A,R>
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.ConditionalCollector<T,A,R>
-
- Type Parameters:
T- the type of input elements to the reduction operationA- the mutable accumulation type of the reduction operation (often hidden as an implementation detail)R- the result type of the reduction operation
- All Implemented Interfaces:
Task.Collector<T,List<T>,R>,com.tangosol.io.ExternalizableLite,com.tangosol.io.pof.PortableObject,Serializable
public class ConditionalCollector<T,A,R> extends Object implements Task.Collector<T,List<T>,R>, com.tangosol.io.pof.PortableObject
ATask.Collectorthat conditionally collects values based on the available result.- Since:
- 21.12
- Author:
- bo
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Task.Collector<T,A,R>m_collectorTheTask.Collectorto use when theRemote.Predicateis satisfied.protected Rm_defaultResultThe default result to return when theRemote.Predicateis not satisfied.protected com.tangosol.util.function.Remote.Predicate<? super Iterator<T>>m_predicateTheRemote.Predicateto determine when results can be collected.
-
Constructor Summary
Constructors Constructor Description ConditionalCollector()For serialization.ConditionalCollector(com.tangosol.util.function.Remote.Predicate<? super Iterator<T>> predicate, Task.Collector<? super T,A,R> collector, R defaultResult)Constructs aConditionalCollector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BiConsumer<List<T>,T>accumulator()A function that foldsTaskresults into a mutable result container.com.tangosol.util.function.Remote.Predicate<List<T>>finishable()ARemote.Predicateto determine if a result container can be finished early avoiding further accumulation of results using the container.Function<List<T>,R>finisher()Perform the final transformation from the intermediate accumulation type A to the final result type R.voidreadExternal(com.tangosol.io.pof.PofReader in)voidreadExternal(DataInput in)Supplier<List<T>>supplier()A function that creates and returns a new mutable result container.voidwriteExternal(com.tangosol.io.pof.PofWriter out)voidwriteExternal(DataOutput out)
-
-
-
Field Detail
-
m_predicate
protected com.tangosol.util.function.Remote.Predicate<? super Iterator<T>> m_predicate
TheRemote.Predicateto determine when results can be collected.
-
m_collector
protected Task.Collector<T,A,R> m_collector
TheTask.Collectorto use when theRemote.Predicateis satisfied.
-
m_defaultResult
protected R m_defaultResult
The default result to return when theRemote.Predicateis not satisfied.
-
-
Constructor Detail
-
ConditionalCollector
public ConditionalCollector()
For serialization.
-
ConditionalCollector
public ConditionalCollector(com.tangosol.util.function.Remote.Predicate<? super Iterator<T>> predicate, Task.Collector<? super T,A,R> collector, R defaultResult)
Constructs aConditionalCollector.- Parameters:
predicate- theRemote.Predicateto determine if collection should occurcollector- theTask.Collectorto use when theRemote.Predicateis satisfieddefaultResult- the default result to use when theRemote.Predicateis not satisfied
-
-
Method Detail
-
accumulator
public BiConsumer<List<T>,T> accumulator()
Description copied from interface:Task.CollectorA function that foldsTaskresults into a mutable result container.- Specified by:
accumulatorin interfaceTask.Collector<T,A,R>- Returns:
- a function that folds
Taskresults into a mutable result container
-
finishable
public com.tangosol.util.function.Remote.Predicate<List<T>> finishable()
Description copied from interface:Task.CollectorARemote.Predicateto determine if a result container can be finished early avoiding further accumulation of results using the container.Should there be no further results to accumulate, finishing the result container with the
Task.Collector.finisher()will occur regardless of the result returned by theRemote.Predicate.- Specified by:
finishablein interfaceTask.Collector<T,A,R>- Returns:
- a
Remote.Predicate
-
finisher
public Function<List<T>,R> finisher()
Description copied from interface:Task.CollectorPerform the final transformation from the intermediate accumulation type A to the final result type R.- Specified by:
finisherin interfaceTask.Collector<T,A,R>- Returns:
- a function which transforms the intermediate result to the final result
-
supplier
public Supplier<List<T>> supplier()
Description copied from interface:Task.CollectorA function that creates and returns a new mutable result container.- Specified by:
supplierin interfaceTask.Collector<T,A,R>- Returns:
- a function which returns a new mutable result container
-
readExternal
public void readExternal(DataInput in) throws IOException
- Specified by:
readExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
- Specified by:
writeExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
readExternal
public void readExternal(com.tangosol.io.pof.PofReader in) throws IOException- Specified by:
readExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
writeExternal
public void writeExternal(com.tangosol.io.pof.PofWriter out) throws IOException- Specified by:
writeExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
-