Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3740#discussion_r22127764
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -1174,7 +1174,19 @@ abstract class RDD[T: ClassTag](
        * Save this RDD as a text file, using string representations of 
elements.
        */
       def saveAsTextFile(path: String) {
    -    this.map(x => (NullWritable.get(), new Text(x.toString)))
    +    // https://issues.apache.org/jira/browse/SPARK-2075
    +    // NullWritable is a Comparable rather than Comparable[NullWritable] 
in Hadoop 1.+,
    +    // so the compiler cannot find an implicit Ordering for it and will 
use the default `null`.
    +    // It will generate different anonymous classes for `saveAsTextFile` 
in Hadoop 1.+ and
    +    // Hadoop 2.+. Therefore, here we provide an Ordering for NullWritable 
so that the compiler
    +    // will generate same bytecode.
    +    val nullWritableOrdering = new Ordering[NullWritable] {
    +      override def compare(x: NullWritable, y: NullWritable): Int = 0
    +    }
    +    val nullWritableClassTag = implicitly[ClassTag[NullWritable]]
    +    val textClassTag = implicitly[ClassTag[Text]]
    +    val r = this.map(x => (NullWritable.get(), new Text(x.toString)))
    --- End diff --
    
    here can be reused too


---
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]

Reply via email to