Login  Register

(no subject)

classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

(no subject)

tangkailin
2 posts

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 邮件应用

 

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re:

Rong Rong
148 posts
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

--

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?

 

发送自 Windows 10 邮件应用