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

## Class PageIO

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO

Direct Known Subclasses:
  AbstractDataPageIO, BPlusIO, BPlusMetaIO, PageMetaIO, PagePartitionCountersIO, PagesListMetaIO, PagesListNodeIO, TrackingPageIO

    public abstract class PageIO
    extends Object

Base format for all the page types. Checklist for page IO implementations and usage (The Rules): 1. IO should not have any `public static` methods. We have versioned IOs and any static method will mean that it have to always work in backward compatible way between all the IO versions. The base class `PageIO` has static methods (like `{@link #getPageId(long)}`) intentionally: this base format can not be changed between versions. 2. IO must correctly override `initNewPage(long, long, int)` method and call super. We have logic that relies on this behavior. 3. Page IO type ID constant must be declared in this class to have a list of all the existing IO types in a single place. 4. IO must be added to `getBPlusIO(int, int)` or to `getPageIO(int, int)`. 5. Always keep in mind that IOs are versioned and their format can change from version to version. In this respect it is a good practice to avoid exposing details of IO internal format on it's API. The API should be minimalistic and abstract, so that internal format in future IO version can be completely changed without any changes to the API of this page IO. 6. Page IO API should not have any version dependent semantics and should not change API semantics in newer versions. 7. It is almost always preferable to read or write (especially write) page contents using static methods on `PageHandler`. To just initialize new page use `PageHandler.initPage(PageMemory, int, long, PageIO, IgniteWriteAheadLogManager, PageLockListener, IoStatisticsHolder)` method with needed IO instance.

### Field Summary

Fields
`static int` `COMMON_HEADER_END`
`static int` `CRC_OFF`
`static short` `MAX_PAYLOAD_SIZE` Maximum payload size.
`static int` `PAGE_ID_OFF`
`static int` `ROTATED_ID_PART_OFF`
`static short` `T_BPLUS_META`
`static short` `T_CACHE_ID_AWARE_DATA_REF_INNER`
`static short` `T_CACHE_ID_AWARE_DATA_REF_LEAF`
`static short` `T_CACHE_ID_AWARE_PENDING_REF_INNER`
`static short` `T_CACHE_ID_AWARE_PENDING_REF_LEAF`
`static short` `T_CACHE_ID_DATA_REF_MVCC_INNER`
`static short` `T_CACHE_ID_DATA_REF_MVCC_LEAF`
`static short` `T_DATA`
`static short` `T_DATA_METASTORAGE`
`static short` `T_DATA_PART`
`static short` `T_DATA_REF_INNER`
`static short` `T_DATA_REF_LEAF`
`static short` `T_DATA_REF_METASTORAGE_INNER`
`static short` `T_DATA_REF_METASTORAGE_LEAF`
`static short` `T_DATA_REF_MVCC_INNER`
`static short` `T_DATA_REF_MVCC_LEAF`
`static short` `T_H2_EX_REF_INNER_END`
`static short` `T_H2_EX_REF_INNER_START`
`static short` `T_H2_EX_REF_LEAF_END`
`static short` `T_H2_EX_REF_LEAF_START` Index for payload == 1.
`static short` `T_H2_EX_REF_MVCC_INNER_END`
`static short` `T_H2_EX_REF_MVCC_INNER_START`
`static short` `T_H2_EX_REF_MVCC_LEAF_END`
`static short` `T_H2_EX_REF_MVCC_LEAF_START`
`static short` `T_H2_MVCC_REF_INNER`
`static short` `T_H2_MVCC_REF_LEAF`
`static short` `T_H2_REF_INNER`
`static short` `T_H2_REF_LEAF`
`static short` `T_META`
`static short` `T_METASTORE_INNER`
`static short` `T_METASTORE_LEAF`
`static short` `T_PAGE_LIST_META`
`static short` `T_PAGE_LIST_NODE`
`static short` `T_PAGE_UPDATE_TRACKING`
`static short` `T_PART_CNTRS`
`static short` `T_PART_META`
`static short` `T_PENDING_REF_INNER`
`static short` `T_PENDING_REF_LEAF`
`static short` `T_TX_LOG_INNER`
`static short` `T_TX_LOG_LEAF`
`static int` `TYPE_OFF`
`static int` `VER_OFF`

### Constructor Summary

