-
Notifications
You must be signed in to change notification settings - Fork 347
Add MapAggregator to compose tuples of (key, agg) pairs #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I could be wrong about this but I think it would be more usable if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests would be more informative if there were different aggregators used for each key. It would also be a better test if the aggregators had different intermediate types (like, the B in the agg's A, B, C type params).
|
+1 to Avi's suggestion. Also, not that it is super important: but are you planning to use this or is it just a nice generalization? The reason I ask is that I'm surprised that the result type (V is the map) is homogenous across a wide variety of aggregations. Of course, Double might be common enough. |
|
Yeah, |
Add a MapAggregator to join tuples of (K, Aggregator[A, Bn, C]) pairs into a composed Aggregator[A, TupleN[B1,...,BN], Map[K, C]].
f43f662 to
0ee74aa
Compare
|
Totally convinced, made the suggested changes! cc @mlmanapat |
Add MapAggregator to compose tuples of (key, agg) pairs
|
Thanks, @DanielleSucher! |
|
For consistency/simplicity-of-use, we're missing the ability to generate Tuple or Map aggregator from one entry... at the moment we'he hacked up this: /**
* makes an aggregator returning a Tuple1[Metric]
* this allows to keep aggregator definition consistent with GeneratedTupleAggregator.fromN
*/
def tupleAggrFrom1[A, B, C](agg: Aggregator[A, B, C]): Aggregator[A, B, scala.Tuple1[C]] = {
agg.andThenPresent(Tuple1(_))
}
// for the MapAggregator
def mapAggrFrom1[A, B, C <: AnyVal](aggDef: (String, Aggregator[A, B, C])): Aggregator[A, B, Map[String, AnyVal]] = {
val (key, agg) = aggDef
agg.andThenPresent(value => Map(key -> value))
}
it would be nice to have these methods in |
Add a MapAggregator to join tuples of (K, Aggregator[A, Bn, C]) pairs
into a composed Aggregator[A, TupleN[B1,...,BN], Map[K, C]].
cc @avibryant @mlmanapat