I have the following map:
val pairs = lines.map( l => ( if (l.split(",")(1).toInt < 60) { "rest" } else if (l.split(",")(1).toInt > 110) { "sport" }, 10) ).reduceByKeyAndWindow((a:Int, b:Int) => (a+b), Seconds(12))
Basically, when someone's HR is bellow 60, it's classified as rest, above 110 is classified as sport. The second variable of the tuple represents that the person has been doing it for 10 minutes.
Rigth now, this maps an empty key for values between 60 and 110. What I want is to completely discard them. How is that achievable?
So from
("rest", 30)
("sport", 120)
((),10)
I'm trying to filter out ((),10)
.
I've tried
pairs.filter{case (key, value) => key.length < 3} //error: value length is not a member of Any
pairs.filter(_._1 != "") //no error, just still keeps the empty keys, too
None seem to work.