Class ReduceApiProcessor<O,R>
java.lang.Object
com.scaleoutsoftware.modules.abstractions.ReduceApiProcessor<O,R>
- Type Parameters:
O- the SOSS object type.R- the result object type.
A parallel operation that returns a result.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract RConstructs an instance of aReduceApiProcessorthat will be passed to each invocation ofevaluate(ApiProcessingContext, Object, Object, byte[]).abstract RdeserializeResult(byte[] value) Deserializes a result object into aReduceApiProcessor.abstract EvalResult<R> evaluate(ApiProcessingContext<O> context, R accumulator, O sossObject, byte[] parameter) Evaluates a SOSS object, merges the result into the parameterReduceApiProcessoraccumulator, and returns the accumulated result.abstract RReduces two results into one and returns the reduced result.abstract byte[]serializeResult(R value) Serializes aReduceApiProcessorinto a byte[].
-
Constructor Details
-
ReduceApiProcessor
public ReduceApiProcessor()Instantiate a new ReduceApiProcessor.
-
-
Method Details
-
accumulatorFactory
Constructs an instance of aReduceApiProcessorthat will be passed to each invocation ofevaluate(ApiProcessingContext, Object, Object, byte[]).- Returns:
- an instance of
ReduceApiProcessor.
-
evaluate
public abstract EvalResult<R> evaluate(ApiProcessingContext<O> context, R accumulator, O sossObject, byte[] parameter) Evaluates a SOSS object, merges the result into the parameterReduceApiProcessoraccumulator, and returns the accumulated result.- Parameters:
context- theApiProcessingContext.accumulator- the accumulator of previous results.sossObject- the SOSS object.parameter- the serialized parameter object, or null.- Returns:
- a
EvalResultwith the accumulator with the new result merged in and aProcessingResult. UseProcessingResult.DoUpdateif the object was mutated,ProcessingResult.NoUpdateif the object was not-mutated, orProcessingResult.Removeif the object should be deleted from ScaleOut.
-
reduce
Reduces two results into one and returns the reduced result.- Parameters:
result1- the first result.result2- the second result.- Returns:
- the merged result.
-
deserializeResult
Deserializes a result object into aReduceApiProcessor.- Parameters:
value- the serialized result value.- Returns:
- an instance of
ReduceApiProcessorhydrated from the parameter value.
-
serializeResult
Serializes aReduceApiProcessorinto a byte[].- Parameters:
value- the result object to serialize.- Returns:
- the serialized result.
-