Created
December 22, 2014 23:33
-
-
Save tupshin/b5e7d3b652ec5fa65bbf to your computer and use it in GitHub Desktop.
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 com.datastax.spark.connector.cql.CassandraConnector | |
import org.apache.spark.{SparkContext,SparkConf} | |
import org.apache.spark.sql.SQLContext | |
import com.databricks.spark.csv._ | |
import com.datastax.spark.connector._ | |
object CSV2Cassandra { | |
def main(args: Array[String]): Unit = { | |
val conf = new SparkConf(true).set("spark.cassandra.connection.host", "127.0.0.1").setMaster("local") | |
val sc = new SparkContext("local", "test", conf) | |
val sqlContext = new SQLContext(sc) | |
val cars = sqlContext.csvFile("cars.csv") | |
val connector = CassandraConnector(conf) | |
cars.saveToCassandra("spark_loader", "cars", SomeColumns("make", "model", "year", "comment")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment