Hi,

I think you can use State to achieve your goal:
https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/stream/state.html

Best,
Kurt

On Thu, Jul 13, 2017 at 1:14 PM, ZalaCheung <gzzhangdesh...@corp.netease.com
> wrote:

> Hi all,
>
> I am stuck with a problem. I have a stream, I want keyby it and then do a
> map function on it.  But for each map operator, I want to maintain a
> variable for it. Is that possible? I tried a naive version on local
> IntelliJ IDE and it works. But I got nullpointerException while trying to
> run it on a cluster.
>
> Here is the pseudo code for my naive version, wish it will help you guys
> understand my question.
>
> public class anomalydetection{
>    private static List<TimeSeries> queue;
>    public static void main(String[] args)throws Exception{
>         initialize();
>         getStreamExecutionEnvironment();
>         DataStream input = ...
>         stream.keyby("some key").map(
>             MapFunction(){
>                 if(queue.size() < some_num){
>                     queue.add()
>                     //do something
>                 }
>                 else{
>                     //dosomething
>                 }
>             }
>         )
>
>     public void initialize(){
>         queue = new ArrayList<>();
>     }}
>
>
> when I try to get the size of the arraylist, I get a
> *NullPointerException*. Beside that, I want  to *maintain a list for each
> map operator after I group the stream by some key*.
>
>
> Is that possible to do what I want in Flink?
>
> Desheng Zhang
>
> E-mail: gzzhangdesh...@corp.netease.com;
>
>

Reply via email to