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

--
[1]
https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/operators/windows.html#windowfunction-legacy
[2]
https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/operators/windows.html#processwindowfunction

On Wed, Jul 17, 2019 at 7:37 PM tangkailin <tkl...@126.com> 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 版邮件 <https://go.microsoft.com/fwlink/?LinkId=550986>应用
>
>
>

Reply via email to