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.

public abstract class ReduceApiProcessor<O,R> extends Object
A parallel operation that returns a result.
  • Constructor Details

    • ReduceApiProcessor

      public ReduceApiProcessor()
      Instantiate a new ReduceApiProcessor.
  • Method Details

    • accumulatorFactory

      public abstract R accumulatorFactory()
      Constructs an instance of a ReduceApiProcessor that will be passed to each invocation of evaluate(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 parameter ReduceApiProcessor accumulator, and returns the accumulated result.
      Parameters:
      context - the ApiProcessingContext.
      accumulator - the accumulator of previous results.
      sossObject - the SOSS object.
      parameter - the serialized parameter object, or null.
      Returns:
      a EvalResult with the accumulator with the new result merged in and a ProcessingResult. Use ProcessingResult.DoUpdate if the object was mutated, ProcessingResult.NoUpdate if the object was not-mutated, or ProcessingResult.Remove if the object should be deleted from ScaleOut.
    • reduce

      public abstract R reduce(R result1, R result2)
      Reduces two results into one and returns the reduced result.
      Parameters:
      result1 - the first result.
      result2 - the second result.
      Returns:
      the merged result.
    • deserializeResult

      public abstract R deserializeResult(byte[] value)
      Deserializes a result object into a ReduceApiProcessor.
      Parameters:
      value - the serialized result value.
      Returns:
      an instance of ReduceApiProcessor hydrated from the parameter value.
    • serializeResult

      public abstract byte[] serializeResult(R value)
      Serializes a ReduceApiProcessor into a byte[].
      Parameters:
      value - the result object to serialize.
      Returns:
      the serialized result.