org.apache.ignite.internal.processors.cache.persistence.tree.util

## Class PageHandler<X,R>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler<X,R>

Direct Known Subclasses:
  BPlusTree.Insert, BPlusTree.Replace, BPlusTree.Search

    public abstract class PageHandler<X,R>
    extends Object

Page handler.

### Constructor Summary

Constructors
Constructor and Description
`PageHandler()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static void` `copyMemory(ByteBuffer src, long srcOff, ByteBuffer dst, long dstOff, long cnt)`
`static void` `copyMemory(long srcAddr, long srcOff, long dstAddr, long dstOff, long cnt)`
`static void` `initPage(PageMemory pageMem, int grpId, long pageId, PageIO init, IgniteWriteAheadLogManager wal, PageLockListener lsnr, IoStatisticsHolder statHolder)`
`static boolean` `isWalDeltaRecordNeeded(PageSupport pageMem, int cacheId, long pageId, long page, IgniteWriteAheadLogManager wal, @Nullable Boolean walPlc)`
`static long` `readLock(PageMemory pageMem, int cacheId, long pageId, long page, PageLockListener lsnr)`
`static <X,R> R` `readPage(PageMemory pageMem, int cacheId, long pageId, long page, PageLockListener lsnr, PageHandler<X,R> h, X arg, int intArg, R lockFailed, IoStatisticsHolder statHolder)`
`static <X,R> R` `readPage(PageMemory pageMem, int cacheId, long pageId, PageLockListener lsnr, PageHandler<X,R> h, X arg, int intArg, R lockFailed, IoStatisticsHolder statHolder)`
`static void` `readUnlock(PageMemory pageMem, int cacheId, long pageId, long page, long pageAddr, PageLockListener lsnr)`
`boolean` `releaseAfterWrite(int cacheId, long pageId, long page, long pageAddr, X arg, int intArg)`
`abstract R` `run(int cacheId, long pageId, long page, long pageAddr, PageIO io, Boolean walPlc, X arg, int intArg, IoStatisticsHolder statHolder)`
`static long` `writeLock(PageMemory pageMem, int cacheId, long pageId, long page, PageLockListener lsnr, boolean tryLock)`
`static <X,R> R` `writePage(PageMemory pageMem, int grpId, long pageId, long page, PageLockListener lsnr, PageHandler<X,R> h, PageIO init, IgniteWriteAheadLogManager wal, Boolean walPlc, X arg, int intArg, R lockFailed, IoStatisticsHolder statHolder)`
`static <X,R> R` `writePage(PageMemory pageMem, int grpId, long pageId, PageLockListener lsnr, PageHandler<X,R> h, PageIO init, IgniteWriteAheadLogManager wal, Boolean walPlc, X arg, int intArg, R lockFailed, IoStatisticsHolder statHolder)`
`static void` `writeUnlock(PageMemory pageMem, int cacheId, long pageId, long page, long pageAddr, PageLockListener lsnr, Boolean walPlc, boolean dirty)`
`static void` `zeroMemory(ByteBuffer buf, int off, int len)` Will zero memory in buf
`static void` `zeroMemory(long addr, int off, int len)`

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

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

### Constructor Detail

#### PageHandler

    public PageHandler()

### Method Detail

#### run

    public abstract R run(int cacheId,
                          long pageId,
                          long page,
                          long pageAddr,
                          PageIO io,
                          Boolean walPlc,
                          X arg,
                          int intArg,
                          IoStatisticsHolder statHolder)
                   throws IgniteCheckedException

Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page absolute pointer.
  `pageAddr` - Page address.
  `io` - IO.
  `walPlc` - Full page WAL record policy.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
  `statHolder` - Statistics holder to track IO operations.
Returns:
  Result.
Throws:
  `IgniteCheckedException` - If failed.

#### releaseAfterWrite

    public boolean releaseAfterWrite(int cacheId,
                                     long pageId,
                                     long page,
                                     long pageAddr,
                                     X arg,
                                     int intArg)

Parameters:
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `pageAddr` - Page address.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
Returns:
  `true` If release.

#### readPage

    public static <X,R> R readPage(PageMemory pageMem,
                                   int cacheId,
                                   long pageId,
                                   PageLockListener lsnr,
                                   PageHandler<X,R> h,
                                   X arg,
                                   int intArg,
                                   R lockFailed,
                                   IoStatisticsHolder statHolder)
                            throws IgniteCheckedException

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `lsnr` - Lock listener.
  `h` - Handler.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
  `lockFailed` - Result in case of lock failure due to page recycling.
  `statHolder` - Statistics holder to track IO operations.
Returns:
  Handler result.
Throws:
  `IgniteCheckedException` - If failed.

#### readPage

    public static <X,R> R readPage(PageMemory pageMem,
                                   int cacheId,
                                   long pageId,
                                   long page,
                                   PageLockListener lsnr,
                                   PageHandler<X,R> h,
                                   X arg,
                                   int intArg,
                                   R lockFailed,
                                   IoStatisticsHolder statHolder)
                            throws IgniteCheckedException

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `lsnr` - Lock listener.
  `h` - Handler.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
  `lockFailed` - Result in case of lock failure due to page recycling.
  `statHolder` - Statistics holder to track IO operations.
Returns:
  Handler result.
Throws:
  `IgniteCheckedException` - If failed.

#### readLock

    public static long readLock(PageMemory pageMem,
                                int cacheId,
                                long pageId,
                                long page,
                                PageLockListener lsnr)

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `lsnr` - Lock listener.
Returns:
  Page address.

