Skip to content

Improve support for value transformations #148

@rovarga

Description

@rovarga

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions