Try:

~~~
val ht = iter.map(rat => (userPartitioner.getPartition(rat.user), rat.product)).toSet
~~~