Spark- Saving JavaRDD to Cassandra
Asked Answered
P

2

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?

Probation answered 5/12, 2014 at 19:40 Comment(0)
S
6

Following the documentation, should be like this:

javaFunctions(rdd).writerBuilder("ks", "people", mapToRow(Person.class)).saveToCassandra();
Smoke answered 6/12, 2014 at 12:59 Comment(0)
W
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));
Waligore answered 29/4, 2015 at 12:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.