I can't understand 'RDD.map{ case (A, B) => A } ' in Scala Spark

Viewed 6691

I'm relatively new to Scala Spark. I've got a question with map method.

My understanding: map is a RDD method, it accepts a function as its parameter like:map(line => line.split(","))

I found really hard to understand this kind of expression.

val uniqueUsers = data.map { case (user, product, price) => user }.distinct().count()

Could someone explain two things for me:

  1. why {} is used not ()
  2. can I regard case (user, product, price) => user as a function? If not, what is it?

Thank you in advance.

1 Answers
Related