Class GridUnsafeMap

    • Constructor Detail

      • GridUnsafeMap

        public GridUnsafeMap​(int concurrency,
                             float load,
                             long initCap,
                             long totalMem,
                             short lruStripes,
                             @Nullable
                             @Nullable GridOffHeapEvictListener evictLsnr)
        Parameters:
        concurrency - Concurrency.
        load - Load factor.
        initCap - Initial capacity.
        totalMem - Total memory.
        lruStripes - Number of LRU stripes.
        evictLsnr - Eviction listener.
    • Method Detail

      • eventListener

        public boolean eventListener​(GridOffHeapEventListener evtLsnr)
        Adds off-heap event listener.
        Specified by:
        eventListener in interface GridOffHeapMap
        Parameters:
        evtLsnr - Listener.
        Returns:
        True if event listener was added, false if another listener already exists.
      • evictListener

        public boolean evictListener​(GridOffHeapEvictListener evictLsnr)
        Sets callback for when entries are evicted due to memory constraints. The parameter into closure is key bytes.
        Specified by:
        evictListener in interface GridOffHeapMap
        Parameters:
        evictLsnr - Evict listener.
        Returns:
        True if evict listener was added, false if another listener already exists or LRU is disabled.
      • partition

        public int partition()
        Gets partition this map belongs to.
        Specified by:
        partition in interface GridOffHeapMap
        Returns:
        Partition this map belongs to.
      • loadFactor

        public float loadFactor()
        Gets load factor of this map.
        Specified by:
        loadFactor in interface GridOffHeapMap
        Returns:
        Load factor.
      • concurrency

        public int concurrency()
        Gets concurrency level for this map.
        Specified by:
        concurrency in interface GridOffHeapMap
        Returns:
        Concurrency level.
      • contains

        public boolean contains​(int hash,
                                byte[] keyBytes)
        Checks if given key is contained in the map.
        Specified by:
        contains in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        True if key is contained in the map.
      • get

        public byte[] get​(int hash,
                          byte[] keyBytes)
        Gets value bytes for given key.
        Specified by:
        get in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        Value bytes.
      • valuePointer

        @Nullable
        public @Nullable IgniteBiTuple<Long,​Integer> valuePointer​(int hash,
                                                                        byte[] keyBytes)
        Gets value pointer for given key.
        Specified by:
        valuePointer in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        Value pointer.
      • enableEviction

        public void enableEviction​(int hash,
                                   byte[] keyBytes)
        Enables eviction for given key.
        Specified by:
        enableEviction in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
      • remove

        public byte[] remove​(int hash,
                             byte[] keyBytes)
        Removes value from off-heap map.
        Specified by:
        remove in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        Removed value bytes.
      • removex

        public boolean removex​(int hash,
                               byte[] keyBytes)
        Removes value from off-heap map without returning it.
        Specified by:
        removex in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        True if value was removed.
      • removex

        public boolean removex​(int hash,
                               byte[] keyBytes,
                               IgniteBiPredicate<Long,​Integer> p)
        Removes value from off-heap map without returning it.
        Specified by:
        removex in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        p - Value predicate (arguments are value address and value length).
        Returns:
        True if value was removed.
      • put

        public boolean put​(int hash,
                           byte[] keyBytes,
                           byte[] valBytes)
        Puts key and value bytes into the map potentially replacing existing entry.
        Specified by:
        put in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        valBytes - Value bytes.
        Returns:
        True if new entry was created, false if existing value was updated.
      • insert

        public void insert​(int hash,
                           byte[] keyBytes,
                           byte[] valBytes)
        Inserts new entry into the map without comparing if there is a mapping for given key already stored in map.

        Use with caution whenever certain that inserting a new value without current mapping.

        Specified by:
        insert in interface GridOffHeapMap
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        valBytes - Value bytes.
      • totalSize

        public long totalSize()
        Gets number of elements in the map.
        Specified by:
        totalSize in interface GridOffHeapMap
        Returns:
        Number of elements in the map.
      • size

        public long size()
        Gets number of elements in the map.
        Specified by:
        size in interface GridOffHeapMap
        Returns:
        Number of elements in the map.
      • memorySize

        public long memorySize()
        Gets total available memory size.
        Specified by:
        memorySize in interface GridOffHeapMap
        Returns:
        Memory size.
      • allocatedSize

        public long allocatedSize()
        Gets memory allocated for map entries so far.
        Specified by:
        allocatedSize in interface GridOffHeapMap
        Returns:
        Allocated memory.
      • systemAllocatedSize

        public long systemAllocatedSize()
        Gets memory allocated for map internal structure so far.
        Specified by:
        systemAllocatedSize in interface GridOffHeapMap
        Returns:
        Allocated memory.
      • freeSize

        public long freeSize()
        Gets available memory.
        Specified by:
        freeSize in interface GridOffHeapMap
        Returns:
        Available memory.
      • destruct

        public void destruct()
        Destructs this map and deallocates all memory.
        Specified by:
        destruct in interface GridOffHeapMap
      • lruStripes

        public short lruStripes()
        Gets number of LRU stripes.
        Returns:
        Number of LRU stripes.
      • lruMemorySize

        public long lruMemorySize()
        Gets memory size occupied by LRU queue.
        Returns:
        Memory size occupied by LRU queue.
      • lruSize

        public long lruSize()
        Gets number of elements in LRU queue.
        Returns:
        Number of elements in LRU queue.