2014-12-05 126 views
4

http://www.datastax.com/dev/blog/accessing-cassandra-from-spark-in-java火花保存JavaRDD卡桑德拉

上面的鏈接顯示的方式保存JavaRDDcassandra這樣:

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

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

但是,com.datastax.spark.connector.CassandraJavaUtil.*似乎過時。更新後的API應該是:

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

能有人告訴我一些代碼來存儲JavaRDDCassandra使用上述更新的API?

回答

5

documentation,應該是這樣的:

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

http://stackoverflow.com/questions/27450944更換

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

/火花罐不存取第一ELEM ent-in-an-javardd-using-first您還可以看看這個問題嗎? – byteBiter 2014-12-12 19:45:09

1

通過

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