Package io.trino.util

Class LongLong2LongOpenCustomBigHashMap

java.lang.Object
io.trino.util.LongLong2LongOpenCustomBigHashMap
All Implemented Interfaces:
it.unimi.dsi.fastutil.Hash

public class LongLong2LongOpenCustomBigHashMap extends Object implements it.unimi.dsi.fastutil.Hash
  • Field Details

    • key1

      protected LongBigArray key1
      The array of keys.
    • key2

      protected LongBigArray key2
    • 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.
    • strategy

      The hash strategy of this custom map.
    • 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.
    • defRetValue

      protected long defRetValue
      The default return value for get(), put() and remove().
    • nullKey1

      protected final long nullKey1
      The two-part value denoting unmapped keys (or null keys). These values may be passed back via the HashStrategy callback during equality checks, even though no keys with these values have been added.
    • nullKey2

      protected final long nullKey2
  • Constructor Details

    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2)
      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.
      strategy - the strategy.
      nullKey1 - first half of the representation for unmapped keys.
      nullKey2 - second half of the representation for unmapped keys.
    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2)
      Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor.
      Parameters:
      expected - the expected number of elements in the hash map.
      strategy - the strategy.
    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy)
      Creates a new hash map and zero based null keys.

      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.
      strategy - the strategy.
    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy)
      Creates a new hash map with Hash.DEFAULT_LOAD_FACTOR as load factor and zero based null keys.
      Parameters:
      expected - the expected number of elements in the hash map.
      strategy - the strategy.
    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2)
      Creates a new hash map with initial expected BigArrays.SEGMENT_SIZE entries and Hash.DEFAULT_LOAD_FACTOR as load factor.
      Parameters:
      strategy - the strategy.
      nullKey1 - first half of the representation for unmapped keys.
      nullKey2 - second half of the representation for unmapped keys.
    • LongLong2LongOpenCustomBigHashMap

      public LongLong2LongOpenCustomBigHashMap(LongLong2LongOpenCustomBigHashMap.HashStrategy strategy)
      Creates a new hash map with initial expected BigArrays.SEGMENT_SIZE entries, Hash.DEFAULT_LOAD_FACTOR as load factor, and zero based null keys.
      Parameters:
      strategy - the strategy.
  • Method Details

    • defaultReturnValue

      public void defaultReturnValue(long rv)
    • defaultReturnValue

      public long defaultReturnValue()
    • sizeOf

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

      Returns the hashing strategy.
      Returns:
      the hashing strategy of this custom hash map.
    • put

      public long put(long k1, long k2, long v)
    • addTo

      public long addTo(long k1, long k2, 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:
      k1 - the first half of key.
      k2 - the second half of 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 k1, long k2)
    • get

      public long get(long k1, long k2)
    • containsKey

      public boolean containsKey(long k1, long k2)
    • containsValue

      public boolean containsValue(long v)
    • getOrDefault

      public long getOrDefault(long k1, long k2, long defaultValue)
    • putIfAbsent

      public long putIfAbsent(long k1, long k2, long v)
    • remove

      public boolean remove(long k1, long k2, long v)
    • replace

      public boolean replace(long k1, long k2, long oldValue, long v)
    • replace

      public long replace(long k1, long k2, long v)
    • computeIfAbsent

      public long computeIfAbsent(long k1, long k2, LongBinaryOperator mappingFunction)
    • merge

      public long merge(long k1, long k2, long v, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
    • clear

      public void clear()
    • size

      public long size()
    • isEmpty

      public boolean isEmpty()
    • 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