5

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?

2 Answers 2

6

Following the documentation, should be like this:

javaFunctions(rdd).writerBuilder("ks", "people", mapToRow(Person.class)).saveToCassandra();
0
0

replace

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

by

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.