Package org.apache.ignite.internal.processors.cache.persistence.freelist.io

## Class PagesListNodeIO

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

All Implemented Interfaces:
  `CompactablePageIO`

    public class PagesListNodeIO
    extends PageIO
    implements CompactablePageIO

TODO optimize: now we have slow `removePage(long, long)`

### Field Summary

Fields
`static IOVersions<PagesListNodeIO>` `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, ROTATED_ID_PART_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_PART, T_DATA_REF_INNER, T_DATA_REF_LEAF, T_DATA_REF_METASTORAGE_INNER, T_DATA_REF_METASTORAGE_LEAF, T_DEFRAG_LINK_MAPPING_INNER, T_DEFRAG_LINK_MAPPING_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_MARKER_PAGE, 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` `PagesListNodeIO​(int ver)`

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `addPage​(long pageAddr, long pageId, int pageSize)` Adds page to the end of pages list.
`void` `compactPage​(ByteBuffer page, ByteBuffer out, int pageSize)` Compacts page contents to the output buffer.
`long` `getAt​(long pageAddr, int idx)`
`int` `getCapacity​(int pageSize)` Gets capacity of this page in items.
`int` `getCount​(long pageAddr)` Gets total count of entries in this page.
`int` `getFreeSpace​(int pageSize, long pageAddr)` Count of bytes that is currently free in this page and possibly can be used to place additional payload.
`long` `getNextId​(long pageAddr)`
`long` `getPreviousId​(long pageAddr)`
`void` `initNewPage​(long pageAddr, long pageId, int pageSize, PageMetrics metrics)`
`boolean` `isEmpty​(long pageAddr)`
`protected void` `printPage​(long addr, int pageSize, GridStringBuilder sb)`
`boolean` `removePage​(long pageAddr, long dataPageId)` Removes the given page ID from the pages list.
`void` `restorePage​(ByteBuffer compactPage, int pageSize)` Restores the original page in place.
`void` `setNextId​(long pageAddr, long nextId)`
`void` `setPreviousId​(long pageAddr, long prevId)`
`long` `takeAnyPage​(long pageAddr)` Removes any page from the pages list.

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

`assertPageType, assertPageType, copyPage, deriveIndexPageType, getBPlusIO, getBPlusIO, getCompactedSize, getCompactedSize, getCompressedSize, getCompressedSize, getCompressionType, getCompressionType, getCrc, getCrc, getInnerVersions, getLeafVersions, getPageId, getPageId, getPageIO, getPageIO, getPageIO, getRotatedIdPart, getType, getType, getType, getVersion, getVersion, getVersion, isDataPageType, isIndexPage, printPage, registerH2, registerH2ExtraInner, registerH2ExtraLeaf, registerTest, registerTest, setCompactedSize, setCompressedSize, setCompressionType, setCrc, setCrc, setPageId, setRotatedIdPart, setType, setVersion, 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<PagesListNodeIO> VERSIONS

### Constructor Detail

#### PagesListNodeIO

    protected PagesListNodeIO​(int ver)

Parameters:
  `ver` - Page format version.

### Method Detail

#### initNewPage

    public void initNewPage​(long pageAddr,
                            long pageId,
                            int pageSize,
                            PageMetrics metrics)

Overrides:
  `initNewPage` in class `PageIO`
Parameters:
  `pageAddr` - Page address.
  `pageId` - Page ID.
  `pageSize` - Page size.
  `metrics` - Page metrics for tracking page allocation. Can be `null` if no tracking is required.
See Also:
  `EncryptionSpi.encryptedSize(int)`

#### getNextId

    public long getNextId​(long pageAddr)

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

#### setNextId

    public void setNextId​(long pageAddr,
                          long nextId)

Parameters:
  `pageAddr` - Page address.
  `nextId` - Next page ID.

#### getPreviousId

    public long getPreviousId​(long pageAddr)

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

#### setPreviousId

    public void setPreviousId​(long pageAddr,
                              long prevId)

Parameters:
  `pageAddr` - Page address.
  `prevId` - Previous page ID.

#### getCount

    public int getCount​(long pageAddr)

Gets total count of entries in this page. Does not change the buffer state.

Parameters:
  `pageAddr` - Page address to get count from.
Returns:
  Total number of entries.

#### getCapacity

    public int getCapacity​(int pageSize)

Gets capacity of this page in items.

Parameters:
  `pageSize` - Page size.
Returns:
  Capacity of this page in items.

#### getAt

    public long getAt​(long pageAddr,
                      int idx)

Parameters:
  `pageAddr` - Page address.
  `idx` - Item index.
Returns:
  Item at the given index.

#### addPage

    public int addPage​(long pageAddr,
                       long pageId,
                       int pageSize)

Adds page to the end of pages list.

Parameters:
  `pageAddr` - Page address.
  `pageId` - Page ID.
  `pageSize` - Page size.
Returns:
  Total number of items in this page.

#### takeAnyPage

    public long takeAnyPage​(long pageAddr)

Removes any page from the pages list.

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

#### removePage

    public boolean removePage​(long pageAddr,
                              long dataPageId)

Removes the given page ID from the pages list.

Parameters:
  `pageAddr` - Page address.
  `dataPageId` - Page ID to remove.
Returns:
  `true` if page was in the list and was removed, `false` otherwise.

#### isEmpty

    public boolean isEmpty​(long pageAddr)

Parameters:
  `pageAddr` - Page address.
Returns:
  `True` if there are no items in this page.

#### compactPage

    public void compactPage​(ByteBuffer page,
                            ByteBuffer out,
                            int pageSize)

Compacts page contents to the output buffer. Implementation must not change contents, position and limit of the original page buffer.

Specified by:
  `compactPage` in interface `CompactablePageIO`
Parameters:
  `page` - Page buffer.
  `out` - Output buffer.
  `pageSize` - Page size.

#### restorePage

    public void restorePage​(ByteBuffer compactPage,
                            int pageSize)

Restores the original page in place.

Specified by:
  `restorePage` in interface `CompactablePageIO`
Parameters:
  `compactPage` - Compact page.
  `pageSize` - Page size.

#### printPage

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

Specified by:
  `printPage` in class `PageIO`
Parameters:
  `addr` - Address.
  `pageSize` - Page size.
  `sb` - Sb.
Throws:
  `IgniteCheckedException`

#### getFreeSpace

    public int getFreeSpace​(int pageSize,
                            long pageAddr)

Count of bytes that is currently free in this page and possibly can be used to place additional payload.

Specified by:
  `getFreeSpace` in class `PageIO`
Parameters:
  `pageSize` - Page size.
  `pageAddr` - Page address.
Returns:
  Free space.