Class MapMakerInternalMap<K,​V,​E extends MapMakerInternalMap.InternalEntry<K,​V,​E>,​S extends MapMakerInternalMap.Segment<K,​V,​E,​S>>

    • Field Detail

      • MAXIMUM_CAPACITY

        static final int MAXIMUM_CAPACITY
        The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments. MUST be a power of two <= 1<<30 to ensure that entries are indexable using ints.
        See Also:
        Constant Field Values
      • MAX_SEGMENTS

        static final int MAX_SEGMENTS
        The maximum number of segments to allow; used to bound constructor arguments.
        See Also:
        Constant Field Values
      • CONTAINS_VALUE_RETRIES

        static final int CONTAINS_VALUE_RETRIES
        Number of (unsynchronized) retries in the containsValue method.
        See Also:
        Constant Field Values
      • DRAIN_THRESHOLD

        static final int DRAIN_THRESHOLD
        Number of cache access operations that can be buffered per segment before the cache's recency ordering information is updated. This is used to avoid lock contention by recording a memento of reads and delaying a lock acquisition until the threshold is crossed or a mutation occurs.

        This must be a (2^n)-1 as it is used as a mask.

        See Also:
        Constant Field Values
      • DRAIN_MAX

        static final int DRAIN_MAX
        Maximum number of entries to be drained in a single cleanup run. This applies independently to the cleanup queue and both reference queues.
        See Also:
        Constant Field Values
      • CLEANUP_EXECUTOR_DELAY_SECS

        static final long CLEANUP_EXECUTOR_DELAY_SECS
        See Also:
        Constant Field Values
      • segmentMask

        final transient int segmentMask
        Mask value for indexing into segments. The upper bits of a key's hash code are used to choose the segment.
      • segmentShift

        final transient int segmentShift
        Shift value for indexing within segments. Helps prevent entries that end up in the same segment from also ending up in the same bucket.
      • concurrencyLevel

        final int concurrencyLevel
        The concurrency level.
      • keyEquivalence

        final Equivalence<java.lang.Object> keyEquivalence
        Strategy for comparing keys.
      • keySet

        transient java.util.Set<K> keySet
      • values

        transient java.util.Collection<V> values
      • entrySet

        transient java.util.Set<java.util.Map.Entry<K,​V>> entrySet
    • Method Detail

      • rehash

        static int rehash​(int h)
        Applies a supplemental hash function to a given hash code, which defends against poor quality hash functions. This is critical when the concurrent hash map uses power-of-two length hash tables, that otherwise encounter collisions for hash codes that do not differ in lower or upper bits.
        Parameters:
        h - hash code
      • hash

        int hash​(java.lang.Object key)
      • reclaimKey

        void reclaimKey​(E entry)
      • segmentFor

        MapMakerInternalMap.Segment<K,​V,​E,​S> segmentFor​(int hash)
        Returns the segment that should be used for a key with the given hash.
        Parameters:
        hash - the hash code for the key
        Returns:
        the segment
      • getLiveValue

        V getLiveValue​(E entry)
        Gets the value from an entry. Returns null if the entry is invalid, partially-collected or computing.
      • valueEquivalence

        Equivalence<java.lang.Object> valueEquivalence()
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
        Overrides:
        isEmpty in class java.util.AbstractMap<K,​V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.AbstractMap<K,​V>
      • get

        public V get​(@Nullable
                     java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.AbstractMap<K,​V>
      • getEntry

        E getEntry​(@Nullable
                   java.lang.Object key)
        Returns the internal entry for the specified key. The entry may be computing or partially collected. Does not impact recency ordering.
      • containsKey

        public boolean containsKey​(@Nullable
                                   java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Overrides:
        containsKey in class java.util.AbstractMap<K,​V>
      • containsValue

        public boolean containsValue​(@Nullable
                                     java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class java.util.AbstractMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value)
        Specified by:
        putIfAbsent in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        putIfAbsent in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
        Overrides:
        putAll in class java.util.AbstractMap<K,​V>
      • remove

        public V remove​(@Nullable
                        java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.AbstractMap<K,​V>
      • remove

        public boolean remove​(@Nullable
                              java.lang.Object key,
                              @Nullable
                              java.lang.Object value)
        Specified by:
        remove in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        remove in interface java.util.Map<K,​V>
      • replace

        public boolean replace​(K key,
                               @Nullable
                               V oldValue,
                               V newValue)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        replace in interface java.util.Map<K,​V>
      • replace

        public V replace​(K key,
                         V value)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        replace in interface java.util.Map<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class java.util.AbstractMap<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Overrides:
        keySet in class java.util.AbstractMap<K,​V>
      • values

        public java.util.Collection<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
        Overrides:
        values in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • toArrayList

        private static <E> java.util.ArrayList<E> toArrayList​(java.util.Collection<E> c)
      • writeReplace

        java.lang.Object writeReplace()