#### readUnlock

    public static void readUnlock(PageMemory pageMem,
                                  int cacheId,
                                  long pageId,
                                  long page,
                                  long pageAddr,
                                  PageLockListener lsnr)

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `pageAddr` - Page address (for-write pointer)
  `lsnr` - Lock listener.

#### initPage

    public static void initPage(PageMemory pageMem,
                                int grpId,
                                long pageId,
                                PageIO init,
                                IgniteWriteAheadLogManager wal,
                                PageLockListener lsnr,
                                IoStatisticsHolder statHolder)
                         throws IgniteCheckedException

Parameters:
  `pageMem` - Page memory.
  `grpId` - Group ID.
  `pageId` - Page ID.
  `init` - IO for new page initialization.
  `wal` - Write ahead log.
  `lsnr` - Lock listener.
  `statHolder` - Statistics holder to track IO operations.
Throws:
  `IgniteCheckedException` - If failed.

#### writePage

    public static <X,R> R writePage(PageMemory pageMem,
                                    int grpId,
                                    long pageId,
                                    PageLockListener lsnr,
                                    PageHandler<X,R> h,
                                    PageIO init,
                                    IgniteWriteAheadLogManager wal,
                                    Boolean walPlc,
                                    X arg,
                                    int intArg,
                                    R lockFailed,
                                    IoStatisticsHolder statHolder)
                             throws IgniteCheckedException

Parameters:
  `pageMem` - Page memory.
  `grpId` - Group ID.
  `pageId` - Page ID.
  `lsnr` - Lock listener.
  `h` - Handler.
  `init` - IO for new page initialization or `null` if it is an existing page.
  `wal` - Write ahead log.
  `walPlc` - Full page WAL record policy.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
  `lockFailed` - Result in case of lock failure due to page recycling.
  `statHolder` - Statistics holder to track IO operations.
Returns:
  Handler result.
Throws:
  `IgniteCheckedException` - If failed.

#### writePage

    public static <X,R> R writePage(PageMemory pageMem,
                                    int grpId,
                                    long pageId,
                                    long page,
                                    PageLockListener lsnr,
                                    PageHandler<X,R> h,
                                    PageIO init,
                                    IgniteWriteAheadLogManager wal,
                                    Boolean walPlc,
                                    X arg,
                                    int intArg,
                                    R lockFailed,
                                    IoStatisticsHolder statHolder)
                             throws IgniteCheckedException

Parameters:
  `pageMem` - Page memory.
  `grpId` - Group ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `lsnr` - Lock listener.
  `h` - Handler.
  `init` - IO for new page initialization or `null` if it is an existing page.
  `wal` - Write ahead log.
  `walPlc` - Full page WAL record policy.
  `arg` - Argument.
  `intArg` - Argument of type `int`.
  `lockFailed` - Result in case of lock failure due to page recycling.
  `statHolder` - Statistics holder to track IO operations.
Returns:
  Handler result.
Throws:
  `IgniteCheckedException` - If failed.

#### writeUnlock

    public static void writeUnlock(PageMemory pageMem,
                                   int cacheId,
                                   long pageId,
                                   long page,
                                   long pageAddr,
                                   PageLockListener lsnr,
                                   Boolean walPlc,
                                   boolean dirty)

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `pageAddr` - Page address.
  `lsnr` - Lock listener.
  `walPlc` - Full page WAL record policy.
  `dirty` - Page is dirty.

#### writeLock

    public static long writeLock(PageMemory pageMem,
                                 int cacheId,
                                 long pageId,
                                 long page,
                                 PageLockListener lsnr,
                                 boolean tryLock)

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `lsnr` - Lock listener.
  `tryLock` - Only try to lock without waiting.
Returns:
  Page address or `0` if failed to lock due to recycling.

#### isWalDeltaRecordNeeded

    public static boolean isWalDeltaRecordNeeded(PageSupport pageMem,
                                                 int cacheId,
                                                 long pageId,
                                                 long page,
                                                 IgniteWriteAheadLogManager wal,
                                                 @Nullable
                                                 @Nullable Boolean walPlc)

Parameters:
  `pageMem` - Page memory.
  `cacheId` - Cache ID.
  `pageId` - Page ID.
  `page` - Page pointer.
  `wal` - Write ahead log.
  `walPlc` - Full page WAL record policy.
Returns:
  `true` If we need to make a delta WAL record for the change in this page.

#### copyMemory

    public static void copyMemory(ByteBuffer src,
                                  long srcOff,
                                  ByteBuffer dst,
                                  long dstOff,
                                  long cnt)

Parameters:
  `src` - Source.
  `srcOff` - Source offset in bytes.
  `dst` - Destination.
  `dstOff` - Destination offset in bytes.
  `cnt` - Bytes count to copy.

#### zeroMemory

    public static void zeroMemory(ByteBuffer buf,
                                  int off,
                                  int len)

Will zero memory in buf

Parameters:
  `buf` - Buffer.
  `off` - Offset.
  `len` - Length.

#### copyMemory

    public static void copyMemory(long srcAddr,
                                  long srcOff,
                                  long dstAddr,
                                  long dstOff,
                                  long cnt)

Parameters:
  `srcAddr` - Source.
  `srcOff` - Source offset in bytes.
  `dstAddr` - Destination.
  `dstOff` - Destination offset in bytes.
  `cnt` - Bytes count to copy.

#### zeroMemory

    public static void zeroMemory(long addr,
                                  int off,
                                  int len)

Parameters:
  `addr` - Address.
  `off` - Offset.
  `len` - Length.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.0
Release Date | : February 27 2020