bx123 created FLINK-25127:
-----------------------------

             Summary: Reuse a single Collection in GlobalWindows#assignWindows
                 Key: FLINK-25127
                 URL: https://issues.apache.org/jira/browse/FLINK-25127
             Project: Flink
          Issue Type: Improvement
          Components: API / DataStream
            Reporter: bx123


When we use GlobalWindow, the window assigner will create a new collection for 
each new stream record. This is not necessary, as the collection is immutable 
and GlobalWindow is singleton and stateless. We can add a static collection 
field in GlobalWindows and return it, to take pressure off the GC.

 

private static final Collection<GlobalWindow> GlobalWindowCollection = 
Collections.singletonList(GlobalWindow.get());

 

@Override
public Collection<GlobalWindow> assignWindows(
Object element, long timestamp, WindowAssignerContext context) {
     return GlobalWindowCollection;
}

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to