This aggregator batches up agg
so that all the addition can be performed at once.
This aggregator batches up agg
so that all the addition can be performed at once.
It is useful when sumOption
is much faster than using plus
(e.g. when there is temporary mutable
state used to make summation fast).
Constructed a batch from a single value.
Compacting monoid for batched values.
Compacting monoid for batched values.
This monoid ensures that the batch's tree structure has fewer than batchSize
values in it. When more
values are added, the tree is compacted using m
.
It's worth noting that x + 0
here will produce the same sum as x
, but .toList
will produce
different lists (one will have an extra zero).
Compacting semigroup for batched values.
Compacting semigroup for batched values.
This semigroup ensures that the batch's tree structure has fewer than batchSize
values in it. When more
values are added, the tree is compacted using s
.
Equivalence for batches.
Equivalence for batches.
Batches are equivalent if they sum to the same value. Since the free semigroup is associative, it's not correct to take tree structure into account when determining equality.
One thing to note here is that two equivalent batches might produce different lists (for instance, if one of the batches has more zeros in it than another one).
Constructed an optional batch from a collection of values.
Constructed an optional batch from a collection of values.
Since batches cannot be empty, this method returns None
if ts
is empty, and Some(batch)
otherwise.
This monoid aggregator batches up agg
so that all the addition can be performed at once.
This monoid aggregator batches up agg
so that all the addition can be performed at once.
It is useful when sumOption
is much faster than using plus
(e.g. when there is temporary mutable
state used to make summation fast).
The free semigroup for batched values.
The free semigroup for batched values.
This semigroup just accumulates batches and doesn't ever evaluate them to flatten the tree.