Class ShardedMap<K,​V>

  • Type Parameters:
    K - the key type
    V - the value type
    All Implemented Interfaces:
    java.util.Map<K,​V>

    public class ShardedMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    A sharded map. It is typically split into multiple sub-maps that don't have overlapping keys.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ShardedMap.CountedMap<K,​V>
      A map that can efficiently return the index of a key, and the key at a given index.
      static interface  ShardedMap.LargeMap
      A large map.
      • Nested classes/interfaces inherited from class java.util.AbstractMap

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

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMap​(java.util.Map<K,​V> map, K min, K max)
      Add the given shard.
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)  
      V put​(K key, V value)  
      int size()  
      long sizeAsLong()
      The size of the map.
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • ShardedMap

        public ShardedMap()
      • ShardedMap

        public ShardedMap​(DataType keyType)
    • Method Detail

      • addMap

        public void addMap​(java.util.Map<K,​V> map,
                           K min,
                           K max)
        Add the given shard.
        Parameters:
        map - the map
        min - the lowest key, or null if no limit
        max - the highest key, or null if no limit
      • size

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

        public long sizeAsLong()
        The size of the map.
        Returns:
        the size
      • 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>
      • 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>
      • 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>