Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark- Saving JavaRDD to Cassandra

This link shows a way to save a JavaRDD to Cassandra in this way:

import static com.datastax.spark.connector.CassandraJavaUtil.*;

JavaRDD<Product> productsRDD = sc.parallelize(products);
javaFunctions(productsRDD, Product.class).saveToCassandra("java_api", "products");

But the com.datastax.spark.connector.CassandraJavaUtil.* seems deprecated. The updated API should be:

import static com.datastax.spark.connector.japi.CassandraJavaUtil.*;

Can someone show me some codes to store a JavaRDD to Cassandra using the updated API above?

like image 598
chrisTina Avatar asked Dec 05 '14 19:12

chrisTina


1 Answers

Following the documentation, should be like this:

javaFunctions(rdd).writerBuilder("ks", "people", mapToRow(Person.class)).saveToCassandra();
like image 171
maasg Avatar answered Sep 21 '22 02:09

maasg