2

그래서 데이터 집합 API를 사용하기 위해 노력하고있는 프로젝트를 다시 포맷하려고 시도했으며 인코딩 오류와 관련된 몇 가지 문제가있었습니다. 필자가 읽은 바에 따르면, 데이터 집합에 원시 값의 배열을 저장할 수 있어야한다고 생각합니다. 그러나 다음 클래스는 인코딩 오류를 제공합니다.배열의 데이터 집합 (1.6.1)

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 { 
    //... 
} 

누군가가 여기에있는 문제를 이해하도록 도와 주시겠습니까? 데이터 셋은 현재 프리미티브 배열을 처리 할 수 ​​없습니까? 아니면 데이터를 작동 시키려면 추가로 필요합니까? 여기에 스파크 2.0에서 예상대로 내가

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 { 
+0

당신은 좀보고 할 수 있습니다 [이 SO 포스트 (http://stackoverflow.com/questions/36449368/using-an-optionsome-primitive-type-in-spark-dataset-api) . 어떤 오류가 발생합니까? –

+0

가지고 계십니까? import sqlContext.implicits._ –

+0

@RobertHorvick 예, 함수에서 가져 오기 때문에 문제가 발생합니까? (이 함수는 sparkContext를 매개 변수로 취하므로 클래스 전체 sqlContext를 가질 수 없습니다.) –

답변

0

다음 작품을 무엇입니까 전체 오류가

:

편집 1 감사드립니다.

import spark.implicits._ 

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