-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1223 from datastax/YannMoisan-SPARKC-458-scala-21…
…2-support Yann moisan sparkc 458 scala 212 support
- Loading branch information
Showing
13 changed files
with
138 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,7 @@ metastore_db | |
.worksheet | ||
.idea | ||
.idea_modules | ||
*.ipr | ||
*.iws | ||
|
||
checkpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ sudo: required | |
dist: trusty | ||
scala: | ||
- 2.11.12 | ||
- 2.12.10 | ||
|
||
env: | ||
- CASSANDRA_VERSION=2.1.15 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
2.4.2 | ||
* Support for Scala 2.12 (SPARKC-458) | ||
|
||
2.4.1 | ||
* Includes all up to 2.3.3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...-embedded/scala-2.12/src/main/scala/com/datastax/spark/connector/embedded/SparkRepl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.datastax.spark.connector.embedded | ||
|
||
import java.io._ | ||
import java.net.URLClassLoader | ||
|
||
import org.apache.spark.SparkConf | ||
import org.apache.spark.repl.{Main, SparkILoop} | ||
|
||
import scala.collection.mutable.ArrayBuffer | ||
import scala.tools.nsc.GenericRunnerSettings | ||
|
||
object SparkRepl { | ||
|
||
def runInterpreter(input: String, conf: SparkConf): String = { | ||
val in = new BufferedReader(new StringReader(input + "\n")) | ||
val out = new StringWriter() | ||
val cl = getClass.getClassLoader | ||
var paths = new ArrayBuffer[String] | ||
cl match { | ||
case urlLoader: URLClassLoader => | ||
for (url <- urlLoader.getURLs) { | ||
if (url.getProtocol == "file") { | ||
paths += url.getFile | ||
} | ||
} | ||
case _ => | ||
} | ||
|
||
Main.conf.setAll(conf.getAll) | ||
val interp = new SparkILoop(Some(in), new PrintWriter(out)) | ||
Main.interp = interp | ||
val separator = System.getProperty("path.separator") | ||
val settings = new GenericRunnerSettings(s => throw new RuntimeException(s"Scala options error: $s")) | ||
settings.processArguments(List("-classpath", paths.mkString(separator)), true) | ||
interp.process(settings) // Repl starts and goes in loop of R.E.P.L | ||
Main.interp = null | ||
Option(Main.sparkContext).foreach(_.stop()) | ||
System.clearProperty("spark.driver.port") | ||
out.toString | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...andra-connector/scala-2.12/src/main/scala/com/datastax/spark/connector/util/Reflect.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.datastax.spark.connector.util | ||
|
||
import scala.reflect.runtime.universe._ | ||
|
||
private[connector] object Reflect { | ||
|
||
def constructor(tpe: Type): Symbol = tpe.decl(termNames.CONSTRUCTOR) | ||
|
||
def member(tpe: Type, name: String): Symbol = tpe.member(TermName(name)) | ||
|
||
def methodSymbol(tpe: Type): MethodSymbol = { | ||
val constructors = constructor(tpe).asTerm.alternatives.map(_.asMethod) | ||
val paramCount = constructors.map(_.paramLists.flatten.size).max | ||
constructors.filter(_.paramLists.flatten.size == paramCount) match { | ||
case List(onlyOne) => onlyOne | ||
case _ => throw new IllegalArgumentException( | ||
"Multiple constructors with the same number of parameters not allowed.") | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters