Github user massie commented on the pull request:
https://github.com/apache/spark/pull/7403#issuecomment-122134441
There is another approach that would work here too.
Currently, `RDD` has following implicit method for the PairRDDFunctions...
```scala
object RDD {
def rddToPairRDDFunctions[K, V](rdd: RDD[(K, V)])
(implicit kt: ClassTag[K], vt:
ClassTag[V], ord: Ordering[K] = null): PairRDDFunctions[K, V] = {
new PairRDDFunctions(rdd)
}
```
Code compiled with this looks like the following,
```
val rdd: com.github.massie.RDD = new
com.github.massie.RDD((ClassTag.apply(classOf[scala.Tuple2]):
scala.reflect.ClassTag));
massie.this.RDD.rddToPairRDDFunctions(rdd,
(ClassTag.apply(classOf[java.lang.String]): scala.reflect.ClassTag),
(ClassTag.apply(classOf[java.lang.String]): scala.reflect.ClassTag),
scala.math.Ordering$String).combineByKey()
```
To keep binary compatibility, we just need to keep the
`rrdToPairRDDFunctions`, remove the implicit and create a new implicit, e.g.
```scala
object RDD {
def rddToPairRDDFunctions[K, V](rdd: RDD[(K, V)])
(implicit kt: ClassTag[K], vt:
ClassTag[V], ord: Ordering[K] = null): PairRDDFunctions[K, V] = {
new PairRDDFunctions(rdd)
}
implicit def rddToNewPairRDDFunctions[K, V](rdd: RDD[(K, V)])
(implicit kt: ClassTag[K], vt:
ClassTag[V], ord: Ordering[K] = null): NewPairRDDFunctions[K, V] = {
new NewPairRDDFunctions(rdd)
}
...
}
```
Old code will still run since the `rddToPairRDDFunction` exists and
`PairRDDFunctions` has not been modified. New code will build against the new
`NewPairRDDFunctions` class which included the `ClassTag` information in the
`combineByKey` methods.
As a small side note, the `PairRDDFunctions` would wrap the
`NewPairRDDFunctions` so even though we don't have copy-paste. The
`combineByKey` functions in `PairRDDFunctions` would pass in a null ClassTag.
That means that old applications will work as before, but not provide combiner
class information to the shuffle.
The advantage of this approach is that the method names rename the same (no
need for a `combineByKey2` or whatever).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]