IgniteRdd的savepairs读取实木复合地板文件的方法
问题描述:
为了读取实木复合地板文件并将项目存储到缓存中,我做了一个小小的impl。所以我写了:IgniteRdd的savepairs读取实木复合地板文件的方法
val df= sqlContext.read.
parquet(hdfsFolder).
select("a","b", "c", "d", "e", "f")
val columnsSeq= Seq("a","b", "c", "d", "e", "f")
val values = df.map(row => (row.getAs[String]("a"), row.getValuesMap(columnsSeq))).
groupByKey(1024).
map(row => (row._1 , row._2.toList.asJava))
//put them into cache
val igniteContext = new IgniteContext(sc, cacheConfigPath)
val sharedRdd = igniteContext.fromCache(cacheName)
sharedRdd.savePairs(values)
但最后一行 “sharedRdd.savePairs(值)” 给出了compileerror:
found : org.apache.spark.rdd.RDD[(String, java.util.List[Map[String,Nothing]])] required: org.apache.spark.rdd.RDD[(Nothing, Nothing)] Note: (String, java.util.List[Map[String,Nothing]]) >: (Nothing, Nothing), but class RDD is invariant in type T. You may wish to define T as -T instead. (SLS 4.5) sharedRdd.savePairs(values)
我无法找到克服这种错误的任何方式。
任何想法?
答
您应该创建IgniteRDD
适当打字:
val sharedRdd = igniteContext.fromCache[String, java.util.List[Map[String,Nothing]]](cacheName)