Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2417 Explore reimplementing HashMap as CHAMP (Compressed Hash-Array Mapped Prefix-tree) #2745

Open
wants to merge 181 commits into
base: version/1.x
Choose a base branch
from

Conversation

wrandelshofer
Copy link

This is a draft intended for discussion.

This merge requests explores how a migration of the HAMT trie to a CHAMP trie could look like:

  • HashSet, HashMap: Replaces the internal HAMT data structure by a CHAMP data structure.
  • LinkedHashSet, LinkedHashMap: Replaces the internal HAMT+Seq data strucures by CHAMP+Vector data structures.
  • The changes are intended to affect the performance of vavr, but are not supposed to change any API.

The changes are somewhat sub-optimal and somewhat over-complicated, because I strived to not break any of the unit tests. (I believe that I should change a number of unit tests, because some rely on the iteration sequence of the HAMT implementation. However, the vavr API specifies that the iteration sequence is unspecified.)

The code is a port from the JHotDraw 8 collections module. https://github.com/wrandelshofer/jhotdraw8/tree/main/org.jhotdraw8.collection
The JHotDraw 8 collections are in turn a port of the 'capsule' collection library https://github.com/usethesource/capsule, and of vavr.

I do not expect that this draft can be merged in the current form. In JHotDraw 8 we have a mutable 'partner' collection for every immutable collection. This allows to test all immutable collections with the 'guava-testlib' library. Which provides very through tests. I did not want to change the API of vavr - so I have downgraded the mutable collections to transient collections. But I have not written new tests yet. So code coverage by unit tests is currently lower than I want it to be.

@wrandelshofer
Copy link
Author

I made now a release that is binary compatible with vavr 0.10.5.

You can get it here: https://github.com/wrandelshofer/vavr/releases/tag/v0.10.5

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 70.56169% with 587 lines in your changes missing coverage. Please review.

Project coverage is 89.24%. Comparing base (e43e44b) to head (734fc83).
Report is 73 commits behind head on master.

Files with missing lines Patch % Lines
src/main/java/io/vavr/collection/ChampTrie.java 50.00% 252 Missing and 63 partials ⚠️
...c/main/java/io/vavr/collection/ChampSequenced.java 49.74% 89 Missing and 8 partials ⚠️
...rc/main/java/io/vavr/collection/LinkedHashSet.java 81.38% 35 Missing and 8 partials ⚠️
src/main/java/io/vavr/collection/HashSet.java 76.78% 32 Missing and 7 partials ⚠️
...rc/main/java/io/vavr/collection/LinkedHashMap.java 89.11% 24 Missing and 13 partials ⚠️
.../main/java/io/vavr/collection/ChampTransience.java 68.11% 14 Missing and 8 partials ⚠️
src/main/java/io/vavr/collection/HashMap.java 90.59% 6 Missing and 13 partials ⚠️
...c/main/java/io/vavr/collection/ChampIteration.java 88.23% 5 Missing and 3 partials ⚠️
...rc/main/java/io/vavr/collection/BitMappedTrie.java 86.66% 4 Missing ⚠️
src/main/java/io/vavr/collection/Vector.java 95.16% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2745      +/-   ##
============================================
- Coverage     92.74%   89.24%   -3.50%     
- Complexity     5247     5294      +47     
============================================
  Files            89       92       +3     
  Lines         12538    13844    +1306     
  Branches       1604     1857     +253     
============================================
+ Hits          11628    12355     +727     
- Misses          721     1187     +466     
- Partials        189      302     +113     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant