com.rpl.rama.aggs

+and

(+and $$target *val)(+and *val :> *result)

Applies and operator to all input. Null or false values are considered “false”, and all other values are considered “true”. If all inputs are “true”, aggregates to last “true” value seen. If any input is “false”, aggregates to first “false” value seen. If no input, aggregates to boolean true.

+avg

(+avg *val :> *result)

Aggregates average of input. Cannot be used for aggregation into an existing PState.

+count

(+count $$target *val)(+count *val :> *result)

Aggregates count of values.

+first

(+first $$target *val)(+first *val :> *result)

Aggregates to the first input seen.

+last

(+last $$target *val)(+last *val :> *result)

Aggregates to the last input seen.

+limit

(+limit [amt] & vars)(+limit [amt] & vars :+options options-map)

Special combiner aggregator that limits incoming data to a fixed amount according to optional sort options. Only usable in batch blocks and operates during agg and post-agg phases. Output of aggregator is same as input but limited to the specified number.

Available options:

  • :sort: expression to sort emitted values by
  • :reverse?: if sort expression is specified, emits and limits by reverse order
  • :index-var: variable to bind the index of each emit

Examples:

(+limit [5] *v)
(+limit [10] *v1 *v2 :+options {:sort *v1 :reverse? true :index-var *i})
(+limit [100] *v1 *v2 *v3 :+options {:sort [*v3 *v1]})

+map-agg

(+map-agg $$target *key *val)(+map-agg *key *val :> *map)

Aggregates a map from key/value inputs

+max

(+max $$target *val)(+max *val :> *result)

Aggregates maximum value. Aggregates nil if no input.

+merge

(+merge $$target *map)(+merge *map :> *result-map)

Aggregates maps by merging them like Clojure’s merge function.

+min

(+min $$target *val)(+min *val :> *result)

Aggregates minimum value. Aggregates nil if no input.

+multi-set-agg

(+multi-set-agg $$target *val)(+multi-set-agg *val :> *map)

Aggregates values into a map from value to count.

+NONE

Aggregator version of NONE>, causing that element to be removed from that position.

Example:

(+compound $$p {*k (+NONE)})

+or

(+or $$target *val)(+or *val :> *result)

Applies or operator to all input. Null or boolean false values are considered “false”, and all other values are considered “true”. If any input is “true”, aggregates to first “true” value seen. If all inputs are “false”, aggregates to last “false” value seen. If no input, aggregates to boolean false.

+set-agg

(+set-agg $$target *val)(+set-agg *val :> *set)

Aggregates a set.

+set-remove-agg

(+set-remove-agg $$target *val)(+set-remove-agg *val :> *set)

Aggregator to remove an element from a set.

Example:

(+compound $$p {*k (+set-remove-agg *v)})

+sum

(+sum $$target *val)(+sum *val :> *result)

Aggregates sum of values.

+top-monotonic

(+top-monotonic [amt] *object :> *list)(+top-monotonic [amt] *object :+options options-map :> *list)(+top-monotonic [amt] $$target *object)(+top-monotonic [amt] $$target *object :+options options-map)

Aggregates input into list of top elements. See the extended documentation for more details.

Available options:

  • :id-fn: function to extract identifier from input objects so existing entities can be replaced during aggregation
  • :sort-val-fn: function to extract a sort val from input objects
  • :sort-type: can be :ascending or :descending (default)

Examples:

(+top-monotonic [10] *data :> *res :+options {:id-fn first :sort-val-fn second})
(+top-monotonic [10] $$topn *data :> *res :+options {:id-fn first :sort-val-fn second})
(+compound $$p {*k (+top-monotonic *data :+options {:id-fn first :sort-val-fn second})})

+vec-agg

(+vec-agg $$target *val)(+vec-agg *val :> *vector)

Aggregates a vector.