You could do

records.filter { _.isInstanceOf[Orange] } .map { _.asInstanceOf[Orange] }



On Wed, May 21, 2014 at 3:28 PM, Ian Holsman <i...@holsman.com.au> wrote:

> Hi.
> Firstly I'm a newb (to both Scala & Spark).
>
> I have a stream, that contains multiple types of records, and I would like
> to create multiple streams based on that
>
> currently I have it set up as
>
> class ALL
> class Orange extends ALL
> class Apple extends ALL
>
> now I can easily add a filter ala
> val records:DStream[ALL] = ...mapper to build the classes off the wire...
> val orangeRecords = records.filter {_.isInstanceOf[Orange]}
>
> but I would like to have the line be a DStream[Orange] instead of a
> DStream[ALL]
> (So I can access the unique fields in the subclass).
>
> I'm using 0.9.1 if it matters.
>
> TIA
> Ian
>
> --
> Ian Holsman
> i...@holsman.com.au
> PH: + 61-3-9028 8133 / +1-(425) 998-7083
>

Reply via email to