Like calling andThen on the present function
This may error if inputs are empty (for Monoid Aggregators it never will, instead you see present(Monoid.zero[B])
This returns the cumulative sum of its inputs, in the same order.
This returns the cumulative sum of its inputs, in the same order. If the inputs are empty, the result will be empty too.
This returns None if the inputs are empty
Like calling compose on the prepare function
This returns the cumulative sum of its inputs, in the same order.
This returns the cumulative sum of its inputs, in the same order. If the inputs are empty, the result will be empty too.
This allows you to run two aggregators on the same data with a single pass
This may error if items is empty.
This may error if items is empty. To be safe you might use reduceOption if you don't know that items is non-empty
combine two inner values
This is the safe version of the above.
This is the safe version of the above. If the input in empty, return None, else reduce the items
An Aggregator can be converted to a Fold, but not vice-versa Note, a Fold is more constrained so only do this if you require joining a Fold with an Aggregator to produce a Fold
This allows you to join two aggregators into one that takes a tuple input, which in turn allows you to chain .composePrepare onto the result if you have an initial input that has to be prepared differently for each of the joined aggregators.
This allows you to join two aggregators into one that takes a tuple input, which in turn allows you to chain .composePrepare onto the result if you have an initial input that has to be prepared differently for each of the joined aggregators.
The law here is: ag1.zip(ag2).apply(as.zip(bs)) == (ag1(as), ag2(bs))
This is a type that models map/reduce(map). First each item is mapped, then we reduce with a semigroup, then finally we present the results.
Unlike Fold, Aggregator keeps it's middle aggregation type externally visible. This is because Aggregators are useful in parallel map/reduce systems where there may be some additional types needed to cross the map/reduce boundary (such a serialization and intermediate storage). If you don't care about the middle type, an _ may be used and the main utility of the instance is still preserved (e.g. def operate[T](ag: Aggregator[T, _, Int]): Int)
Note, join is very useful to combine multiple aggregations with one pass. Also GeneratedTupleAggregator.fromN((agg1, agg2, ... aggN)) can glue these together well.
This type is the the Fold.M from Haskell's fold package: https://hackage.haskell.org/package/folds-0.6.2/docs/Data-Fold-M.html