Class GridUnsafePartitionedMap

    • Constructor Detail

      • GridUnsafePartitionedMap

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

      • contains

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

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

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

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

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

        public boolean removex​(int part,
                               int hash,
                               byte[] keyBytes,
                               IgniteBiPredicate<Long,​Integer> p)
        Removes value from off-heap map without returning it.
        Specified by:
        removex in interface GridOffHeapPartitionedMap
        Parameters:
        part - Partition.
        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 p,
                           int hash,
                           byte[] keyBytes,
                           byte[] valBytes)
        Puts key and value bytes into the map potentially replacing existing entry.
        Specified by:
        put in interface GridOffHeapPartitionedMap
        Parameters:
        p - Partition.
        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 p,
                           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 GridOffHeapPartitionedMap
        Parameters:
        p - Partition.
        hash - Hash.
        keyBytes - Key bytes.
        valBytes - Value bytes.
      • size

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

        public long size​(Set<Integer> parts)
        Gets number of elements in the map.
        Specified by:
        size in interface GridOffHeapPartitionedMap
        Parameters:
        parts - Partitions.
        Returns:
        Number of elements in the map.
      • allocatedSize

        public long allocatedSize()
        Gets size of a memory allocated for map entries so far.
        Specified by:
        allocatedSize in interface GridOffHeapPartitionedMap
        Returns:
        Allocated memory size.
      • 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 GridOffHeapPartitionedMap
        Parameters:
        evictLsnr - Evict listener.
        Returns:
        True if evict listener was added, false if another listener already exists or LRU is disabled.
      • 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.