Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-32410

Allocate hash-based collections with sufficient capacity for expected size

    XMLWordPrintableJSON

Details

    Description

      The JDK API to create hash-based collections for a certain capacity is arguable misleading because it doesn't size the collections to "hold a specific number of items" like you'd expect it would. Instead it sizes it to hold load-factor% of the specified number.

      For the common pattern to allocate a hash-based collection with the size of expected elements to avoid rehashes, this means that a rehash is essentially guaranteed.

      We should introduce helper methods (similar to Guava's `Maps.newHashMapWithExpectedSize(int)`) for allocations for expected size and replace the direct constructor calls with those.

      Attachments

        Issue Links

          Activity

            People

              srichter Stefan Richter
              srichter Stefan Richter
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: