Documentation of 'org.mapdb.HTreeMap' Java class
HTreeMap
org.mapdb

Class HTreeMap<K,V>

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable, java.lang.AutoCloseable, java.util.concurrent.ConcurrentMap<K,V>, java.util.Map<K,V>, Bind.MapWithModificationListener<K,V>


    public class HTreeMap<K,V>
    extends java.util.AbstractMap<K,V>
    implements java.util.concurrent.ConcurrentMap<K,V>, Bind.MapWithModificationListener<K,V>, java.io.Closeable, java.io.Serializable

    Thread safe concurrent HashMap

    This map uses full 32bit hash from beginning, There is no initial load factor and rehash. Technically it is not hash table, but hash tree with nodes expanding when they become full.

    This map is suitable for number of records 1e9 and over. Larger number of records will increase hash collisions and performance will degrade linearly with number of records (separate chaining).

    Concurrent scalability is achieved by splitting HashMap into 16 segments, each with separate lock. Very similar to ConcurrentHashMap

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      class  HTreeMap.KeySet 
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K,V>
    • Constructor Summary

      Constructors 
      Constructor and Description
      HTreeMap(Engine[] engines, boolean closeEngine, long[] counterRecids, int hashSalt, long[] segmentRecids, Serializer<K> keySerializer, Serializer<V> valueSerializer, long expireTimeStart, long expire, long expireAccess, long expireMaxSize, long expireStoreSize, long[] expireHeads, long[] expireTails, Fun.Function1<V,K> valueCreator, java.util.concurrent.ScheduledExecutorService executor, long executorPeriod, boolean closeExecutor, java.util.concurrent.locks.Lock consistencyLock)
      Opens HTreeMap
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear() 
      void close() 
      boolean containsKey(java.lang.Object o) 
      boolean containsValue(java.lang.Object value) 
      java.util.Set<java.util.Map.Entry<K,V>> entrySet() 
      V get(java.lang.Object o) 
      Engine getEngine() 
      long getMaxExpireTime()
      Returns maximal (newest) expiration timestamp
      long getMinExpireTime()
      Returns minimal (oldest) expiration timestamp
      V getPeek(java.lang.Object key)
      Return given value, without updating cache statistics if expireAccess() is true It also does not use valueCreator if value is not found (always returns null if not found)
      boolean isEmpty() 
      java.util.Set<K> keySet() 
      long mappingCount() 
      void modificationListenerAdd(Bind.MapListener<K,V> listener)
      Add new modification listener notified when Map has been updated
      void modificationListenerRemove(Bind.MapListener<K,V> listener)
      Remove registered notification listener
      V put(K key, V value) 
      V putIfAbsent(K key, V value) 
      V remove(java.lang.Object key) 
      boolean remove(java.lang.Object key, java.lang.Object value) 
      V replace(K key, V value) 
      boolean replace(K key, V oldValue, V newValue) 
      int size() 
      long sizeLong() 
      java.util.Map<K,V> snapshot()
      Make readonly snapshot view of current Map.
      java.util.Collection<V> values() 
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, putAll, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.ConcurrentMap

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
      • Methods inherited from interface java.util.Map

        equals, hashCode, putAll
    • Constructor Detail

      • HTreeMap

        public HTreeMap(Engine[] engines,
                        boolean closeEngine,
                        long[] counterRecids,
                        int hashSalt,
                        long[] segmentRecids,
                        Serializer<K> keySerializer,
                        Serializer<V> valueSerializer,
                        long expireTimeStart,
                        long expire,
                        long expireAccess,
                        long expireMaxSize,
                        long expireStoreSize,
                        long[] expireHeads,
                        long[] expireTails,
                        Fun.Function1<V,K> valueCreator,
                        java.util.concurrent.ScheduledExecutorService executor,
                        long executorPeriod,
                        boolean closeExecutor,
                        java.util.concurrent.locks.Lock consistencyLock)
        Opens HTreeMap
    • Method Detail

      • containsKey

        public boolean containsKey(java.lang.Object o)
        Specified by:
        containsKey in interface java.util.Map<K,V>
        Overrides:
        containsKey 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>
      • mappingCount

        public long mappingCount()
      • isEmpty

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

        public V get(java.lang.Object o)
        Specified by:
        get in interface java.util.Map<K,V>
        Overrides:
        get in class java.util.AbstractMap<K,V>
      • getPeek

        public V getPeek(java.lang.Object key)
        Return given value, without updating cache statistics if expireAccess() is true It also does not use valueCreator if value is not found (always returns null if not found)
        Parameters:
        key - key to lookup
        Returns:
        value associated with key or null
      • 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>
      • 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>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,V>
        Overrides:
        clear 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>
      • 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>
      • 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>
      • getMaxExpireTime

        public long getMaxExpireTime()
        Returns maximal (newest) expiration timestamp
      • getMinExpireTime

        public long getMinExpireTime()
        Returns minimal (oldest) expiration timestamp
      • snapshot

        public java.util.Map<K,V> snapshot()

        Make readonly snapshot view of current Map. Snapshot is immutable and not affected by modifications made by other threads. Useful if you need consistent view on Map.

        Maintaining snapshot have some overhead, underlying Engine is closed after Map view is GCed. Please make sure to release reference to this Map view, so snapshot view can be garbage collected.

        Returns:
        snapshot
      • getEngine

        public Engine getEngine()
      • close

        public void close()
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.lang.AutoCloseable

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.