【发布时间】:2016-06-27 15:52:49
【问题描述】:
因此,我一直在尝试重新格式化我正在处理的项目以使用 Dataset API,并且遇到了一些编码错误问题。根据我的阅读,我认为我应该能够将原始值数组存储在数据集中。但是,下面的类给了我编码错误:
case class InvertedIndex(partition:Int, docs:Array[Int], indices:Array[Long], weights:Array[Double])
val inv = RDD[InvertedIndex]
val invertedIndexDataset = sqlContext.createDataset(inv)
invertedIndexDataset.groupBy(x => x.partition).mapGroups {
//...
}
有人可以帮我理解这里的问题吗?数据集目前不能处理基元数组,还是我需要做一些额外的事情才能使它们工作?
谢谢
编辑 1:
这是我得到的完整错误
Error:(223, 84) Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._ Support for serializing other types will be added in future releases.
val similarities = invertedIndexDataset.groupByKey(x => x.partition).mapGroups {
【问题讨论】:
-
您可能想看看this SO post。您遇到的具体错误是什么?
-
你有没有:import sqlContext.implicits._
-
@RobertHorvick 是的,但是我将它导入函数中,这样会导致问题吗? (这个函数接受 sparkContext 作为参数,所以很难有一个类范围的 sqlContext)
-
@Hawknight 我收到与该帖子相同的错误,但我的案例类是在函数之外定义的,所以我不确定它为什么会发生。
-
请分享您收到的准确且完整的错误消息。
标签: scala apache-spark apache-spark-sql apache-spark-dataset