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

## Class AbstractDataPageIO<T extends Storable>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO
  - - org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO<T>

Direct Known Subclasses:
  DataPageIO, SimpleDataPageIO

    public abstract class AbstractDataPageIO<T extends Storable>
    extends PageIO

Data pages IO.

### Nested Class Summary

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

### Field Summary

Fields
`static int` `ITEMS_OFF`
`static int` `MIN_DATA_PAGE_OVERHEAD`

### 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_METASTORAGE, T_DATA_REF_INNER, T_DATA_REF_LEAF, T_DATA_REF_METASTORAGE_INNER, T_DATA_REF_METASTORAGE_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` `AbstractDataPageIO(int type, int ver)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete 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 pageId, long pageAddr, T 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, T 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.
`protected boolean` `checkIndex(int idx)`
`<T> List<T>` `forAllItems(long pageAddr, AbstractDataPageIO.CC<T> c)`
`protected int` `getDataOffset(long pageAddr, int itemId, int pageSize)`
`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".
`abstract int` `getRowSize(T row)`
`void` `initNewPage(long pageAddr, long pageId, int pageSize)`
`boolean` `isEmpty(long pageAddr)`
`protected boolean` `isFragmented(long pageAddr, int dataOff)`
`protected void` `printPageLayout(long pageAddr, int pageSize, GridStringBuilder b)`
`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, T row, int rowSize)`
`protected abstract void` `writeFragmentData(T row, ByteBuffer buf, int rowOff, int payloadSize)` Write row data fragment.
`protected void` `writeRowData(long pageAddr, int dataOff, byte[] payload)`
`protected abstract void` `writeRowData(long pageAddr, int dataOff, int payloadSize, T row, boolean newRow)`

### 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, printPage, printPage, 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

#### ITEMS_OFF

    public static final int ITEMS_OFF

See Also:
  Constant Field Values

#### MIN_DATA_PAGE_OVERHEAD

    public static final int MIN_DATA_PAGE_OVERHEAD

See Also:
  Constant Field Values

### Constructor Detail

#### AbstractDataPageIO

    protected AbstractDataPageIO(int type,
                                 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,
                                   AbstractDataPageIO.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.

#### checkIndex

    protected boolean checkIndex(int idx)

Parameters:
  `idx` - Index.
Returns:
  `true` If the index is valid.

#### printPageLayout

    protected void printPageLayout(long pageAddr,
                                   int pageSize,
                                   GridStringBuilder b)

Parameters:
  `pageAddr` - Page address.
  `pageSize` - Page size.
  `b` - B.

#### getDataOffset

    protected int getDataOffset(long pageAddr,
                                int itemId,
                                int pageSize)

Parameters:
  `pageAddr` - Page address.
  `itemId` - Fixed item ID (the index used for referencing an entry from the outside).
  `pageSize` - Page size.
Returns:
  Data entry offset in bytes.

#### isFragmented

    protected boolean isFragmented(long pageAddr,
                                   int dataOff)

Parameters:
  `pageAddr` - Page address.
  `dataOff` - Data offset.
Returns:
  `true` If the data row is fragmented across multiple pages.

#### 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
                             T 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 pageId,
                       long pageAddr,
                       T 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` - 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,
                              T 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` - 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.

#### writeFragmentData

    protected abstract void writeFragmentData(T row,
                                              ByteBuffer buf,
                                              int rowOff,
                                              int payloadSize)
                                       throws IgniteCheckedException

Write row data fragment.

Parameters:
  `row` - Row.
  `buf` - Byte buffer.
  `rowOff` - Offset in row data bytes.
  `payloadSize` - Data length that should be written in a fragment.
Throws:
  `IgniteCheckedException` - If failed.

#### writeRowData

    protected abstract void writeRowData(long pageAddr,
                                         int dataOff,
                                         int payloadSize,
                                         T row,
                                         boolean newRow)
                                  throws IgniteCheckedException

Parameters:
  `pageAddr` - Page address.
  `dataOff` - Data offset.
  `payloadSize` - Payload size.
  `row` - Data row.
  `newRow` - `False` if existing cache entry is updated, in this case skip key data write.
Throws:
  `IgniteCheckedException` - If failed.

#### writeRowData

    protected void writeRowData(long pageAddr,
                                int dataOff,
                                byte[] payload)

Parameters:
  `pageAddr` - Page address.
  `dataOff` - Data offset.
  `payload` - Payload

#### getRowSize

    public abstract int getRowSize(T row)
                            throws IgniteCheckedException

Parameters:
  `row` - Row.
Returns:
  Row size in page.
Throws:
  `IgniteCheckedException` - if failed.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018