You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by robertdale <gi...@git.apache.org> on 2017/11/10 04:07:00 UTC

[GitHub] tinkerpop issue #745: TINKERPOP-1830: fix race condition in TinkerIndex

Github user robertdale commented on the issue:

    https://github.com/apache/tinkerpop/pull/745
  
    The race condition is in `put()` and it's used elsewhere. It would make more sense to fix `put()` to be thread-safe.  Then we can keep `parallelStream()`
    
    ```
            Map<Object, Set<T>> keyMap = this.index.get(key);
            if (keyMap == null) {
                keyMap = this.index.putIfAbsent(key, new ConcurrentHashMap<>());
            }
            Set<T> objects = keyMap.get(value);
            if (null == objects) {
                objects = keyMap.putIfAbsent(value, ConcurrentHashMap.newKeySet());
            }
            objects.add(element);
    ```


---