Rahul Koshaley
Rahul Koshaley

Reputation: 201

How to save only few columns to cassandra using spark In Java

I'm trying to save a RDD to Cassandra using

JavaRDD<UserSetGet> rddFromGz = sc.parallelize(ListFromS3);

CassandraJavaUtil.javaFunctions(rddFromGz)
        .writerBuilder("dmp", "table", mapToRow(UserSetGet.class)).saveToCassandra();

Here UserSetGet object has all the fields Initialized.

But I wish to save some columns only , how to do that ?

In the doc , it says we can do

.saveToCassandra("test", "words", SomeColumns("word", "1"));

But it is not recognising SomeColumns Method.

Upvotes: 2

Views: 1076

Answers (2)

Hope the below lines will help you

val w1 = CassandraJavaUtil.javaFunctions(rdd23).writerBuilder("smart","emp", CassandraJavaUtil.mapToRow(classOf[emp]))
w1.withColumnSelector(CassandraJavaUtil.someColumns("pid","page")).saveToCassandra()

Upvotes: 0

doanduyhai
doanduyhai

Reputation: 8812

The SomeColumns method is for the Scala api, you're using the Java API...

Maybe it's a good opportunity to switch to Scala

Upvotes: 1

Related Questions