Re:
Posted by
Rong Rong on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/no-subject-tp28816p28840.html
Hi Tangkailin,
If I understand correctly from the snippet, you are trying to invoke this in some sort of window correct?
If that's the case, your "apply" method will be invoked every time at the window fire[1]. This means there will be one new instance of the HashMap created each time "apply" is invoked.
So to answer your question: no, the HashMap is never a singleton, it will be created everytime "apply" is called.
If you would like to store data across different invoke (e.g. share data between different calls to the "apply" function) you are better off using the ProcessWindowFunction[2].
Thanks,
Rong
--
Hello,
I am trying to use HashMap In my window function of flink job. if the parallelism change, is this hashmap still a singleton? Shouldn’t I do something similar here?

发送自 Windows 10 版邮件应用