Class SynchronizedHashMultiMap<K,​V>

  • public class SynchronizedHashMultiMap<K,​V>
    extends java.lang.Object
    Simple multimap implementation that only stores key reference once.

    Implementation is aimed at storing PerChannelBookieClient completions when there are duplicates. If the key is a pooled object, it must not exist once the value has been removed from the map, which can happen with guava multimap implementations.

    With this map is implemented with pretty heavy locking, but this shouldn't be an issue as the multimap only needs to be used in rare cases, i.e. when a user tries to read or the same entry twice at the same time. This class should *NOT* be used in critical path code.

    A unique key-value pair will only be stored once.

    • Field Summary

      Modifier and Type Field Description
      (package private) java.util.HashMap<java.lang.Integer,​java.util.Set<org.apache.commons.lang3.tuple.Pair<K,​V>>> map  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<K> getAnyKey()  
      void put​(K k, V v)  
      java.util.Optional<V> removeAny​(K k)  
      int removeIf​(java.util.function.BiPredicate<K,​V> predicate)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • map

        java.util.HashMap<java.lang.Integer,​java.util.Set<org.apache.commons.lang3.tuple.Pair<K,​V>>> map
    • Constructor Detail

      • SynchronizedHashMultiMap

        public SynchronizedHashMultiMap()
    • Method Detail

      • put

        public void put​(K k,
                        V v)
      • getAnyKey

        public java.util.Optional<K> getAnyKey()
      • removeAny

        public java.util.Optional<V> removeAny​(K k)
      • removeIf

        public int removeIf​(java.util.function.BiPredicate<K,​V> predicate)