Package com.rpl.agentorama
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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder interface for configuring multi-aggregators. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic MultiAgg.Implcreate()Creates a new multi-aggregator instance.static <S> MultiAgg.Implinit(com.rpl.rama.ops.RamaFunction0<S> impl) Creates a multi-aggregator with an initial value function.static <S> MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for zero arguments.static <S,T0> MultiAgg.Impl Creates a multi-aggregator with a dispatch handler for one argument.static <S,T0, T1>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for two arguments.static <S,T0, T1, T2>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for three arguments.static <S,T0, T1, T2, T3>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for four arguments.static <S,T0, T1, T2, T3, T4>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for five arguments.static <S,T0, T1, T2, T3, T4, T5>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for six arguments.static <S,T0, T1, T2, T3, T4, T5, T6>
MultiAgg.ImplCreates a multi-aggregator with a dispatch handler for seven arguments.
-
Method Details
-
create
Creates a new multi-aggregator instance.- Returns:
- a new multi-aggregator builder
-
init
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
Creates a multi-aggregator with a dispatch handler for zero arguments.- Parameters:
name- the dispatch target nameimpl- the handler function that takes the current aggregation value plus zero arguments- Returns:
- a multi-aggregator builder with the handler set
-
on
Creates a multi-aggregator with a dispatch handler for one argument.- Parameters:
name- the dispatch target nameimpl- 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, MultiAgg.Impl onT1> (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 nameimpl- 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, MultiAgg.Impl onT1, T2> (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 nameimpl- 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, MultiAgg.Impl onT1, T2, T3> (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 nameimpl- 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, MultiAgg.Impl onT1, T2, T3, T4> (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 nameimpl- 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, MultiAgg.Impl onT1, T2, T3, T4, T5> (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 nameimpl- 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, MultiAgg.Impl onT1, T2, T3, T4, T5, T6> (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 nameimpl- the handler function that takes the current aggregation value plus seven arguments- Returns:
- a multi-aggregator builder with the handler set
-