jAi
jAi

Reputation: 115

List[Row] to RDD[CassandrRow] conversion in scala

I've following code :-

 val result = session.execute("Select * from table where imei= '" + imei + "'")
 val list = result.all()
 val sCollection = list.asScala
 val rdd = sc.parallelize(Seq(sCollection))

I'm trying to create list[Row] to RDD[CassandraRow] and I found somewhere that we need to convert this list to scala collection before making it RDD, but when I'm trying to run this is giving error that:

value asScala is not a member of java.util.List[com.datastax.driver.core.Row]

Where I'm going wrong and what can be done to resolve this ?

Thanks,

Upvotes: 0

Views: 314

Answers (1)

wind
wind

Reputation: 1020

You missed import scala.collection.JavaConverters._ at the beginning. However I don't recommend the solution you've written, because it's not scalable.

There is Spark-Cassandra connector, that can load data into Spark in distributed (scalable) way.

Upvotes: 1

Related Questions