-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement MutableTrieMap.computeIfAbsent() #147
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Comments
rovarga
added
enhancement
New feature or request
help wanted
Extra attention is needed
good first issue
Good for newcomers
labels
Apr 13, 2023
Note this has some overlap with #148, hence we need to think about those methods when modifying INode. Both issues seem to have an underlying mechanic in mind, which we need to analyze in terms of meta-meaning and provide a reasonable set of INode methods so we do not end up copy&pasting a ton of code. |
public V computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction) {
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
We currently rely on default implementation from ConcurrentMap. That implementation defers to get() and then to putIfAbsent() -- which means that we end up traversing the tree twice, whereas given the key we know the insertion point.
We should be doing better than that, provided we can plug into our lookup machinery that is :)
The idea is that the get() operation is inevitably finding an existing entry or at least something close to the insertion point. Once we have established that point and the mapping does not exist, we should consult the mapping function. If it produces a non-null value, we should perform an insert operation based on the context.
Implementation-wise this is mostly about INode and its methods: it feels like an extension of recInsertIf().
The text was updated successfully, but these errors were encountered: