It is solved. Thank u! Is more efficient

messages.foreachRDD(rdd => {

if(!rdd.isEmpty) //Do whatever you want.

})


2015-04-25 19:21 GMT+02:00 Akhil Das <ak...@sigmoidanalytics.com>:

> Like this?
>
> messages.foreachRDD(rdd => {
>
> if(rdd.count() > 0) //Do whatever you want.
>
> })
>
>
> Thanks
> Best Regards
>
> On Fri, Apr 24, 2015 at 11:20 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