Package io.trino.util

Class Long2LongOpenBigHashMap

java.lang.Object
it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction
it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
io.trino.util.Long2LongOpenBigHashMap
All Implemented Interfaces:
it.unimi.dsi.fastutil.Function<Long,Long>, it.unimi.dsi.fastutil.Hash, it.unimi.dsi.fastutil.longs.Long2LongFunction, it.unimi.dsi.fastutil.longs.Long2LongMap, Serializable, Function<Long,Long>, LongUnaryOperator, Map<Long,Long>

public class Long2LongOpenBigHashMap extends it.unimi.dsi.fastutil.longs.AbstractLong2LongMap implements it.unimi.dsi.fastutil.Hash
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap

    it.unimi.dsi.fastutil.longs.AbstractLong2LongMap.BasicEntry, it.unimi.dsi.fastutil.longs.AbstractLong2LongMap.BasicEntrySet

    Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.Hash

    it.unimi.dsi.fastutil.Hash.Strategy<K>

    Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.longs.Long2LongMap

    it.unimi.dsi.fastutil.longs.Long2LongMap.Entry, it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Whether this map contains the key zero.
    protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet
    Cached set of entries.
    protected final float
    The acceptable load factor.
    protected LongBigArray
    The array of keys.
    protected it.unimi.dsi.fastutil.longs.LongSet
    Cached set of keys.
    protected long
    The mask for wrapping a position counter.
    protected long
    Threshold after which we rehash.
    protected final long
    We never resize below this threshold, which is the construction-time {#n}.
    protected long
    The current table size.
    protected long
    Number of entries in the set (including the key zero, if present).
    protected LongBigArray
    The array of values.
    protected it.unimi.dsi.fastutil.longs.LongCollection
    Cached collection of values.

    Fields inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction

    defRetValue

    Fields inherited from interface it.unimi.dsi.fastutil.Hash

    DEFAULT_GROWTH_FACTOR, DEFAULT_INITIAL_SIZE, DEFAULT_LOAD_FACTOR, FAST_LOAD_FACTOR, FREE, OCCUPIED, PRIMES, REMOVED, VERY_FAST_LOAD_FACTOR
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new hash map with initial expected BigArrays.SEGMENT_SIZE entries and Hash.DEFAULT_LOAD_FACTOR as load factor.
    Long2LongOpenBigHashMap(long expected)
    Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor.
    Long2LongOpenBigHashMap(long expected, float f)
    Creates a new hash map.
    Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m)
    Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor copying a given type-specific one.
    Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m, float f)
    Creates a new hash map copying a given type-specific one.
    Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m)
    Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor copying a given one.
    Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m, float f)
    Creates a new hash map copying a given one.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    addTo(long k, long incr)
    Adds an increment to value currently associated with a key.
    void
    long
    compute(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
    long
    computeIfAbsent(long k, LongUnaryOperator mappingFunction)
    long
    computeIfAbsentNullable(long k, LongFunction<? extends Long> mappingFunction)
    long
    computeIfPresent(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
    boolean
    containsKey(long k)
     
    boolean
    containsValue(long v)
     
    long
    get(long k)
     
    long
    getOrDefault(long k, long defaultValue)
    boolean
     
    it.unimi.dsi.fastutil.longs.LongSet
     
    it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet
     
    long
    merge(long k, long v, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
    long
    put(long k, long v)
     
    void
    putAll(Map<? extends Long,? extends Long> m)
     
    long
    putIfAbsent(long k, long v)
    protected void
    rehash(long newN)
    Rehashes the map.
    long
    remove(long k)
     
    boolean
    remove(long k, long v)
    long
    replace(long k, long v)
    boolean
    replace(long k, long oldValue, long v)
    protected final void
    shiftKeys(long pos)
    Shifts left entries with the specified hash code, starting at the specified position, and empties the resulting free entry.
    int
     
    long
    Returns the size of this hash map in bytes.
    boolean
    Rehashes the map, making the table as small as possible.
    boolean
    trim(long n)
    Rehashes this map if the table is too large.
    it.unimi.dsi.fastutil.longs.LongCollection
     

    Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap

    equals, hashCode, mergeLong, toString

    Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction

    defaultReturnValue, defaultReturnValue

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface it.unimi.dsi.fastutil.Function

    apply

    Methods inherited from interface it.unimi.dsi.fastutil.longs.Long2LongFunction

    andThen, andThenByte, andThenChar, andThenDouble, andThenFloat, andThenInt, andThenLong, andThenObject, andThenReference, andThenShort, applyAsLong, compose, composeByte, composeChar, composeDouble, composeFloat, composeInt, composeLong, composeObject, composeReference, composeShort

    Methods inherited from interface it.unimi.dsi.fastutil.longs.Long2LongMap

    compute, computeIfAbsent, computeIfAbsent, computeIfAbsentPartial, computeIfPresent, containsKey, containsValue, defaultReturnValue, defaultReturnValue, entrySet, forEach, get, getOrDefault, merge, mergeLong, put, putIfAbsent, remove, remove, replace, replace

    Methods inherited from interface java.util.function.LongUnaryOperator

    andThen, compose

    Methods inherited from interface java.util.Map

    replaceAll
  • Field Details

    • key

      protected LongBigArray key
      The array of keys.
    • value

      protected LongBigArray value
      The array of values.
    • mask

      protected long mask
      The mask for wrapping a position counter.
    • containsNullKey

      protected boolean containsNullKey
      Whether this map contains the key zero.
    • n

      protected long n
      The current table size.
    • maxFill

      protected long maxFill
      Threshold after which we rehash. It must be the table size times f.
    • minN

      protected final long minN
      We never resize below this threshold, which is the construction-time {#n}.
    • size

      protected long size
      Number of entries in the set (including the key zero, if present).
    • f

      protected final float f
      The acceptable load factor.
    • entries

      protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet entries
      Cached set of entries.
    • keys

      protected it.unimi.dsi.fastutil.longs.LongSet keys
      Cached set of keys.
    • values

      protected it.unimi.dsi.fastutil.longs.LongCollection values
      Cached collection of values.
  • Constructor Details

    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(long expected, float f)
      Creates a new hash map.

      The actual table size will be the least power of two greater than expected/f.

      Parameters:
      expected - the expected number of elements in the hash map.
      f - the load factor.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(long expected)
      Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor.
      Parameters:
      expected - the expected number of elements in the hash map.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap()
      Creates a new hash map with initial expected BigArrays.SEGMENT_SIZE entries and Hash.DEFAULT_LOAD_FACTOR as load factor.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m, float f)
      Creates a new hash map copying a given one.
      Parameters:
      m - a Map to be copied into the new hash map.
      f - the load factor.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m)
      Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor copying a given one.
      Parameters:
      m - a Map to be copied into the new hash map.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m, float f)
      Creates a new hash map copying a given type-specific one.
      Parameters:
      m - a type-specific map to be copied into the new hash map.
      f - the load factor.
    • Long2LongOpenBigHashMap

      public Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m)
      Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor copying a given type-specific one.
      Parameters:
      m - a type-specific map to be copied into the new hash map.
  • Method Details

    • sizeOf

      public long sizeOf()
      Returns the size of this hash map in bytes.
    • putAll

      public void putAll(Map<? extends Long,? extends Long> m)
      Specified by:
      putAll in interface Map<Long,Long>
      Overrides:
      putAll in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • put

      public long put(long k, long v)
      Specified by:
      put in interface it.unimi.dsi.fastutil.longs.Long2LongFunction
    • addTo

      public long addTo(long k, long incr)
      Adds an increment to value currently associated with a key.

      Note that this method respects the default return value semantics: when called with a key that does not currently appears in the map, the key will be associated with the default return value plus the given increment.

      Parameters:
      k - the key.
      incr - the increment.
      Returns:
      the old value, or the default return value if no value was present for the given key.
    • shiftKeys

      protected final void shiftKeys(long pos)
      Shifts left entries with the specified hash code, starting at the specified position, and empties the resulting free entry.
      Parameters:
      pos - a starting position.
    • remove

      public long remove(long k)
      Specified by:
      remove in interface it.unimi.dsi.fastutil.longs.Long2LongFunction
    • get

      public long get(long k)
      Specified by:
      get in interface it.unimi.dsi.fastutil.longs.Long2LongFunction
    • containsKey

      public boolean containsKey(long k)
      Specified by:
      containsKey in interface it.unimi.dsi.fastutil.longs.Long2LongFunction
      Specified by:
      containsKey in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Overrides:
      containsKey in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • containsValue

      public boolean containsValue(long v)
      Specified by:
      containsValue in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Overrides:
      containsValue in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • getOrDefault

      public long getOrDefault(long k, long defaultValue)
      Specified by:
      getOrDefault in interface it.unimi.dsi.fastutil.longs.Long2LongFunction
      Specified by:
      getOrDefault in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • putIfAbsent

      public long putIfAbsent(long k, long v)
      Specified by:
      putIfAbsent in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • remove

      public boolean remove(long k, long v)
      Specified by:
      remove in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • replace

      public boolean replace(long k, long oldValue, long v)
      Specified by:
      replace in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • replace

      public long replace(long k, long v)
      Specified by:
      replace in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • computeIfAbsent

      public long computeIfAbsent(long k, LongUnaryOperator mappingFunction)
      Specified by:
      computeIfAbsent in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • computeIfAbsentNullable

      public long computeIfAbsentNullable(long k, LongFunction<? extends Long> mappingFunction)
      Specified by:
      computeIfAbsentNullable in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • computeIfPresent

      public long computeIfPresent(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
      Specified by:
      computeIfPresent in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • compute

      public long compute(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
      Specified by:
      compute in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • merge

      public long merge(long k, long v, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
      Specified by:
      merge in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • clear

      public void clear()

      To increase object reuse, this method does not change the table size. If you want to reduce the table size, you must use trim().

      Specified by:
      clear in interface it.unimi.dsi.fastutil.Function<Long,Long>
      Specified by:
      clear in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Specified by:
      clear in interface Map<Long,Long>
    • size

      public int size()
      Specified by:
      size in interface it.unimi.dsi.fastutil.Function<Long,Long>
      Specified by:
      size in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Specified by:
      size in interface Map<Long,Long>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<Long,Long>
      Overrides:
      isEmpty in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • long2LongEntrySet

      public it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet long2LongEntrySet()
      Specified by:
      long2LongEntrySet in interface it.unimi.dsi.fastutil.longs.Long2LongMap
    • keySet

      public it.unimi.dsi.fastutil.longs.LongSet keySet()
      Specified by:
      keySet in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Specified by:
      keySet in interface Map<Long,Long>
      Overrides:
      keySet in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • values

      public it.unimi.dsi.fastutil.longs.LongCollection values()
      Specified by:
      values in interface it.unimi.dsi.fastutil.longs.Long2LongMap
      Specified by:
      values in interface Map<Long,Long>
      Overrides:
      values in class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
    • trim

      public boolean trim()
      Rehashes the map, making the table as small as possible.

      This method rehashes the table to the smallest size satisfying the load factor. It can be used when the set will not be changed anymore, so to optimize access speed and size.

      If the table size is already the minimum possible, this method does nothing.

      Returns:
      true if there was enough memory to trim the map.
      See Also:
    • trim

      public boolean trim(long n)
      Rehashes this map if the table is too large.

      Let N be the smallest table size that can hold max(n,size()) entries, still satisfying the load factor. If the current table size is smaller than or equal to N, this method does nothing. Otherwise, it rehashes this map in a table of size N.

      This method is useful when reusing maps. Clearing a map leaves the table size untouched. If you are reusing a map many times, you can call this method with a typical size to avoid keeping around a very large table just because of a few large transient maps.

      Parameters:
      n - the threshold for the trimming.
      Returns:
      true if there was enough memory to trim the map.
      See Also:
    • rehash

      protected void rehash(long newN)
      Rehashes the map.

      This method implements the basic rehashing strategy, and may be overridden by subclasses implementing different rehashing strategies (e.g., disk-based rehashing). However, you should not override this method unless you understand the internal workings of this class.

      Parameters:
      newN - the new size