You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/07/24 02:12:32 UTC

git commit: [SPARK-2549] Functions defined inside of other functions trigger failures

Repository: spark
Updated Branches:
  refs/heads/master efdaeb111 -> 9b763329d


[SPARK-2549] Functions defined inside of other functions trigger failures

Author: Prashant Sharma <pr...@imaginea.com>

Closes #1510 from ScrapCodes/SPARK-2549/fun-in-fun and squashes the following commits:

9458bc5 [Prashant Sharma] Tested by removing an inner function from excludes.
bc03b1c [Prashant Sharma] SPARK-2549 Functions defined inside of other functions trigger failures


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9b763329
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9b763329
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9b763329

Branch: refs/heads/master
Commit: 9b763329d968658d2dedee4485b7931646e6392e
Parents: efdaeb1
Author: Prashant Sharma <pr...@imaginea.com>
Authored: Wed Jul 23 17:12:28 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Wed Jul 23 17:12:28 2014 -0700

----------------------------------------------------------------------
 project/MimaExcludes.scala                      | 183 ++++++++-----------
 .../apache/spark/tools/GenerateMIMAIgnore.scala |  21 ++-
 2 files changed, 98 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/9b763329/project/MimaExcludes.scala
----------------------------------------------------------------------
diff --git a/project/MimaExcludes.scala b/project/MimaExcludes.scala
index 5e5ddd2..e9220db 100644
--- a/project/MimaExcludes.scala
+++ b/project/MimaExcludes.scala
@@ -32,108 +32,83 @@ import com.typesafe.tools.mima.core._
  */
 object MimaExcludes {
 
-  def excludes(version: String) = version match {
-    case v if v.startsWith("1.1") =>
-      Seq(
-        MimaBuild.excludeSparkPackage("deploy"),
-        MimaBuild.excludeSparkPackage("graphx")
-      ) ++
-      closures.map(method => ProblemFilters.exclude[MissingMethodProblem](method)) ++
-      Seq(
-        // Adding new method to JavaRDLike trait - we should probably mark this as a developer API.
-        ProblemFilters.exclude[MissingMethodProblem]("org.apache.spark.api.java.JavaRDDLike.partitions"),
-        // We made a mistake earlier (ed06500d3) in the Java API to use default parameter values
-        // for countApproxDistinct* functions, which does not work in Java. We later removed
-        // them, and use the following to tell Mima to not care about them.
-        ProblemFilters.exclude[IncompatibleResultTypeProblem](
-          "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey"),
-        ProblemFilters.exclude[IncompatibleResultTypeProblem](
-          "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.api.java.JavaPairRDD.countApproxDistinct$default$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey$default$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.api.java.JavaRDD.countApproxDistinct$default$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.api.java.JavaRDDLike.countApproxDistinct$default$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.api.java.JavaDoubleRDD.countApproxDistinct$default$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.storage.MemoryStore.Entry"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$debugChildren$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$firstDebugString$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$shuffleDebugString$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$debugString$1"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$"
-            + "createZero$1")
-      ) ++
-      Seq(
-        ProblemFilters.exclude[MissingMethodProblem]("org.apache.spark.streaming.flume.FlumeReceiver.this")
-      ) ++
-      Seq( // Ignore some private methods in ALS.
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$^dateFeatures"),
-        ProblemFilters.exclude[MissingMethodProblem]( // The only public constructor is the one without arguments.
-          "org.apache.spark.mllib.recommendation.ALS.this"),
-        ProblemFilters.exclude[MissingMethodProblem](
-          "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$$<init>$default$7"),
-        ProblemFilters.exclude[IncompatibleMethTypeProblem](
-          "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$^dateFeatures")
-      ) ++
-      MimaBuild.excludeSparkClass("mllib.linalg.distributed.ColumnStatisticsAggregator") ++
-      MimaBuild.excludeSparkClass("rdd.ZippedRDD") ++
-      MimaBuild.excludeSparkClass("rdd.ZippedPartition") ++
-      MimaBuild.excludeSparkClass("util.SerializableHyperLogLog") ++
-      MimaBuild.excludeSparkClass("storage.Values") ++
-      MimaBuild.excludeSparkClass("storage.Entry") ++
-      MimaBuild.excludeSparkClass("storage.MemoryStore$Entry") ++
-      Seq(
-        ProblemFilters.exclude[IncompatibleMethTypeProblem](
-          "org.apache.spark.mllib.tree.impurity.Gini.calculate"),
-        ProblemFilters.exclude[IncompatibleMethTypeProblem](
-          "org.apache.spark.mllib.tree.impurity.Entropy.calculate"),
-        ProblemFilters.exclude[IncompatibleMethTypeProblem](
-          "org.apache.spark.mllib.tree.impurity.Variance.calculate")
-      )
-    case v if v.startsWith("1.0") =>
-      Seq(
-        MimaBuild.excludeSparkPackage("api.java"),
-        MimaBuild.excludeSparkPackage("mllib"),
-        MimaBuild.excludeSparkPackage("streaming")
-      ) ++
-      MimaBuild.excludeSparkClass("rdd.ClassTags") ++
-      MimaBuild.excludeSparkClass("util.XORShiftRandom") ++
-      MimaBuild.excludeSparkClass("graphx.EdgeRDD") ++
-      MimaBuild.excludeSparkClass("graphx.VertexRDD") ++
-      MimaBuild.excludeSparkClass("graphx.impl.GraphImpl") ++
-      MimaBuild.excludeSparkClass("graphx.impl.RoutingTable") ++
-      MimaBuild.excludeSparkClass("graphx.util.collection.PrimitiveKeyOpenHashMap") ++
-      MimaBuild.excludeSparkClass("graphx.util.collection.GraphXPrimitiveKeyOpenHashMap") ++
-      MimaBuild.excludeSparkClass("mllib.recommendation.MFDataGenerator") ++
-      MimaBuild.excludeSparkClass("mllib.optimization.SquaredGradient") ++
-      MimaBuild.excludeSparkClass("mllib.regression.RidgeRegressionWithSGD") ++
-      MimaBuild.excludeSparkClass("mllib.regression.LassoWithSGD") ++
-      MimaBuild.excludeSparkClass("mllib.regression.LinearRegressionWithSGD")
-    case _ => Seq()
-  }
-
-  private val closures = Seq(
-    "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$mergeMaps$1",
-    "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$countPartition$1",
-    "org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$distributePartition$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$mergeValue$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$writeToFile$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$reducePartition$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$writeShard$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$mergeCombiners$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$process$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$createCombiner$1",
-    "org.apache.spark.rdd.PairRDDFunctions.org$apache$spark$rdd$PairRDDFunctions$$mergeMaps$1"
-  )
+    def excludes(version: String) =
+      version match {
+        case v if v.startsWith("1.1") =>
+          Seq(
+            MimaBuild.excludeSparkPackage("deploy"),
+            MimaBuild.excludeSparkPackage("graphx")
+          ) ++
+          Seq(
+            // Adding new method to JavaRDLike trait - we should probably mark this as a developer API.
+            ProblemFilters.exclude[MissingMethodProblem]("org.apache.spark.api.java.JavaRDDLike.partitions"),
+            // We made a mistake earlier (ed06500d3) in the Java API to use default parameter values
+            // for countApproxDistinct* functions, which does not work in Java. We later removed
+            // them, and use the following to tell Mima to not care about them.
+            ProblemFilters.exclude[IncompatibleResultTypeProblem](
+              "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey"),
+            ProblemFilters.exclude[IncompatibleResultTypeProblem](
+              "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.api.java.JavaPairRDD.countApproxDistinct$default$1"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.api.java.JavaPairRDD.countApproxDistinctByKey$default$1"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.api.java.JavaRDD.countApproxDistinct$default$1"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.api.java.JavaRDDLike.countApproxDistinct$default$1"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.api.java.JavaDoubleRDD.countApproxDistinct$default$1"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.storage.MemoryStore.Entry")
+          ) ++
+          Seq(
+            ProblemFilters.exclude[MissingMethodProblem]("org.apache.spark.streaming.flume.FlumeReceiver.this")
+          ) ++
+          Seq( // Ignore some private methods in ALS.
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$^dateFeatures"),
+            ProblemFilters.exclude[MissingMethodProblem]( // The only public constructor is the one without arguments.
+              "org.apache.spark.mllib.recommendation.ALS.this"),
+            ProblemFilters.exclude[MissingMethodProblem](
+              "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$$<init>$default$7"),
+            ProblemFilters.exclude[IncompatibleMethTypeProblem](
+              "org.apache.spark.mllib.recommendation.ALS.org$apache$spark$mllib$recommendation$ALS$^dateFeatures")
+          ) ++
+          MimaBuild.excludeSparkClass("mllib.linalg.distributed.ColumnStatisticsAggregator") ++
+          MimaBuild.excludeSparkClass("rdd.ZippedRDD") ++
+          MimaBuild.excludeSparkClass("rdd.ZippedPartition") ++
+          MimaBuild.excludeSparkClass("util.SerializableHyperLogLog") ++
+          MimaBuild.excludeSparkClass("storage.Values") ++
+          MimaBuild.excludeSparkClass("storage.Entry") ++
+          MimaBuild.excludeSparkClass("storage.MemoryStore$Entry") ++
+          Seq(
+            ProblemFilters.exclude[IncompatibleMethTypeProblem](
+              "org.apache.spark.mllib.tree.impurity.Gini.calculate"),
+            ProblemFilters.exclude[IncompatibleMethTypeProblem](
+              "org.apache.spark.mllib.tree.impurity.Entropy.calculate"),
+            ProblemFilters.exclude[IncompatibleMethTypeProblem](
+              "org.apache.spark.mllib.tree.impurity.Variance.calculate")
+          )
+        case v if v.startsWith("1.0") =>
+          Seq(
+            MimaBuild.excludeSparkPackage("api.java"),
+            MimaBuild.excludeSparkPackage("mllib"),
+            MimaBuild.excludeSparkPackage("streaming")
+          ) ++
+          MimaBuild.excludeSparkClass("rdd.ClassTags") ++
+          MimaBuild.excludeSparkClass("util.XORShiftRandom") ++
+          MimaBuild.excludeSparkClass("graphx.EdgeRDD") ++
+          MimaBuild.excludeSparkClass("graphx.VertexRDD") ++
+          MimaBuild.excludeSparkClass("graphx.impl.GraphImpl") ++
+          MimaBuild.excludeSparkClass("graphx.impl.RoutingTable") ++
+          MimaBuild.excludeSparkClass("graphx.util.collection.PrimitiveKeyOpenHashMap") ++
+          MimaBuild.excludeSparkClass("graphx.util.collection.GraphXPrimitiveKeyOpenHashMap") ++
+          MimaBuild.excludeSparkClass("mllib.recommendation.MFDataGenerator") ++
+          MimaBuild.excludeSparkClass("mllib.optimization.SquaredGradient") ++
+          MimaBuild.excludeSparkClass("mllib.regression.RidgeRegressionWithSGD") ++
+          MimaBuild.excludeSparkClass("mllib.regression.LassoWithSGD") ++
+          MimaBuild.excludeSparkClass("mllib.regression.LinearRegressionWithSGD")
+        case _ => Seq()
+      }
 }

http://git-wip-us.apache.org/repos/asf/spark/blob/9b763329/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
----------------------------------------------------------------------
diff --git a/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala b/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
index 03a73f9..5669836 100644
--- a/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
+++ b/tools/src/main/scala/org/apache/spark/tools/GenerateMIMAIgnore.scala
@@ -99,9 +99,25 @@ object GenerateMIMAIgnore {
     (ignoredClasses.flatMap(c => Seq(c, c.replace("$", "#"))).toSet, ignoredMembers.toSet)
   }
 
+  /** Scala reflection does not let us see inner function even if they are upgraded
+    * to public for some reason. So had to resort to java reflection to get all inner
+    * functions with $$ in there name.
+    */
+  def getInnerFunctions(classSymbol: unv.ClassSymbol): Seq[String] = {
+    try {
+      Class.forName(classSymbol.fullName, false, classLoader).getMethods.map(_.getName)
+        .filter(_.contains("$$")).map(classSymbol.fullName + "." + _)
+    } catch {
+      case t: Throwable =>
+        println("[WARN] Unable to detect inner functions for class:" + classSymbol.fullName)
+        Seq.empty[String]
+    }
+  }
+
   private def getAnnotatedOrPackagePrivateMembers(classSymbol: unv.ClassSymbol) = {
     classSymbol.typeSignature.members
-      .filter(x => isPackagePrivate(x) || isDeveloperApi(x) || isExperimental(x)).map(_.fullName)
+      .filter(x => isPackagePrivate(x) || isDeveloperApi(x) || isExperimental(x)).map(_.fullName) ++
+      getInnerFunctions(classSymbol)
   }
 
   def main(args: Array[String]) {
@@ -121,7 +137,8 @@ object GenerateMIMAIgnore {
     name.endsWith("$class") ||
     name.contains("$sp") ||
     name.contains("hive") ||
-    name.contains("Hive")
+    name.contains("Hive") ||
+    name.contains("repl")
   }
 
   /**