Skip to content
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

TypedPipe.from(List).distinct fails #935

Merged
merged 3 commits into from
Jul 3, 2014
Merged

Conversation

jcoveney
Copy link
Contributor

@jcoveney jcoveney commented Jul 3, 2014

This is a PR to surface an issue, and I will work on the fix.

This was brought up on the mailing list -- TypedPipe.from(List("a","b","c")).distinct doesn't work, but TypedPipe.from(List("a","b","c")).distinctBy(identity) does.

Note: we may want to remove the 2 test cases that pass, since it's just more overhead. On the other hand, they do all share one cluster so the cost isn't TOO high and it does make the issue clear and prevent other regressions.

@@ -522,7 +522,7 @@ final case class IterablePipe[T](iterable: Iterable[T],
.getOrElse(EmptyValue()(fd, mode))

override def sumByLocalKeys[K, V](implicit ev: T <:< (K, V), sg: Semigroup[V]) =
IterablePipe(MapAlgebra.sumByKey(iterable.map(ev(_))), fd, mode)
IterablePipe(iterable.map(ev(_)).groupBy(_._1).mapValues(_.map(_._2).reduce(sg.plus(_, _))), fd, mode)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think mapValues(sg.sumOption(_).get) should work here. The empty case does not come up: each key has at least one value.

johnynek added a commit that referenced this pull request Jul 3, 2014
@johnynek johnynek merged commit 230db43 into develop Jul 3, 2014
@johnynek johnynek deleted the jco/typed_pipe_from_list branch July 3, 2014 20:22
@johnynek
Copy link
Collaborator

johnynek commented Jul 3, 2014

If you want to do the sumOption, that's fine too, but this is green, and since this in-memory lists are probably not huge, it's fine if this does not make it into scalding 0.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants