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

## Class DataPageIO

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

    public class DataPageIO
    extends PageIO

Data pages IO.

### Nested Class Summary

Nested Classes
`static interface` `DataPageIO.CC<T>` Defines closure interface for applying computations to data page items.

### Field Summary

Fields
`static int` `MIN_DATA_PAGE_OVERHEAD`
`static IOVersions<DataPageIO>` `VERSIONS`

### Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO

`COMMON_HEADER_END, CRC_OFF, MAX_PAYLOAD_SIZE, PAGE_ID_OFF, T_BPLUS_META, T_CACHE_ID_AWARE_DATA_REF_INNER, T_CACHE_ID_AWARE_DATA_REF_LEAF, T_CACHE_ID_AWARE_PENDING_REF_INNER, T_CACHE_ID_AWARE_PENDING_REF_LEAF, T_DATA, T_DATA_REF_INNER, T_DATA_REF_LEAF, T_H2_EX_REF_INNER_END, T_H2_EX_REF_INNER_START, T_H2_EX_REF_LEAF_END, T_H2_EX_REF_LEAF_START, T_H2_REF_INNER, T_H2_REF_LEAF, T_META, T_METASTORE_INNER, T_METASTORE_LEAF, T_PAGE_LIST_META, T_PAGE_LIST_NODE, T_PAGE_UPDATE_TRACKING, T_PART_CNTRS, T_PART_META, T_PENDING_REF_INNER, T_PENDING_REF_LEAF, TYPE_OFF, VER_OFF`

### Constructor Summary

Constructors
`protected` `DataPageIO(int ver)`

### Method Summary

