You can use a 1 minute tumbling window

dstream.window(Minutes(1), Minutes(1)).foreachRDD { rdd =>
   // calculate stats per key
}

On Thu, Jan 21, 2016 at 4:59 AM, Santoshakhilesh <
[email protected]> wrote:

> Hi,
>
> I have following scenario in my project;
>
> 1.    I will continue to get a stream of data from a source
>
> 2.    I need to calculate mean and variance for a key every minute
>
> 3.    After minute is over I should restart fresh computing the values
> for new minute
>
> Example:
>
> *10:00:00 computation and output*
>
> 10:00:00 key =1 , mean = 10 , variance =2
>
> 10:00:00 key =N , mean = 10 , variance =2
>
> *10:00:01 computation and output*
>
> 10:00:00 key =1 , mean = 11 , variance =2
>
> 10:00:00 key =N , mean = 12 , variance =2
>
> *10:00:01 data has no dependency with 10:00:00*
>
> How to setup such jobs in a single java spark streaming application.
>
> Regards,|
>
> Santosh Akhilesh
>
>
>

Reply via email to