Sorry for my explanation, my English is bad. I just need obtain the Long
containing of the DStream created by messages.count(). Thanks for all.

2015-04-24 20:00 GMT+02:00 Sean Owen <so...@cloudera.com>:

> Do you mean an RDD? I don't think it makes sense to ask if the DStream
> has data; it may have no data so far but may have data in the future.
> That's why I say you can count records received to date.
>
> On Fri, Apr 24, 2015 at 1:57 PM, Sergio Jiménez Barrio
> <drarse.a...@gmail.com> wrote:
> > My problem is that I need know if I have a DStream with data. If in this
> > second I didn't recive data, I have a exception:
> >
> > if (count != 0) {
> >     messages.foreachRDD { rdd =>
> >
> >
> >
> > 2015-04-24 19:53 GMT+02:00 Sean Owen <so...@cloudera.com>:
> >>
> >> foreachRDD is an action and doesn't return anything. It seems like you
> >> want one final count, but that's not possible with a stream, since
> >> there is conceptually no end to a stream of data. You can get a stream
> >> of counts, which is what you have already. You can sum those counts in
> >> another data structure to get a current total. See the streaming word
> >> count examples.
> >>
> >> On Fri, Apr 24, 2015 at 1:50 PM, Sergio Jiménez Barrio
> >> <drarse.a...@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > I need compare the count of messages recived if is 0 or not, but
> >> > messages.count() return a DStream[Long]. I tried this solution:
> >> >
> >> > val cuenta  = messages.count().foreachRDD{ rdd =>
> >> >                                                 rdd.first()
> >> >                                              }
> >> >
> >> > But this return a type Unit, not Long.
> >> >
> >> >
> >> > Any suggestion? Thanks!
> >
> >
>

Reply via email to