Skip to content

[SPARK-3266] [Java] Change JavaRDDLike trait to abstract class.#2186

Closed
JoshRosen wants to merge 1 commit intoapache:masterfrom
JoshRosen:SPARK-3266
Closed

[SPARK-3266] [Java] Change JavaRDDLike trait to abstract class.#2186
JoshRosen wants to merge 1 commit intoapache:masterfrom
JoshRosen:SPARK-3266

Conversation

@JoshRosen
Copy link
Contributor

JavaRDDLike's current design is a holdover from an earlier prototype that tried
to achieve code-reuse for methods like map(), filter(), etc. using the same
builder-trait pattern that the Scala collections library uses. This approach
didn't work due to some compiler issues, but unfortunately we never removed
the confusing trait implementation.

This patch changes JavaRDDLike from a trait to an abstract base class.
This should be source-compatible with earlier versions.

This change resolves some problems with certain inherited methods having the
wrong signatures in the bytecode (such as max(); see SPARK-3266).

Review on Reviewable

JavaRDDLike's current design is a holdover from an earlier prototype that tried
to achieve code-reuse for methods like map(), filter(), etc. using the same
builder-trait pattern that the Scala collections library uses.  This approach
didn't work due to some compiler issues, but unfortunately we never removed
the confusing trait implementation.

This patch changes JavaRDDLike from a trait to an abstract base class.
This should be source-compatible with earlier versions.

This change resolves some problems with certain inherited methods having the
wrong signatures in the bytecode (such as max(); see SPARK-3266).
@SparkQA
Copy link

SparkQA commented Aug 28, 2014

QA tests have started for PR 2186 at commit 492694b.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 28, 2014

QA tests have finished for PR 2186 at commit 492694b.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaDoubleRDD(val srdd: RDD[scala.Double]) extends JavaRDDLike[JDouble]
    • abstract class JavaRDDLike[T] extends Serializable

@SparkQA
Copy link

SparkQA commented Sep 5, 2014

QA tests have started for PR 2186 at commit 492694b.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Sep 6, 2014

QA tests have finished for PR 2186 at commit 492694b.

  • This patch fails unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class JavaDoubleRDD(val srdd: RDD[scala.Double]) extends JavaRDDLike[JDouble]
    • abstract class JavaRDDLike[T] extends Serializable
    • case class AddJar(path: String) extends LeafNode with Command

@liancheng
Copy link
Contributor

test this please

@JoshRosen
Copy link
Contributor Author

This almost certainly breaks binary compatibility; sorry for letting this PR sit for so long. I'll try to update it today or tomorrow.

JoshRosen added a commit to JoshRosen/spark that referenced this pull request Oct 26, 2014
This PR addresses a Scala compiler bug ([SI-8905](https://issues.scala-lang.org/browse/SI-8905)) that was breaking some of the Spark Java APIs.  In a nutshell, it seems that methods whose implementations are inherited from generic traits sometimes have their type parameters erased to Object.  This was causing methods like `DoubleRDD.min()` to throw confusing NoSuchMethodErrors at runtime.

The workaround is to move the implementations of these methods out of the trait.  Ideally, I'd like to just delete the trait and convert it into an abstract class, but this technically breaks binary compatibility because it removes an interface (see apache#2186).  Instead, I remove the method implementations from the traits and put them in AbstractJavaDStream and AbstractJavaRDD classes that inherit from their respective traits.  This leads to a bit of redundancy, but I think it's the cleanest general solution that maintains binary compatibility.

I also improved the test coverage of the Java API.
@marmbrus
Copy link
Contributor

marmbrus commented Dec 2, 2014

ping @JoshRosen, trying to decrease the number of open SQL PRs ;)

@JoshRosen JoshRosen closed this Dec 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants