org.apache.ignite.internal.processors.offheap

## Class GridOffHeapProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor

    public class GridOffHeapProcessor
    extends GridProcessorAdapter

Manages offheap memory caches.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`GridOffHeapProcessor(GridKernalContext ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`long` `allocatedSize(@Nullable String spaceName)` Gets size of a memory allocated for the entries of the given space.
`boolean` `contains(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Checks if offheap space contains value for the given key.
`void` `create(@Nullable String spaceName, int parts, long init, long max, @Nullable GridOffHeapEvictListener lsnr)` Creates offheap map for given space name.
`void` `destruct(@Nullable String spaceName)` Destructs offheap map for given space name.
`void` `enableEviction(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Enables eviction for entry after `valuePointer(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])` was called.
`long` `entriesCount(@Nullable String spaceName)` Gets number of elements in the given space.
`long` `entriesCount(@Nullable String spaceName, Set<Integer> parts)` Gets number of elements in the given space.
`@Nullable byte[]` `get(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Gets value bytes from offheap space for the given key.
`<T> T` `getValue(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, @Nullable ClassLoader ldr)` Gets value from offheap space for the given key.
`GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>` `iterator(@Nullable String spaceName)` Gets iterator over contents of the given space.
`<T> GridCloseableIterator<T>` `iterator(@Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)` Gets iterator over contents of the given space.
`<T> GridCloseableIterator<T>` `iterator(@Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c, int part)` Gets iterator over contents of the given space.
`GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>` `iterator(@Nullable String spaceName, int part)` Gets iterator over contents of partition.
`void` `put(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, byte[] valBytes)` Puts the given value to offheap space for the given key.
`@Nullable byte[]` `remove(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Removes value from offheap space for the given key.
`boolean` `removex(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Removes value from offheap space for the given key.
`boolean` `removex(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, IgniteBiPredicate<Long,Integer> p)` Removes value from offheap space for the given key.
`void` `stop(boolean cancel)` Stops grid component.
`@Nullable IgniteBiTuple<Long,Integer>` `valuePointer(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)` Gets value pointer from offheap space for the given key.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, toString, validateNode, validateNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridOffHeapProcessor

    public GridOffHeapProcessor(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### create

    public void create(@Nullable
                       @Nullable String spaceName,
                       int parts,
                       long init,
                       long max,
                       @Nullable
                       @Nullable GridOffHeapEvictListener lsnr)

Creates offheap map for given space name. Previous one will be destructed if it exists.

Parameters:
  `spaceName` - Space name.
  `parts` - Partitions number.
  `init` - Initial size.
  `max` - Maximum size.
  `lsnr` - Eviction listener.

#### destruct

    public void destruct(@Nullable
                         @Nullable String spaceName)

Destructs offheap map for given space name.

Parameters:
  `spaceName` - Space name.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### contains

    public boolean contains(@Nullable
                            @Nullable String spaceName,
                            int part,
                            KeyCacheObject key,
                            byte[] keyBytes)
                     throws IgniteCheckedException

Checks if offheap space contains value for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Returns:
  `true` If offheap space contains value for the given key.
Throws:
  `IgniteCheckedException` - If failed.

#### get

    @Nullable
    public @Nullable byte[] get(@Nullable
                                          @Nullable String spaceName,
                                          int part,
                                          KeyCacheObject key,
                                          byte[] keyBytes)
                                   throws IgniteCheckedException

Gets value bytes from offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### valuePointer

    @Nullable
    public @Nullable IgniteBiTuple<Long,Integer> valuePointer(@Nullable
                                                                        @Nullable String spaceName,
                                                                        int part,
                                                                        KeyCacheObject key,
                                                                        byte[] keyBytes)
                                                                 throws IgniteCheckedException

Gets value pointer from offheap space for the given key. While pointer is in use eviction is disabled for corresponding entry. Eviction for entry is enabled when `put(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[], byte[])` or `enableEviction(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])` is called.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Returns:
  Tuple where first value is pointer and second is value size.
Throws:
  `IgniteCheckedException` - If failed.

#### enableEviction

    public void enableEviction(@Nullable
                               @Nullable String spaceName,
                               int part,
                               KeyCacheObject key,
                               byte[] keyBytes)
                        throws IgniteCheckedException

Enables eviction for entry after `valuePointer(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])` was called.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### getValue

    @Nullable
    public <T> T getValue(@Nullable
                                    @Nullable String spaceName,
                                    int part,
                                    KeyCacheObject key,
                                    byte[] keyBytes,
                                    @Nullable
                                    @Nullable ClassLoader ldr)
                             throws IgniteCheckedException

Gets value from offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
  `ldr` - Class loader.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    @Nullable
    public @Nullable byte[] remove(@Nullable
                                             @Nullable String spaceName,
                                             int part,
                                             KeyCacheObject key,
                                             byte[] keyBytes)
                                      throws IgniteCheckedException

Removes value from offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### put

    public void put(@Nullable
                    @Nullable String spaceName,
                    int part,
                    KeyCacheObject key,
                    byte[] keyBytes,
                    byte[] valBytes)
             throws IgniteCheckedException

Puts the given value to offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
  `valBytes` - Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### removex

    public boolean removex(@Nullable
                           @Nullable String spaceName,
                           int part,
                           KeyCacheObject key,
                           byte[] keyBytes)
                    throws IgniteCheckedException

Removes value from offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
Returns:
  `true` If succeeded.
Throws:
  `IgniteCheckedException` - If failed.

#### removex

    public boolean removex(@Nullable
                           @Nullable String spaceName,
                           int part,
                           KeyCacheObject key,
                           byte[] keyBytes,
                           IgniteBiPredicate<Long,Integer> p)
                    throws IgniteCheckedException

Removes value from offheap space for the given key.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
  `key` - Key.
  `keyBytes` - Key bytes.
  `p` - Value predicate (arguments are value address and value length).
Returns:
  `true` If succeeded.
Throws:
  `IgniteCheckedException` - If failed.

#### iterator

    public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(@Nullable
                                                                        @Nullable String spaceName)

Gets iterator over contents of the given space.

Parameters:
  `spaceName` - Space name.
Returns:
  Iterator.

#### iterator

    public <T> GridCloseableIterator<T> iterator(@Nullable
                                                 @Nullable String spaceName,
                                                 CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)

Gets iterator over contents of the given space.

Parameters:
  `spaceName` - Space name.
  `c` - Key/value closure.
Returns:
  Iterator.

#### iterator

    public <T> GridCloseableIterator<T> iterator(@Nullable
                                                 @Nullable String spaceName,
                                                 CX2<T2<Long,Integer>,T2<Long,Integer>,T> c,
                                                 int part)

Gets iterator over contents of the given space.

Parameters:
  `spaceName` - Space name.
  `c` - Key/value closure.
  `part` - Partition.
Returns:
  Iterator.

#### entriesCount

    public long entriesCount(@Nullable
                             @Nullable String spaceName)

Gets number of elements in the given space.

Parameters:
  `spaceName` - Space name. Optional.
Returns:
  Number of elements or `-1` if no space with the given name has been found.

#### entriesCount

    public long entriesCount(@Nullable
                             @Nullable String spaceName,
                             Set<Integer> parts)

Gets number of elements in the given space.

Parameters:
  `spaceName` - Space name. Optional.
  `parts` - Partitions.
Returns:
  Number of elements or `-1` if no space with the given name has been found.

#### allocatedSize

    public long allocatedSize(@Nullable
                              @Nullable String spaceName)

Gets size of a memory allocated for the entries of the given space.

Parameters:
  `spaceName` - Space name. Optional.
Returns:
  Allocated memory size or `-1` if no space with the given name has been found.

#### iterator

    public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(@Nullable
                                                                        @Nullable String spaceName,
                                                                        int part)

Gets iterator over contents of partition.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
Returns:
  Iterator.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022