简体   繁体   中英

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,

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM