-
Notifications
You must be signed in to change notification settings - Fork 708
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
Scala implicit ordering fun -- have 2 forms of sketch, defaulting to … #1535
base: develop
Are you sure you want to change the base?
Conversation
@@ -119,6 +119,67 @@ object TypedPipe extends Serializable { | |||
override def hash(x: Int): Int = x | |||
} | |||
} | |||
implicit class HigherPriorityTypedPipeMethods[T, K, V](val tp: TypedPipe[T])(implicit ev: TypedPipe[T] <:< TypedPipe[(K, V)], |
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.
Can only enter an implicit class if you meet all of its criteria
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.
can we drop T
entirely here and just do (K, V)
?
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.
Looks like the tests here pass with that yep
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.
can we just do SketchJoinMethods
similar to https://github.com/twitter/scalding/blob/ianoc/addSketchOrderedSerializationInterface/scalding-core/src/main/scala/com/twitter/scalding/typed/TypedPipe.scala#L92 so we can fix (K, V)
and simpify a bit
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.
We can put the classes somewhere else, but I think to keep the same sort of source feel/compatibility we need this low priority implicit stuff to fall back to the old one. If we would be happy to make it disappear in the event of no matching signature i think we can just do 2 implicit methods in the object pointing at 2 classes (in sketched.scala) containing the sketch method of the 2 signatures.
looks good to me modulo the naming (I would use names for classes more specific to SketchJoin) |
👍 I like this. You can use the OrderedSerialization macros, not have an implicit conversion in scope and do a more efficient join at the same time. Seems like a win. |
what do you think of this @rubanm @isnotinvain ? I like not having to set up an implicit conversion and the ability to use compiler generated serializers. |
.write(TypedText.tsv[(Int, Int, Int)]("output-join")) | ||
} | ||
|
||
class BothAvailableSketchMethodsTypedSketchLeftJoinJob(args: Args) extends Job(args) { |
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.
This job looks unused in the test specs below.
|
…the existing
@johnynek as we were discussing for the sketch method. More of a consideration than hard PR