Constructors
`protected` `PageIO(int type, int ver)`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`protected void` `copyPage(ByteBuffer page, ByteBuffer out, int pageSize)`
`static IndexPageType` `deriveIndexPageType(long pageAddr)`
`static <Q extends BPlusIO<?>> Q` `getBPlusIO(int type, int ver)`
`static <Q extends BPlusIO<?>> Q` `getBPlusIO(long pageAddr)`
`static short` `getCompactedSize(ByteBuffer page)`
`static short` `getCompactedSize(long pageAddr)`
`static short` `getCompressedSize(ByteBuffer page)`
`static short` `getCompressedSize(long pageAddr)`
`static byte` `getCompressionType(ByteBuffer page)`
`static byte` `getCompressionType(long pageAddr)`
`static int` `getCrc(ByteBuffer buf)`
`static int` `getCrc(long pageAddr)`
`static IOVersions<? extends BPlusInnerIO<?>>` `getInnerVersions(int idx, boolean mvcc)`
`static IOVersions<? extends BPlusLeafIO<?>>` `getLeafVersions(int idx, boolean mvcc)`
`static long` `getPageId(ByteBuffer buf)`
`static long` `getPageId(long pageAddr)`
`static <Q extends PageIO> Q` `getPageIO(ByteBuffer page)`
`static <Q extends PageIO> Q` `getPageIO(int type, int ver)`
`static <Q extends PageIO> Q` `getPageIO(long pageAddr)`
`static int` `getRotatedIdPart(long pageAddr)`
`int` `getType()`
`static int` `getType(ByteBuffer buf)`
`static int` `getType(long pageAddr)`
`int` `getVersion()`
`static int` `getVersion(ByteBuffer buf)`
`static int` `getVersion(long pageAddr)`
`void` `initNewPage(long pageAddr, long pageId, int pageSize)`
`static boolean` `isDataPageType(int type)`
`static String` `printPage(long addr, int pageSize)`
`protected abstract void` `printPage(long addr, int pageSize, GridStringBuilder sb)`
`static void` `registerH2(IOVersions<? extends BPlusInnerIO<?>> innerIOs, IOVersions<? extends BPlusLeafIO<?>> leafIOs, IOVersions<? extends BPlusInnerIO<?>> mvccInnerIOs, IOVersions<? extends BPlusLeafIO<?>> mvccLeafIOs)` Registers this B+Tree IO versions.
`static void` `registerH2ExtraInner(IOVersions<? extends BPlusInnerIO<?>> innerExtIOs, boolean mvcc)` Registers extra inner IO versions.
`static void` `registerH2ExtraLeaf(IOVersions<? extends BPlusLeafIO<?>> leafExtIOs, boolean mvcc)` Registers extra inner IO versions.
`static void` `registerTest(BPlusInnerIO<?> innerIO, BPlusLeafIO<?> leafIO)` Registers IOs for testing.
`static void` `registerTest(PageIO io)` Registers IO for testing.
`static void` `setCompactedSize(ByteBuffer page, short compactedSize)`
`static void` `setCompressedSize(ByteBuffer page, short compressedSize)`
`static void` `setCompressionType(ByteBuffer page, byte compressType)`
`static void` `setCrc(ByteBuffer buf, int crc)`
`static void` `setCrc(long pageAddr, int crc)`
`static void` `setPageId(long pageAddr, long pageId)`
`static void` `setRotatedIdPart(long pageAddr, int rotatedIdPart)`
`static void` `setType(long pageAddr, int type)`
`protected static void` `setVersion(long pageAddr, int ver)`
`String` `toString()`

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

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

### Field Detail

#### MAX_PAYLOAD_SIZE

    public static final short MAX_PAYLOAD_SIZE

Maximum payload size.

See Also:
  Constant Field Values

#### TYPE_OFF

    public static final int TYPE_OFF

See Also:
  Constant Field Values

#### VER_OFF

    public static final int VER_OFF

See Also:
  Constant Field Values

#### CRC_OFF

    public static final int CRC_OFF

See Also:
  Constant Field Values

#### PAGE_ID_OFF

    public static final int PAGE_ID_OFF

See Also:
  Constant Field Values

#### ROTATED_ID_PART_OFF

    public static final int ROTATED_ID_PART_OFF

See Also:
  Constant Field Values

#### COMMON_HEADER_END

    public static final int COMMON_HEADER_END

See Also:
  Constant Field Values

#### T_DATA

    public static final short T_DATA

See Also:
  Constant Field Values

#### T_BPLUS_META

    public static final short T_BPLUS_META

See Also:
  Constant Field Values

#### T_H2_REF_LEAF

    public static final short T_H2_REF_LEAF

See Also:
  Constant Field Values

