Scala Spark中阵列的数据集(1.6.1)

Scala Spark中阵列的数据集(1.6.1),scala,apache-spark,apache-spark-sql,apache-spark-dataset,Scala,Apache Spark,Apache Spark Sql,Apache Spark Dataset,因此,我一直在尝试重新格式化一个正在使用DataSetaAPI的项目,但在编码错误方面遇到了一些问题。从我读到的内容来看,我认为我应该能够在数据集中存储基本值数组。但是,以下类给了我编码错误: case class InvertedIndex(partition:Int, docs:Array[Int], indices:Array[Long], weights:Array[Double]) val inv = RDD[InvertedIndex] val invertedIndexDatas

因此,我一直在尝试重新格式化一个正在使用DataSetaAPI的项目,但在编码错误方面遇到了一些问题。从我读到的内容来看,我认为我应该能够在数据集中存储基本值数组。但是,以下类给了我编码错误:

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 {

在Spark 2.0中,以下各项可以正常工作

import spark.implicits._

spark.createDataset( Array(1,2) :: Array(1) :: Array(2) :: Nil )
res0:org.apache.spark.sql.Dataset[Array[Int]] = [value: array<int>]
导入spark.implicits_
createDataset(数组(1,2)::数组(1)::数组(2)::Nil)
res0:org.apache.spark.sql.Dataset[Array[Int]]=[value:Array]

您可能想看看。您得到的具体错误是什么?是否有:import sqlContext.implicits.@RobertHorvick是的,但是我在函数中导入了它,这样会导致问题吗?(此函数将sparkContext作为参数,因此很难获得类范围内的sqlContext)@Hawknight我收到的错误与那篇文章相同,但我的case类是在函数外部定义的,因此我不确定为什么会发生这种情况。请分享您收到的准确完整的错误消息。