org.apache.ignite.internal.util.offheap

## Interface GridOffHeapPartitionedMap

All Known Implementing Classes:
  GridUnsafePartitionedMap

    public interface GridOffHeapPartitionedMap

Off-heap map.

### Method Summary

All Methods Instance Methods Abstract Methods
`long` `allocatedSize()` Gets size of a memory allocated for map entries so far.
`int` `concurrency()` Gets concurrency level for this map.
`boolean` `contains(int p, 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 p, int hash, byte[] keyBytes)` Enables eviction for entry.
`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.
`@Nullable byte[]` `get(int p, int hash, byte[] keyBytes)` Gets value bytes for given key.
`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.
`GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>` `iterator()` Gets iterator over the whole map.
`<T> GridCloseableIterator<T>` `iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)` Gets iterator over the whole map.
`<T> GridCloseableIterator<T>` `iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c, int part)` Gets iterator over the partition.
`GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>` `iterator(int p)` Gets iterator over certain partition.
`float` `loadFactor()` Gets load factor of this map.
`long` `memorySize()` Gets total available memory size.
`int` `partitions()` Gets number of partitions.
`boolean` `put(int p, int hash, byte[] keyBytes, byte[] valBytes)` Puts key and value bytes into the map potentially replacing existing entry.
`@Nullable byte[]` `remove(int p, int hash, byte[] keyBytes)` Removes value from off-heap map.
`boolean` `removex(int p, int hash, byte[] keyBytes)` Removes value from off-heap map without returning it.
`boolean` `removex(int part, 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` `size(Set<Integer> parts)` Gets number of elements in the map.
`long` `systemAllocatedSize()` Gets memory allocated for map internal structure so far.
`@Nullable IgniteBiTuple<Long,Integer>` `valuePointer(int p, int hash, byte[] keyBytes)` Gets value pointer for given key.

### Method Detail

#### loadFactor

    float loadFactor()

Gets load factor of this map.

Returns:
  Load factor.

#### concurrency

    int concurrency()

Gets concurrency level for this map.

Returns:
  Concurrency level.

#### partitions

    int partitions()

Gets number of partitions.

Returns:
  Number of partitions.

#### contains

    boolean contains(int p,
                     int hash,
                     byte[] keyBytes)

Checks if given key is contained in the map.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
Returns:
  `True` if key is contained in the map.

#### get

    @Nullable
    @Nullable byte[] get(int p,
                                   int hash,
                                   byte[] keyBytes)

Gets value bytes for given key.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
Returns:
  Value bytes.

#### valuePointer

    @Nullable
    @Nullable IgniteBiTuple<Long,Integer> valuePointer(int p,
                                                                 int hash,
                                                                 byte[] keyBytes)

Gets value pointer for given key. While pointer is in use eviction is disabled for corresponding entry. Eviction for entry is enabled when `put(int, int, byte[], byte[])` or `enableEviction(int, int, byte[])` is called.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
Returns:
  Value pointer.

#### enableEviction

    void enableEviction(int p,
                        int hash,
                        byte[] keyBytes)

Enables eviction for entry.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.

#### remove

    @Nullable
    @Nullable byte[] remove(int p,
                                      int hash,
                                      byte[] keyBytes)

Removes value from off-heap map.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
Returns:
  Removed value bytes.

#### removex

    boolean removex(int p,
                    int hash,
                    byte[] keyBytes)

Removes value from off-heap map without returning it.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
Returns:
  `True` if value was removed.

#### removex

    boolean removex(int part,
                    int hash,
                    byte[] keyBytes,
                    IgniteBiPredicate<Long,Integer> p)

Removes value from off-heap map without returning it.

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

    boolean put(int p,
                int hash,
                byte[] keyBytes,
                byte[] valBytes)

Puts key and value bytes into the map potentially replacing existing entry.

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

    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.

Parameters:
  `p` - Partition.
  `hash` - Hash.
  `keyBytes` - Key bytes.
  `valBytes` - Value bytes.

#### size

    long size()

Gets number of elements in the map.

Returns:
  Number of elements in the map.

#### size

    long size(Set<Integer> parts)

Gets number of elements in the map.

Parameters:
  `parts` - Partitions.
Returns:
  Number of elements in the map.

#### memorySize

    long memorySize()

Gets total available memory size.

Returns:
  Memory size.

#### allocatedSize

    long allocatedSize()

Gets size of a memory allocated for map entries so far.

Returns:
  Allocated memory size.

#### 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.

#### iterator

    GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator()

Gets iterator over the whole map.

Returns:
  Iterator over the whole map.

#### iterator

    <T> GridCloseableIterator<T> iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)

Gets iterator over the whole map.

Parameters:
  `c` - Key/value closure.
Returns:
  Iterator over the whole map.

#### iterator

    <T> GridCloseableIterator<T> iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c,
                                          int part)

Gets iterator over the partition.

Parameters:
  `c` - Key/value closure.
  `part` - Partition.
Returns:
  Iterator over the partition.

#### iterator

    GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(int p)

Gets iterator over certain partition.

Parameters:
  `p` - Partition.
Returns:
  Iterator over certain partition.

#### 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.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022