spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <...@holsman.com.au>
Subject Re: I want to filter a stream by a subclass.
Date Thu, 22 May 2014 01:04:26 GMT
Thanks Tobias & Tathagata.
these are great.


On Wed, May 21, 2014 at 8:02 PM, Tobias Pfeiffer <tgp@preferred.jp> wrote:

> On Thu, May 22, 2014 at 8:07 AM, Tathagata Das
> <tathagata.das1565@gmail.com> wrote:
> > records.filter { _.isInstanceOf[Orange] } .map { _.asInstanceOf[Orange] }
>
> I think a Scala-ish way would be
>
> records.flatMap(_ match {
>   case i: Int=>
>     Some(i)
>   case _ =>
>     None
> })
>



-- 
Ian Holsman
ian@holsman.com.au
PH: + 61-3-9028 8133 / +1-(425) 998-7083

Mime
View raw message