GitHub user zsxwing opened a pull request:

    https://github.com/apache/spark/pull/3262

    [SPARK-4397][Core] Reorganize 'implicit's to improve the API convenience

    This PR moved `implicit`s to `package object` and `companion object` to 
enable the Scala compiler search them automatically without explicit importing.
    
    It should not break any API. I compiled the following codes with Spark 
1.1.0:
    ```scala
    import org.apache.spark.{SparkContext, SparkConf}
    import org.apache.spark.SparkContext._
    
    object ImplicitBackforwardCompatibilityApp {
      def main(args: Array[String]): Unit = {
        val conf = new 
SparkConf().setAppName("ImplicitBackforwardCompatibilityApp")
        val sc = new SparkContext(conf)
    
        val rdd = sc.parallelize(1 to 100).map(i => (i, i))
        val rdd2 = rdd.groupByKey() // rddToPairRDDFunctions
        val rdd3 = rdd2.sortByKey() // rddToOrderedRDDFunctions
        val s1 = rdd3.map(_._1).stats() // numericRDDToDoubleRDDFunctions
        println(s1)
        val s2 = rdd3.map(_._1.toDouble).stats() // 
doubleRDDToDoubleRDDFunctions
        println(s2)
        val f = rdd2.countAsync() // rddToAsyncRDDActions
        println(f.get())
        rdd2.map { case (k, v) => (k, v.size) } 
saveAsSequenceFile("/tmp/test_path") // rddToSequenceFileRDDFunctions
    
        val a1 = sc.accumulator(123.4) // DoubleAccumulatorParam
        a1.add(1.0)
        println(a1.value)
        val a2 = sc.accumulator(123) // IntAccumulatorParam
        a2.add(3)
        println(a2.value)
        val a3 = sc.accumulator(123L) // LongAccumulatorParam
        a3.add(11L)
        println(a3.value)
        val a4 = sc.accumulator(123F) // FloatAccumulatorParam
        a4.add(1.1F)
        println(a4.value)
    
        sc.stop()
      }
    }
    ```
    And run it with this PR. It ran correctly.
    
    However, for `WritableConverter`, I cannot make it work without `import`. 
Thoughts?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zsxwing/spark SPARK-4397

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/3262.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3262
    
----
commit 1eda9e4921617bc71acf2bb502cf3a22ee43c41f
Author: zsxwing <[email protected]>
Date:   2014-11-14T07:35:02Z

    Reorganize 'implicit's to improve the API convenience

----


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