6
我執行以下操作:如何迭代scala wrappedArray? (星火)
val tempDict = sqlContext.sql("select words.pName_token,collect_set(words.pID) as docids
from words
group by words.pName_token").toDF()
val wordDocs = tempDict.filter(newDict("pName_token")===word)
val listDocs = wordDocs.map(t => t(1)).collect()
listDocs: Array
[Any] = Array(WrappedArray(123, 234, 205876618, 456))
我的問題是我怎麼遍歷這個包裹陣列或轉換成榜單。我得到的listDocs選項有:apply
asInstanceOf
clone
isInstanceOf
length
toString
update
我該如何繼續?
其實我這樣做,這似乎解決了我的情況: VAL arrDocs = listDocs(0) VAL TEMP = arrDocs.asInstanceOf [mutable.WrappedArray [龍] 的** **溫度現在基本上給了我一個迭代器。 – boY
謝謝@boY,我更新了答案。前一個有點冗長。 –
我在代碼中遇到了WrappedArray的問題,並能夠用Seq [Int]替換它。 – jspooner