The documentation says this about Session Windows:
Since session windows do not have a fixed start and end, they are evaluated differently than tumbling and sliding windows. Internally, a session window operator creates a new window for each arriving record and merges windows together if they are closer to each other than the defined gap. In order to be mergeable, a session window operator requires a merging Trigger and a merging Window Function, such as ReduceFunction, AggregateFunction, or ProcessWindowFunction.
In another stackoverflow answer, it was stated that
Flink will create new accumulators as necessary (e.g., for each new window).
Does this mean that a createAccumulator() is called for every event that arrives to my stream partitioned by the key? And then merge() is called every time when the gap turns out to be less than defined session gap?
In my implementation, createAccumulator() creates an object and that object itself is returned in getResult() after the necessary updates are made to its fields inside add(). I wanted to know if the same object will be shared by all windows within a partition (i.e. all the events with the same key) or if a new instance of the object is created and returned for every window.
Does this mean that a createAccumulator() is called for every event that arrives to my stream partitioned by the key? And then merge() is called every time when the gap turns out to be less than defined session gap?
Yes, that's how it works when using an AggregateFunction with session windows.