#### T_H2_REF_INNER

    public static final short T_H2_REF_INNER

See Also:
  Constant Field Values

#### T_DATA_REF_INNER

    public static final short T_DATA_REF_INNER

See Also:
  Constant Field Values

#### T_DATA_REF_LEAF

    public static final short T_DATA_REF_LEAF

See Also:
  Constant Field Values

#### T_METASTORE_INNER

    public static final short T_METASTORE_INNER

See Also:
  Constant Field Values

#### T_METASTORE_LEAF

    public static final short T_METASTORE_LEAF

See Also:
  Constant Field Values

#### T_PENDING_REF_INNER

    public static final short T_PENDING_REF_INNER

See Also:
  Constant Field Values

#### T_PENDING_REF_LEAF

    public static final short T_PENDING_REF_LEAF

See Also:
  Constant Field Values

#### T_META

    public static final short T_META

See Also:
  Constant Field Values

#### T_PAGE_LIST_META

    public static final short T_PAGE_LIST_META

See Also:
  Constant Field Values

#### T_PAGE_LIST_NODE

    public static final short T_PAGE_LIST_NODE

See Also:
  Constant Field Values

#### T_PART_META

    public static final short T_PART_META

See Also:
  Constant Field Values

#### T_PAGE_UPDATE_TRACKING

    public static final short T_PAGE_UPDATE_TRACKING

See Also:
  Constant Field Values

#### T_CACHE_ID_AWARE_DATA_REF_INNER

    public static final short T_CACHE_ID_AWARE_DATA_REF_INNER

See Also:
  Constant Field Values

#### T_CACHE_ID_AWARE_DATA_REF_LEAF

    public static final short T_CACHE_ID_AWARE_DATA_REF_LEAF

See Also:
  Constant Field Values

#### T_CACHE_ID_AWARE_PENDING_REF_INNER

    public static final short T_CACHE_ID_AWARE_PENDING_REF_INNER

See Also:
  Constant Field Values

#### T_CACHE_ID_AWARE_PENDING_REF_LEAF

    public static final short T_CACHE_ID_AWARE_PENDING_REF_LEAF

See Also:
  Constant Field Values

#### T_PART_CNTRS

    public static final short T_PART_CNTRS

See Also:
  Constant Field Values

#### T_DATA_METASTORAGE

    public static final short T_DATA_METASTORAGE

See Also:
  Constant Field Values

#### T_DATA_REF_METASTORAGE_INNER

    public static final short T_DATA_REF_METASTORAGE_INNER

See Also:
  Constant Field Values

#### T_DATA_REF_METASTORAGE_LEAF

    public static final short T_DATA_REF_METASTORAGE_LEAF

See Also:
  Constant Field Values

#### T_DATA_REF_MVCC_INNER

    public static final short T_DATA_REF_MVCC_INNER

See Also:
  Constant Field Values

#### T_DATA_REF_MVCC_LEAF

    public static final short T_DATA_REF_MVCC_LEAF

See Also:
  Constant Field Values

#### T_CACHE_ID_DATA_REF_MVCC_INNER

    public static final short T_CACHE_ID_DATA_REF_MVCC_INNER

See Also:
  Constant Field Values

#### T_CACHE_ID_DATA_REF_MVCC_LEAF

    public static final short T_CACHE_ID_DATA_REF_MVCC_LEAF

See Also:
  Constant Field Values

#### T_H2_MVCC_REF_LEAF

    public static final short T_H2_MVCC_REF_LEAF

See Also:
  Constant Field Values

#### T_H2_MVCC_REF_INNER

    public static final short T_H2_MVCC_REF_INNER

See Also:
  Constant Field Values

#### T_TX_LOG_LEAF

    public static final short T_TX_LOG_LEAF

See Also:
  Constant Field Values

#### T_TX_LOG_INNER

    public static final short T_TX_LOG_INNER

See Also:
  Constant Field Values

#### T_DATA_PART

    public static final short T_DATA_PART

See Also:
  Constant Field Values

#### T_H2_EX_REF_LEAF_START

    public static final short T_H2_EX_REF_LEAF_START

Index for payload == 1.

See Also:
  Constant Field Values

#### T_H2_EX_REF_LEAF_END

    public static final short T_H2_EX_REF_LEAF_END

See Also:
  Constant Field Values

#### T_H2_EX_REF_INNER_START

    public static final short T_H2_EX_REF_INNER_START

See Also:
  Constant Field Values

#### T_H2_EX_REF_INNER_END

    public static final short T_H2_EX_REF_INNER_END

