Created
June 13, 2016 19:00
-
-
Save danielrmeyer/ed2c8a3d4cfe6e143769cef8652edc28 to your computer and use it in GitHub Desktop.
Connect to a cassandra cluster using spark hosted on Amazon EMR
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
import org.apache.spark.SparkContext | |
import org.apache.spark.SparkContext._ | |
import org.apache.spark.SparkConf | |
import com.datastax.spark.connector._ | |
val conf = new SparkConf(true) | |
.set("spark.cassandra.connection.host", "<cassandra_host") | |
.set("spark.cassandra.auth.username", "cassandra") | |
.set("spark.cassandra.auth.password", "########") | |
sc.stop | |
val sc = new SparkContext("local[2]", "test", conf) | |
val rdd = sc.cassandraTable("ks", "cf") | |
println(rdd.count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment