Uh oh!
There was an error while loading. Please reload this page.
[SPARK-4397][Core] Reorganize 'implicit's to improve the API convenience - #3262
[SPARK-4397][Core] Reorganize 'implicit's to improve the API convenience#3262zsxwing wants to merge 11 commits into
Conversation
zsxwing
commented
Nov 14, 2014
/cc @rxin |
SparkQA
commented
Nov 14, 2014
Test build #23354 has started for PR 3262 at commit
|
SparkQA
commented
Nov 14, 2014
Test build #23354 has finished for PR 3262 at commit
|
AmplabJenkins
commented
Nov 14, 2014
Test FAILed. |
SparkQA
commented
Nov 14, 2014
Test build #23356 has started for PR 3262 at commit
|
There was a problem hiding this comment.
can u add parentheses to groupByKey?
SparkQA
commented
Nov 14, 2014
Test build #23358 has started for PR 3262 at commit
|
aarondav
commented
Nov 14, 2014
What's the distinction for intToIntWritable/writableConverters? |
SparkQA
commented
Nov 14, 2014
Test build #23356 has finished for PR 3262 at commit
|
AmplabJenkins
commented
Nov 14, 2014
Test PASSed. |
SparkQA
commented
Nov 14, 2014
Test build #23358 has finished for PR 3262 at commit
|
AmplabJenkins
commented
Nov 14, 2014
Test PASSed. |
SparkQA
commented
Nov 14, 2014
Test build #23367 has started for PR 3262 at commit
|
zsxwing
commented
Nov 14, 2014
importorg.apache.spark.{SparkContext, SparkConf}
importorg.apache.spark.SparkContext._objectImplicitBackforwardCompatibilityApp {
defmain(args: Array[String]):Unit= {
valconf=newSparkConf().setAppName("ImplicitBackforwardCompatibilityApp")
valsc=newSparkContext(conf)
valrdd= sc.parallelize(1 to 100).map(i => (i, i))
valrdd2= rdd.groupByKey() // rddToPairRDDFunctionsvalrdd3= rdd2.sortByKey() // rddToOrderedRDDFunctionsvals1= rdd3.map(_._1).stats() // numericRDDToDoubleRDDFunctions
println(s1)
vals2= rdd3.map(_._1.toDouble).stats() // doubleRDDToDoubleRDDFunctions
println(s2)
valf= rdd2.countAsync() // rddToAsyncRDDActions
println(f.get())
rdd2.map { case (k, v) => (k, v.size)} saveAsSequenceFile ("/tmp/implicit_test_path") // rddToSequenceFileRDDFunctionsvala1= sc.accumulator(123.4) // DoubleAccumulatorParam
a1.add(1.0)
println(a1.value)
vala2= sc.accumulator(123) // IntAccumulatorParam
a2.add(3)
println(a2.value)
vala3= sc.accumulator(123L) // LongAccumulatorParam
a3.add(11L)
println(a3.value)
vala4= sc.accumulator(123F) // FloatAccumulatorParam
a4.add(1.1F)
println(a4.value)
{
sc.parallelize(1 to 10).map(i => (i, i)).saveAsSequenceFile("/tmp/implicit_test_int")
valr= sc.sequenceFile[Int, Int]("/tmp/implicit_test_int")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (i.toLong, i.toLong)).saveAsSequenceFile("/tmp/implicit_test_long")
valr= sc.sequenceFile[Long, Long]("/tmp/implicit_test_long")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (i.toDouble, i.toDouble)).saveAsSequenceFile("/tmp/implicit_test_double")
valr= sc.sequenceFile[Double, Double]("/tmp/implicit_test_double")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (i.toFloat, i.toFloat)).saveAsSequenceFile("/tmp/implicit_test_float")
valr= sc.sequenceFile[Float, Float]("/tmp/implicit_test_float")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (i.toString, i.toString)).saveAsSequenceFile("/tmp/implicit_test_string")
valr= sc.sequenceFile[String, String]("/tmp/implicit_test_string")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (true, false)).saveAsSequenceFile("/tmp/implicit_test_boolean")
valr= sc.sequenceFile[Boolean, Boolean]("/tmp/implicit_test_boolean")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (Array(i.toByte), Array(i.toByte))).saveAsSequenceFile("/tmp/implicit_test_bytes")
valr= sc.sequenceFile[Array[Byte], Array[Byte]]("/tmp/implicit_test_bytes")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
{
sc.parallelize(1 to 10).map(i => (i.toString, i.toString)).saveAsSequenceFile("/tmp/implicit_test_writable")
valr= sc.sequenceFile[org.apache.hadoop.io.Text, org.apache.hadoop.io.Text]("/tmp/implicit_test_writable")
r.map { case (k, v) => (k.toString, v.toString)} foreach (println)
}
sc.stop()
}
}
I compiled the above codes with Spark 1.1.0 and ran it with the new Spark compiled from this PR. And it works correctly. For
Ref: http://eed3si9n.com/revisiting-implicits-without-import-tax A possible solution is creating a new class for classSequenceFileRDDFunctions[K, V](
self: RDD[(K, V)])(implicitkeyConverter: NewWritableConverter[K], valueConverter: NewWritableConverter[V])However, since it's a breaking change (of cause, we can also add a new SequenceFileRDDFunctions class to avoid breaking the old codes), I don't think it's worth us to change it. |
SparkQA
commented
Nov 14, 2014
Test build #23367 has finished for PR 3262 at commit
|
AmplabJenkins
commented
Nov 14, 2014
Test PASSed. |
mateiz
commented
Nov 15, 2014
@zsxwing just curious, with the old conversions being deprecated, is there any chance they'll create compiler warnings in common uses of the code? In any case this seems pretty cool if it doesn't actually break binary compatibility. I guess one risk is if it adds new implicits that cause something to compile differently, but it seems unlikely from a first glance. |
rxin
commented
Nov 15, 2014
Ok I finally went through the code. I like the change and it is pretty clever. I believe it should preserve both source compatibility and binary compatibility. To summarize, the changes are:
It is still a tricky change so it'd be great to get more eyes. |
SparkQA
commented
Nov 15, 2014
Test build #23425 has started for PR 3262 at commit
|
zsxwing
commented
Nov 15, 2014
@rxin Thank you for the great summary and reviewing. Already updated it accordingly. |
AmplabJenkins
commented
Nov 17, 2014
Test PASSed. |
rxin
commented
Nov 21, 2014
@heathermiller@gzm0 - do you think this pr is good for merge now? |
There was a problem hiding this comment.
All these comments are outdated (still refer to package object, but should refer to RDD companion)
gzm0
commented
Nov 21, 2014
Otherwise LGTM |
gzm0
commented
Nov 21, 2014
LGTM |
SparkQA
commented
Nov 21, 2014
Test build #23716 has started for PR 3262 at commit
|
SparkQA
commented
Nov 21, 2014
Test build #23716 has finished for PR 3262 at commit
|
AmplabJenkins
commented
Nov 21, 2014
Test PASSed. |
rxin
commented
Nov 21, 2014
I'm merging this in master. Thanks for working on this @zsxwing and everybody else for reviewing. |
rxin
commented
Nov 21, 2014
mateiz
commented
Nov 21, 2014
Yeah merging to master sounds fine; it's too late to put it in 1.2. |
mateiz
commented
Nov 21, 2014
Thanks for the patch @zsxwing, this is very cool. |
We reverted #3459 in branch-1.2 due to missing `import o.a.s.SparkContext._`, which is no longer needed in master (#3262). This PR adds #3459 back to branch-1.2 with correct imports. Github is out-of-sync now. The real changes are the last two commits. Author: Xiangrui Meng <meng@databricks.com> Closes#3473 from mengxr/SPARK-4604-1.2 and squashes the following commits: a7638a5 [Xiangrui Meng] add import o.a.s.SparkContext._ for v1.2 b749000 [Xiangrui Meng] [SPARK-4604][MLLIB] make MatrixFactorizationModel public
…+ doc updates We reverted #3439 in branch-1.2 due to missing `import o.a.s.SparkContext._`, which is no longer needed in master (#3262). This PR adds #3439 back to branch-1.2 with correct imports. Github is out-of-sync now. The real changes are the last two commits. Author: Joseph K. Bradley <joseph@databricks.com> Author: Xiangrui Meng <meng@databricks.com> Closes#3474 from mengxr/SPARK-4583-1.2 and squashes the following commits: aca2abb [Xiangrui Meng] add import o.a.s.SparkContext._ for v1.2 6b5564a [Joseph K. Bradley] [SPARK-4583] [mllib] LogLoss for GradientBoostedTrees fix + doc updates
This PR cleans up `import SparkContext._` in core for SPARK-4397(#3262) to prove it really works well. Author: zsxwing <zsxwing@gmail.com> Closes#3530 from zsxwing/SPARK-4397-cleanup and squashes the following commits: 04e2273 [zsxwing] Cleanup 'import SparkContext._' in core
As #3262 wasn't merged to branch 1.2, the `since` value of `deprecated` should be '1.3.0'. Author: zsxwing <zsxwing@gmail.com> Closes#3573 from zsxwing/SPARK-4397-version and squashes the following commits: 1daa03c [zsxwing] Change the 'since' value to '1.3.0'
This PR moved
implicits topackage objectandcompanion objectto enable the Scala compiler search them automatically without explicit importing.It should not break any API. A test project for backforward compatibility is here. It proves the codes compiled with Spark 1.1.0 can run with this PR.
To summarize, the changes are:
The disadvantage is there are duplicated codes in SparkContext for backforward compatibility.