See Also:
  Constant Field Values

#### T_H2_EX_REF_MVCC_LEAF_START

    public static final short T_H2_EX_REF_MVCC_LEAF_START

See Also:
  Constant Field Values

#### T_H2_EX_REF_MVCC_LEAF_END

    public static final short T_H2_EX_REF_MVCC_LEAF_END

See Also:
  Constant Field Values

#### T_H2_EX_REF_MVCC_INNER_START

    public static final short T_H2_EX_REF_MVCC_INNER_START

See Also:
  Constant Field Values

#### T_H2_EX_REF_MVCC_INNER_END

    public static final short T_H2_EX_REF_MVCC_INNER_END

See Also:
  Constant Field Values

### Constructor Detail

#### PageIO

    protected PageIO(int type,
                     int ver)

Parameters:
  `type` - Page type.
  `ver` - Page format version.

### Method Detail

#### getType

    public static int getType(ByteBuffer buf)

Parameters:
  `buf` - Buffer.
Returns:
  Page type.

#### getType

    public static int getType(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Page type.

#### setType

    public static void setType(long pageAddr,
                               int type)

Parameters:
  `pageAddr` - Page address.
  `type` - Type.

#### getVersion

    public static int getVersion(ByteBuffer buf)

Parameters:
  `buf` - Buffer.
Returns:
  Version.

#### getVersion

    public static int getVersion(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Version.

#### setVersion

    protected static void setVersion(long pageAddr,
                                     int ver)

Parameters:
  `pageAddr` - Page address.
  `ver` - Version.

#### getPageId

    public static long getPageId(ByteBuffer buf)

Parameters:
  `buf` - Buffer.
Returns:
  Page ID.

#### getPageId

    public static long getPageId(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Page ID.

#### setPageId

    public static void setPageId(long pageAddr,
                                 long pageId)

Parameters:
  `pageAddr` - Page address.
  `pageId` - Page ID.

#### getRotatedIdPart

    public static int getRotatedIdPart(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Rotated page ID part.

#### setRotatedIdPart

    public static void setRotatedIdPart(long pageAddr,
                                        int rotatedIdPart)

Parameters:
  `pageAddr` - Page address.
  `rotatedIdPart` - Rotated page ID part.

#### setCompressionType

    public static void setCompressionType(ByteBuffer page,
                                          byte compressType)

Parameters:
  `page` - Page buffer.
  `compressType` - Compression type.

#### getCompressionType

    public static byte getCompressionType(ByteBuffer page)

Parameters:
  `page` - Page buffer.
Returns:
  Compression type.

#### getCompressionType

    public static byte getCompressionType(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Compression type.

#### setCompressedSize

    public static void setCompressedSize(ByteBuffer page,
                                         short compressedSize)

Parameters:
  `page` - Page buffer.
  `compressedSize` - Compressed size.

#### getCompressedSize

    public static short getCompressedSize(ByteBuffer page)

Parameters:
  `page` - Page buffer.
Returns:
  Compressed size.

#### getCompressedSize

    public static short getCompressedSize(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Compressed size.

#### setCompactedSize

    public static void setCompactedSize(ByteBuffer page,
                                        short compactedSize)

Parameters:
  `page` - Page buffer.
  `compactedSize` - Compacted size.

#### getCompactedSize

    public static short getCompactedSize(ByteBuffer page)

Parameters:
  `page` - Page buffer.
Returns:
  Compacted size.

#### getCompactedSize

    public static short getCompactedSize(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Compacted size.

#### getCrc

    public static int getCrc(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Checksum.

#### setCrc

    public static void setCrc(long pageAddr,
                              int crc)

Parameters:
  `pageAddr` - Page address.
  `crc` - Checksum.

#### getCrc

    public static int getCrc(ByteBuffer buf)

Parameters:
  `buf` - Buffer.
Returns:
  Checksum.

#### setCrc

    public static void setCrc(ByteBuffer buf,
                              int crc)

Parameters:
  `buf` - Buffer.
  `crc` - Checksum.

#### registerH2

    public static void registerH2(IOVersions<? extends BPlusInnerIO<?>> innerIOs,
                                  IOVersions<? extends BPlusLeafIO<?>> leafIOs,
                                  IOVersions<? extends BPlusInnerIO<?>> mvccInnerIOs,
                                  IOVersions<? extends BPlusLeafIO<?>> mvccLeafIOs)

Registers this B+Tree IO versions.

Parameters:
  `innerIOs` - Inner IO versions.
  `leafIOs` - Leaf IO versions.
  `mvccInnerIOs` - Inner IO versions with mvcc enabled.
  `mvccLeafIOs` - Leaf IO versions with mvcc enabled.

#### registerH2ExtraInner

    public static void registerH2ExtraInner(IOVersions<? extends BPlusInnerIO<?>> innerExtIOs,
                                            boolean mvcc)

Registers extra inner IO versions.

Parameters:
  `innerExtIOs` - Extra versions.

#### registerH2ExtraLeaf

    public static void registerH2ExtraLeaf(IOVersions<? extends BPlusLeafIO<?>> leafExtIOs,
                                           boolean mvcc)

Registers extra inner IO versions.

Parameters:
  `leafExtIOs` - Extra versions.

#### getInnerVersions

    public static IOVersions<? extends BPlusInnerIO<?>> getInnerVersions(int idx,
                                                                         boolean mvcc)

Parameters:
  `idx` - Index.
Returns:
  IOVersions for given idx.

#### getLeafVersions

    public static IOVersions<? extends BPlusLeafIO<?>> getLeafVersions(int idx,
                                                                       boolean mvcc)

Parameters:
  `idx` - Index.
Returns:
  IOVersions for given idx.

#### registerTest

    public static void registerTest(BPlusInnerIO<?> innerIO,
                                    BPlusLeafIO<?> leafIO)

Registers IOs for testing.

Parameters:
  `innerIO` - Inner IO.
  `leafIO` - Leaf IO.

#### registerTest

    public static void registerTest(PageIO io)

Registers IO for testing.

Parameters:
  `io` - Page IO.

#### getType

    public final int getType()

Returns:
  Type.

#### getVersion

    public final int getVersion()

Returns:
  Version.

#### initNewPage

    public void initNewPage(long pageAddr,
                            long pageId,
                            int pageSize)

Parameters:
  `pageAddr` - Page address.
  `pageId` - Page ID.
  `pageSize` - Page size.
See Also:
  `EncryptionSpi.encryptedSize(int)`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### getPageIO

    public static <Q extends PageIO> Q getPageIO(long pageAddr)
                                          throws IgniteCheckedException

Parameters:
  `pageAddr` - Page address.
Returns:
  IO.
Throws:
  `IgniteCheckedException` - If failed.

#### getPageIO

    public static <Q extends PageIO> Q getPageIO(ByteBuffer page)
                                          throws IgniteCheckedException

Parameters:
  `page` - Page.
Returns:
  Page IO.
Throws:
  `IgniteCheckedException` - If failed.

#### getPageIO

    public static <Q extends PageIO> Q getPageIO(int type,
                                                 int ver)
                                          throws IgniteCheckedException

Parameters:
  `type` - IO Type.
  `ver` - IO Version.
Returns:
  Page IO.
Throws:
  `IgniteCheckedException` - If failed.

#### getBPlusIO

    public static <Q extends BPlusIO<?>> Q getBPlusIO(long pageAddr)
                                               throws IgniteCheckedException

Parameters:
  `pageAddr` - Page address.
Returns:
  IO for either inner or leaf B+Tree page.
Throws:
  `IgniteCheckedException` - If failed.

#### getBPlusIO

    public static <Q extends BPlusIO<?>> Q getBPlusIO(int type,
                                                      int ver)
                                               throws IgniteCheckedException

Parameters:
  `type` - IO Type.
  `ver` - IO Version.
Returns:
  IO for either inner or leaf B+Tree page.
Throws:
  `IgniteCheckedException` - If failed.

#### deriveIndexPageType

    public static IndexPageType deriveIndexPageType(long pageAddr)

Parameters:
  `pageAddr` - Address of page.
Returns:
  Index page type.

#### isDataPageType

    public static boolean isDataPageType(int type)

Parameters:
  `type` - Type to test.
Returns:
  `True` if data page.

#### printPage

    protected abstract void printPage(long addr,
                                      int pageSize,
                                      GridStringBuilder sb)
                               throws IgniteCheckedException

Parameters:
  `addr` - Address.
  `pageSize` - Page size.
  `sb` - Sb.
Throws:
  `IgniteCheckedException`

#### copyPage

    protected final void copyPage(ByteBuffer page,
                                  ByteBuffer out,
                                  int pageSize)

Parameters:
  `page` - Page.
  `out` - Output buffer.
  `pageSize` - Page size.

#### printPage

    public static String printPage(long addr,
                                   int pageSize)

Parameters:
  `addr` - Address.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020