Interface GridOffHeapMap

  • All Known Implementing Classes:
    GridUnsafeMap

    public interface GridOffHeapMap
    Off-heap map.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long allocatedSize()
      Gets memory allocated for map entries so far.
      int concurrency()
      Gets concurrency level for this map.
      boolean contains​(int hash, byte[] keyBytes)
      Checks if given key is contained in the map.
      void destruct()
      Destructs this map and deallocates all memory.
      void enableEviction​(int hash, byte[] keyBytes)
      Enables eviction for given key.
      boolean eventListener​(GridOffHeapEventListener lsnr)
      Adds off-heap event listener.
      boolean evictListener​(GridOffHeapEvictListener lsnr)
      Sets callback for when entries are evicted due to memory constraints.
      long freeSize()
      Gets available memory.
      @org.jetbrains.annotations.Nullable byte[] get​(int hash, byte[] keyBytes)
      Gets value bytes for given key.
      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.
      GridCloseableIterator<IgniteBiTuple<byte[],​byte[]>> iterator()
      Gets iterator over map.
      <T> GridCloseableIterator<T> iterator​(@Nullable CX2<T2<Long,​Integer>,​T2<Long,​Integer>,​T> c)
      Gets iterator over map.
      float loadFactor()
      Gets load factor of this map.
      long memorySize()
      Gets total available memory size.
      int partition()
      Gets partition this map belongs to.
      boolean put​(int hash, byte[] keyBytes, byte[] valBytes)
      Puts key and value bytes into the map potentially replacing existing entry.
      @org.jetbrains.annotations.Nullable byte[] remove​(int hash, byte[] keyBytes)
      Removes value from off-heap map.
      boolean removex​(int hash, byte[] keyBytes)
      Removes value from off-heap map without returning it.
      boolean removex​(int hash, byte[] keyBytes, IgniteBiPredicate<Long,​Integer> p)
      Removes value from off-heap map without returning it.
      long size()
      Gets number of elements in the map.
      long systemAllocatedSize()
      Gets memory allocated for map internal structure so far.
      long totalSize()
      Gets number of elements in the map.
      @Nullable IgniteBiTuple<Long,​Integer> valuePointer​(int hash, byte[] keyBytes)
      Gets value pointer for given key.
    • Method Detail

      • partition

        int partition()
        Gets partition this map belongs to.
        Returns:
        Partition this map belongs to.
      • loadFactor

        float loadFactor()
        Gets load factor of this map.
        Returns:
        Load factor.
      • concurrency

        int concurrency()
        Gets concurrency level for this map.
        Returns:
        Concurrency level.
      • contains

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

        @Nullable
        @org.jetbrains.annotations.Nullable byte[] get​(int hash,
                                                       byte[] keyBytes)
        Gets value bytes for given key.
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        Value bytes.
      • valuePointer

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

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

        @Nullable
        @org.jetbrains.annotations.Nullable byte[] remove​(int hash,
                                                          byte[] keyBytes)
        Removes value from off-heap map.
        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        Returns:
        Removed value bytes.
      • removex

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

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

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

        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.

        Parameters:
        hash - Hash.
        keyBytes - Key bytes.
        valBytes - Value bytes.
      • totalSize

        long totalSize()
        Gets number of elements in the map.
        Returns:
        Number of elements in the map.
      • size

        long size()
        Gets number of elements in the map.
        Returns:
        Number of elements in the map.
      • memorySize

        long memorySize()
        Gets total available memory size.
        Returns:
        Memory size.
      • allocatedSize

        long allocatedSize()
        Gets memory allocated for map entries so far.
        Returns:
        Allocated memory.
      • systemAllocatedSize

        long systemAllocatedSize()
        Gets memory allocated for map internal structure so far.
        Returns:
        Allocated memory.
      • freeSize

        long freeSize()
        Gets available memory.
        Returns:
        Available memory.
      • destruct

        void destruct()
        Destructs this map and deallocates all memory.
      • evictListener

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

        boolean eventListener​(GridOffHeapEventListener lsnr)
        Adds off-heap event listener.
        Parameters:
        lsnr - Listener.
        Returns:
        True if event listener was added, false if another listener already exists.