[jira] [Created] (FLINK-16940) Avoid creating currentRegion HashSet with manually set initialCapacity

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-16940) Avoid creating currentRegion HashSet with manually set initialCapacity

Shang Yuanchun (Jira)
Gary Yao created FLINK-16940:
--------------------------------

             Summary: Avoid creating currentRegion HashSet with manually set initialCapacity
                 Key: FLINK-16940
                 URL: https://issues.apache.org/jira/browse/FLINK-16940
             Project: Flink
          Issue Type: Bug
          Components: Runtime / REST
    Affects Versions: 1.11.0
            Reporter: Gary Yao
            Assignee: Gary Yao
             Fix For: 1.11.0


The {{currentRegion}} HashSet in {{PipelinedRegionComputeUtil}} is created with an initialCapacity of 1. This is wrong because when we add the first element, the sets capacity will be already increased. From the style guidelines:
{quote}
Set the initial capacity for a collection only if there is a good proven reason for that, otherwise do not clutter the code. In case of Maps it can be even deluding because the Map’s load factor effectively reduces the capacity.
{quote}
https://flink.apache.org/contributing/code-style-and-quality-java.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)