Interface MultiAgg


public interface MultiAgg
Creates an aggregator for use with aggregation nodes that supports multiple dispatch targets. MultiAgg provides dispatch-based aggregation where different values are processed by different aggregation functions based on a dispatch key. The first argument when emitting to the aggregation node is the dispatch target, which runs the corresponding handler. Example usage:

 MultiAgg.Impl agg = MultiAgg.create()
     .init(() -> Map.of("sum", 0, "texts", new ArrayList<>()))
     .on("add", (acc, value) -> {
         Map<String, Object> newAcc = new HashMap<>(acc);
         newAcc.put("sum", (Integer) newAcc.get("sum") + (Integer) value);
         return newAcc;
     })
     .on("text", (acc, text) -> {
         Map<String, Object> newAcc = new HashMap<>(acc);
         ((List<String>) newAcc.get("texts")).add((String) text);
         return newAcc;
     });
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder interface for configuring multi-aggregators.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    Creates a new multi-aggregator instance.
    static <S> MultiAgg.Impl
    init(com.rpl.rama.ops.RamaFunction0<S> impl)
    Creates a multi-aggregator with an initial value function.
    static <S> MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction1<S,Object> impl)
    Creates a multi-aggregator with a dispatch handler for zero arguments.
    static <S, T0> MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction2<S,T0,Object> impl)
    Creates a multi-aggregator with a dispatch handler for one argument.
    static <S, T0, T1>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction3<S,T0,T1,Object> impl)
    Creates a multi-aggregator with a dispatch handler for two arguments.
    static <S, T0, T1, T2>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction4<S,T0,T1,T2,Object> impl)
    Creates a multi-aggregator with a dispatch handler for three arguments.
    static <S, T0, T1, T2, T3>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction5<S,T0,T1,T2,T3,Object> impl)
    Creates a multi-aggregator with a dispatch handler for four arguments.
    static <S, T0, T1, T2, T3, T4>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction6<S,T0,T1,T2,T3,T4,Object> impl)
    Creates a multi-aggregator with a dispatch handler for five arguments.
    static <S, T0, T1, T2, T3, T4, T5>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction7<S,T0,T1,T2,T3,T4,T5,Object> impl)
    Creates a multi-aggregator with a dispatch handler for six arguments.
    static <S, T0, T1, T2, T3, T4, T5, T6>
    MultiAgg.Impl
    on(String name, com.rpl.rama.ops.RamaFunction8<S,T0,T1,T2,T3,T4,T5,T6,Object> impl)
    Creates a multi-aggregator with a dispatch handler for seven arguments.
  • Method Details

    • create

      static MultiAgg.Impl create()
      Creates a new multi-aggregator instance.
      Returns:
      a new multi-aggregator builder
    • init

      static <S> MultiAgg.Impl init(com.rpl.rama.ops.RamaFunction0<S> impl)
      Creates a multi-aggregator with an initial value function.
      Parameters:
      impl - function that returns the initial aggregation value
      Returns:
      a multi-aggregator builder with the initial value set
    • on

      static <S> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction1<S,Object> impl)
      Creates a multi-aggregator with a dispatch handler for zero arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus zero arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction2<S,T0,Object> impl)
      Creates a multi-aggregator with a dispatch handler for one argument.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus one argument
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction3<S,T0,T1,Object> impl)
      Creates a multi-aggregator with a dispatch handler for two arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus two arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1, T2> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction4<S,T0,T1,T2,Object> impl)
      Creates a multi-aggregator with a dispatch handler for three arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus three arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1, T2, T3> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction5<S,T0,T1,T2,T3,Object> impl)
      Creates a multi-aggregator with a dispatch handler for four arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus four arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1, T2, T3, T4> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction6<S,T0,T1,T2,T3,T4,Object> impl)
      Creates a multi-aggregator with a dispatch handler for five arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus five arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1, T2, T3, T4, T5> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction7<S,T0,T1,T2,T3,T4,T5,Object> impl)
      Creates a multi-aggregator with a dispatch handler for six arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus six arguments
      Returns:
      a multi-aggregator builder with the handler set
    • on

      static <S, T0, T1, T2, T3, T4, T5, T6> MultiAgg.Impl on(String name, com.rpl.rama.ops.RamaFunction8<S,T0,T1,T2,T3,T4,T5,T6,Object> impl)
      Creates a multi-aggregator with a dispatch handler for seven arguments.
      Parameters:
      name - the dispatch target name
      impl - the handler function that takes the current aggregation value plus seven arguments
      Returns:
      a multi-aggregator builder with the handler set