Re: Convert DStream[Long] to Long

2015-04-25 Thread Akhil Das
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

Re: Convert DStream[Long] to Long

2015-04-25 Thread Sergio Jiménez Barrio
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

Re: Convert DStream[Long] to Long

2015-04-24 Thread Sergio Jiménez Barrio
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

Re: Convert DStream[Long] to Long

2015-04-24 Thread Sergio Jiménez Barrio
But if a use messages.count().print this show a single number :/ 2015-04-24 20:22 GMT+02:00 Sean Owen so...@cloudera.com: It's not a Long. it's an infinite stream of Longs. On Fri, Apr 24, 2015 at 2:20 PM, Sergio Jiménez Barrio drarse.a...@gmail.com wrote: It isn't the sum. This is de

Re: Convert DStream[Long] to Long

2015-04-24 Thread Sean Owen
The sum? you just need to use an accumulator to sum the counts or something. On Fri, Apr 24, 2015 at 2:14 PM, Sergio Jiménez Barrio drarse.a...@gmail.com wrote: Sorry for my explanation, my English is bad. I just need obtain the Long containing of the DStream created by messages.count().

Re: Convert DStream[Long] to Long

2015-04-24 Thread Sean Owen
No, it prints each Long in that stream, forever. Have a look at the DStream API. On Fri, Apr 24, 2015 at 2:24 PM, Sergio Jiménez Barrio drarse.a...@gmail.com wrote: But if a use messages.count().print this show a single number :/

Convert DStream[Long] to Long

2015-04-24 Thread Sergio Jiménez Barrio
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

Re: Convert DStream[Long] to Long

2015-04-24 Thread Sean Owen
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