Getting error when processing RDD of predictionIO

25 visningar
Hoppa till det första olästa meddelandet

Kim Trang Le

oläst,
7 okt. 2015 22:45:182015-10-07
till scala-user
Dear all,
I have difficulty processing a list a Scala:
Currently I have a list of like this

(List(JString(2437), JString(2445), JString(2428), JString(321)), CompactBuffer((4,1)))

and I would like after processing, the result will look like below:

( (2437, CompactBuffer((4,1))), (2445, CompactBuffer((4,1))), (2428, CompactBuffer((4,1))), (321, CompactBuffer((4,1))) )

I have got a helpful reply but I am still got stuck when I try this


val pair = (List(JString(2437), JString(2445), JString(2428), JString(321)), CompactBuffer((4,1)))
val result = pair._1.map((_, pair._2))

First, pair._1 gets the list from the tuple. Then, map performs the function on each element of the list. The function (_, pair._2) puts the given element from the list in a new tuple together with the second part of the pair tuple.


I got an error:
value _1 is not a member of org.apache.spark.rdd.RDD[(String, Array[(Int, Int)])].

It seems that
List(JString(2437), JString(2445), JString(2428), JString(321)) is a string rather than a list. Can anybody help me with that?

Thank you very much.

Seth Tisue

oläst,
7 okt. 2015 23:11:102015-10-07
till scala-user
I see that you've also posted this to http://stackoverflow.com/questions/33005737/error-processing-scala-list. When posting the same question to more than one place on the Internet, it's polite to say so and include a link, so someone doesn't waste time helping you in one place when you were already helped in the other place.

You also posted the same question to the scala-language group. It wasn't appropriate there, so I deleted it. (The question is appropriate here on scala-user, though I think you're likelier to get better help faster on Stack Overflow.)

Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden