0
我有這樣的:如何在Spark 2.1中編寫集合的編碼器?
import spark.implicits._
import org.apache.spark.sql.catalyst.encoders.RowEncoder
val mydata: Dataset[Row] = spark.read.format("csv").option("header", true).option("inferSchema", true).load("mydata.csv")
// CSV header: Time,Area,City
// CSV values: "2016-01","A1","NY"
// "2016-01","AB","HK" etc
// ...somewhere in my aggregate:
def bufferEncoder: Encoder[Array[(String, Row)]] = ....
對於在Array
內的元組我可以這樣寫:
val rowEncoder = RowEncoder(mydata.schema)
Encoders.tuple(Encoders.STRING, rowEncoder)
,但我怎麼能寫Encoder
的外Array
?
你能給出一個可重複的例子嗎? my.data中有什麼? – mtoto