flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ZalaCheung <gzzhangdesh...@corp.netease.com>
Subject How to maintain variable for each map operator
Date Thu, 13 Jul 2017 05:14:10 GMT
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{
        DataStream input = ...
        stream.keyby("some key").map(
                if(queue.size() < some_num){
                    //do something
    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: gzzhangdesheng@corp.netease.com;

View raw message