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

Improve support for value transformations #148

Open
rovarga opened this issue Apr 13, 2023 · 0 comments
Open

Improve support for value transformations #148

rovarga opened this issue Apr 13, 2023 · 0 comments

Comments

@rovarga
Copy link
Collaborator

rovarga commented Apr 13, 2023

We currently rely on ConcurrentMap's default implementations of compute(), computeIfPresent() and merge() methods.

This has two downsides:

  • we end up traversing the TrieMap multiple times (get() + putIfAbsent()/replace()/remove() invocations)
  • the computation function may be invoked multiple times if face of races

Implement these methods for MutableTrieMap, so the traversal is minimized and we call the mapping function as little as possible.

This is a mixed bag a bit, but mostly revolves around INode operations. computeIfPresent() is essentially a replace(), except the value to store is computed when we have found a matching node. compute() combines that with an insert operation (in case of non-presence, which something #147 deals with). merge() combines all these together, based on lookup result and mapping function result.

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

No branches or pull requests

1 participant