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?
按照文档,应该是这样的:
javaFunctions(rdd).writerBuilder("ks", "people", mapToRow(Person.class)).saveToCassandra();
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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.