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?
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].
On Wed, Jul 17, 2019 at 7:37 PM tangkailin <[hidden email]> wrote:
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?