Reputation: 1073
I am able to accomplish a filter for RDD[Test] using a specific value
Test.filter(_.state == "NY")
I need to extend this to be able to filter Test with multiple values like ("NY","CA","PA")
Is there an "in list" or in ("NY","CA","PA") in scala
Upvotes: 3
Views: 5436
Reputation: 8866
You can put values in Set and filter the following way:
val set = Set("NY", "CA", "PA")
rdd.filter(item => set(item.state))
to test if value is in set:
set.contains(value)
or
set(value)
Upvotes: 2