Methods
`void` `addRow(long pageAddr, byte[] payload, int pageSize)` Adds row to this data page and sets respective link to the given row object.
`void` `addRow(long pageAddr, CacheDataRow row, int rowSize, int pageSize)` Adds row to this data page and sets respective link to the given row object.
`void` `addRowFragment(long pageAddr, byte[] payload, long lastLink, int pageSize)` Adds this payload as a fragment to this data page.
`int` `addRowFragment(PageMemory pageMem, long pageAddr, CacheDataRow row, int written, int rowSize, int pageSize)` Adds maximum possible fragment of the given row to this data page and sets respective link to the row.
`<T> List<T>` `forAllItems(long pageAddr, DataPageIO.CC<T> c)`
`long` `getFreeListPageId(long pageAddr)`
`int` `getFreeSpace(long pageAddr)` Free space refers to a "max row size (without any data page specific overhead) which is guaranteed to fit into this data page".
`void` `initNewPage(long pageAddr, long pageId, int pageSize)`
`boolean` `isEmpty(long pageAddr)`
`DataPagePayload` `readPayload(long pageAddr, int itemId, int pageSize)` Sets position to start of actual fragment data and limit to it's end.
`long` `removeRow(long pageAddr, int itemId, int pageSize)`
`void` `setFreeListPageId(long pageAddr, long freeListPageId)`
`boolean` `updateRow(long pageAddr, int itemId, int pageSize, byte[] payload, CacheDataRow row, int rowSize)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO

`getBPlusIO, getBPlusIO, getCrc, getCrc, getInnerVersions, getLeafVersions, getPageId, getPageId, getPageIO, getPageIO, getType, getType, getType, getVersion, getVersion, getVersion, isDataPageType, registerH2, registerH2ExtraInner, registerH2ExtraLeaf, registerTest, setCrc, setCrc, setPageId, setType, toString`

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

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

### Field Detail

#### VERSIONS

    public static final IOVersions<DataPageIO> VERSIONS

#### MIN_DATA_PAGE_OVERHEAD

    public static final int MIN_DATA_PAGE_OVERHEAD

See Also:
  Constant Field Values

### Constructor Detail

#### DataPageIO

    protected DataPageIO(int ver)

Parameters:
  `ver` - Page format version.

### Method Detail

#### initNewPage

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

Overrides:
  `initNewPage` in class `PageIO`
Parameters:
  `pageAddr` - Page address.
  `pageId` - Page ID.
  `pageSize` - Page size.

#### setFreeListPageId

    public void setFreeListPageId(long pageAddr,
                         long freeListPageId)

Parameters:
  `pageAddr` - Page address.
  `freeListPageId` - Free list page ID.

#### getFreeListPageId

    public long getFreeListPageId(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  Free list page ID.

#### getFreeSpace

    public int getFreeSpace(long pageAddr)

Free space refers to a "max row size (without any data page specific overhead) which is guaranteed to fit into this data page".

Parameters:
  `pageAddr` - Page address.
Returns:
  Free space.

#### isEmpty

    public boolean isEmpty(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  `true` If there is no useful data in this page.

#### forAllItems

    public <T> List<T> forAllItems(long pageAddr,
                          DataPageIO.CC<T> c)
                        throws IgniteCheckedException

Type Parameters:
  `T` - Closure return type.
Parameters:
  `pageAddr` - Page address.
  `c` - Closure.
Returns:
  Collection of closure results for all items in page.
Throws:
  `IgniteCheckedException` - In case of error in closure body.

#### readPayload

    public DataPagePayload readPayload(long pageAddr,
                              int itemId,
                              int pageSize)

Sets position to start of actual fragment data and limit to it's end.

Parameters:
  `pageAddr` - Page address.
  `itemId` - Item to position on.
  `pageSize` - Page size.
Returns:
  `DataPagePayload` object.

#### updateRow

    public boolean updateRow(long pageAddr,
                    int itemId,
                    int pageSize,
                    @Nullable
                    byte[] payload,
                    @Nullable
                    CacheDataRow row,
                    int rowSize)
                      throws IgniteCheckedException

Parameters:
  `pageAddr` - Page address.
  `itemId` - Item ID.
  `pageSize` - Page size.
  `payload` - Row data.
  `row` - Row.
  `rowSize` - Row size.
Returns:
  `True` if entry is not fragmented.
Throws:
  `IgniteCheckedException` - If failed.

#### removeRow

    public long removeRow(long pageAddr,
                 int itemId,
                 int pageSize)
                   throws IgniteCheckedException

Parameters:
  `pageAddr` - Page address.
  `itemId` - Fixed item ID (the index used for referencing an entry from the outside).
  `pageSize` - Page size.
Returns:
  Next link for fragmented entries or `0` if none.
Throws:
  `IgniteCheckedException` - If failed.

#### addRow

    public void addRow(long pageAddr,
              CacheDataRow row,
              int rowSize,
              int pageSize)
                throws IgniteCheckedException

Adds row to this data page and sets respective link to the given row object.

Parameters:
  `pageAddr` - Page address.
  `row` - Cache data row.
  `rowSize` - Row size.
  `pageSize` - Page size.
Throws:
  `IgniteCheckedException` - If failed.

#### addRow

    public void addRow(long pageAddr,
              byte[] payload,
              int pageSize)
                throws IgniteCheckedException

Adds row to this data page and sets respective link to the given row object.

Parameters:
  `pageAddr` - Page address.
  `payload` - Payload.
  `pageSize` - Page size.
Throws:
  `IgniteCheckedException` - If failed.

#### addRowFragment

    public int addRowFragment(PageMemory pageMem,
                     long pageAddr,
                     CacheDataRow row,
                     int written,
                     int rowSize,
                     int pageSize)
                       throws IgniteCheckedException

Adds maximum possible fragment of the given row to this data page and sets respective link to the row.

Parameters:
  `pageMem` - Page memory.
  `pageAddr` - Page address.
  `row` - Cache data row.
  `written` - Number of bytes of row size that was already written.
  `rowSize` - Row size.
  `pageSize` - Page size.
Returns:
  Written payload size.
Throws:
  `IgniteCheckedException` - If failed.

#### addRowFragment

    public void addRowFragment(long pageAddr,
                      byte[] payload,
                      long lastLink,
                      int pageSize)
                        throws IgniteCheckedException

Adds this payload as a fragment to this data page.

Parameters:
  `pageAddr` - Page address.
  `payload` - Payload bytes.
  `lastLink` - Link to the previous written fragment (link to the tail).
  `pageSize` - Page size.
Throws:
  `IgniteCheckedException` - If failed.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017