Same trick here:
~~~
val pairs = ratings.map { case Rating(i, j, r) =>
  (i, j)
}
~~~