Given a sequence of data as
, aggregate it into a value of monoidal type M
Given a sequence of data as
, aggregate it into a value of monoidal type M
Aggregation has two equivalent definitions:
aggregate(as) = monoid.combineAll(as.map(mf)) // The "map-reduce" definition
aggregate(as) = as.foldLeft(monoid.empty)(lff) // The "left-folding" definition
The left-folding definition is more efficient in general, and desirable for objects
implementing the Aggregator
trait when possible.
http://erikerlandson.github.io/blog/2016/09/05/expressing-map-reduce-as-a-left-folding-monoid
Return the left-folding function for this aggregator.
Return the left-folding function for this aggregator.
The function lff
obeys the properties:
lff(m, d) = monoid.combine(m, lff(monoid.empty, d))
lff(m, d) = monoid.combine(m, mf(d))
Return the mapping function for this aggregator.
Return the mapping function for this aggregator.
The function mf
obeys the properties:
monoid.combine(m, mf(d)) = lff(m, d)
Return the object defining the monoidal properties on type M
Defines aggregation (aka map-reduce) on a monoidal aggregating type
M
and data typeD