Class AbstractConcurrentOffHeapMap<K,​V>

    • Field Detail

      • segments

        protected final Segment<K,​V>[] segments
      • segmentShift

        private final int segmentShift
      • segmentMask

        private final int segmentMask
      • keySet

        private java.util.Set<K> keySet
      • entrySet

        private java.util.Set<java.util.Map.Entry<K,​V>> entrySet
      • values

        private java.util.Collection<V> values
    • Constructor Detail

      • AbstractConcurrentOffHeapMap

        public AbstractConcurrentOffHeapMap​(Factory<? extends Segment<K,​V>> segmentFactory)
        Create a concurrent map using a default number of segments.
        Parameters:
        segmentFactory - factory used to create the map segments
      • AbstractConcurrentOffHeapMap

        public AbstractConcurrentOffHeapMap​(Factory<? extends Segment<K,​V>> segmentFactory,
                                            int concurrency)
        Create a concurrent map with a defined number of segments.
        Parameters:
        segmentFactory - factory used to create the map segments
        concurrency - number of segments in the map
        Throws:
        java.lang.IllegalArgumentException - if the supplied number of segments is negative
    • Method Detail

      • segmentFor

        protected Segment<K,​V> segmentFor​(java.lang.Object key)
      • segmentFor

        protected Segment<K,​V> segmentFor​(int hash)
      • getIndexFor

        public int getIndexFor​(int hash)
      • getSegments

        public java.util.List<Segment<K,​V>> getSegments()
      • getConcurrency

        protected int getConcurrency()
      • spread

        private static int spread​(int hash)
      • size

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

        public boolean containsKey​(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​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class java.util.AbstractMap<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get 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>
      • put

        public V put​(K key,
                     V value,
                     int metadata)
      • fill

        public V fill​(K key,
                      V value)
        See OffHeapHashMap.fill(Object, Object) for a detailed description.
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key (irrespective of whether the value was successfully installed).
      • fill

        public V fill​(K key,
                      V value,
                      int metadata)
      • remove

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

        public boolean removeNoReturn​(java.lang.Object key)
      • getMetadata

        public java.lang.Integer getMetadata​(K key,
                                             int mask)
                                      throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getAndSetMetadata

        public java.lang.Integer getAndSetMetadata​(K key,
                                                   int mask,
                                                   int values)
                                            throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getValueAndSetMetadata

        public V getValueAndSetMetadata​(K key,
                                        int mask,
                                        int values)
      • clear

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

        public void destroy()
      • 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>
      • remove

        public boolean remove​(java.lang.Object key,
                              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,
                               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>
      • 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>
      • readLockAll

        protected void readLockAll()
      • readUnlockAll

        protected void readUnlockAll()
      • writeLockAll

        public final void writeLockAll()
      • writeUnlockAll

        public final void writeUnlockAll()
      • handleOversizeMappingException

        public final boolean handleOversizeMappingException​(int hash)
      • computeIfAbsentWithMetadata

        public MetadataTuple<V> computeIfAbsentWithMetadata​(K key,
                                                            java.util.function.Function<? super K,​? extends MetadataTuple<V>> mappingFunction)
      • removeAllWithHash

        public java.util.Map<K,​V> removeAllWithHash​(int keyHash)
        Description copied from interface: HashingMap
        Remove all keys having a specific hashcode.
        Specified by:
        removeAllWithHash in interface HashingMap<K,​V>
        Parameters:
        keyHash - the hashcode of the keys to be removed.
        Returns:
        a Map containing the removed mappings.