Class BPlusIO<L>
java.lang.Object
org.apache.ignite.internal.persistence.tree.io.PageIO
org.apache.ignite.internal.persistence.tree.io.BPlusIO<L>
- All Implemented Interfaces:
CompactablePageIO
- Direct Known Subclasses:
BPlusInnerIO,BPlusLeafIO
Abstract IO routines for B+Tree pages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected final intAll the items must be of fixed size.Fields inherited from class org.apache.ignite.internal.persistence.tree.io.PageIO
COMMON_HEADER_END, CRC_OFF, MAX_PAYLOAD_SIZE, PAGE_ID_OFF, ROTATED_ID_PART_OFF, T_BM_BINARY_DATA, T_BM_BINARY_LONG_INDEX_INNER, T_BM_BINARY_LONG_INDEX_LEAF, T_BM_CONTAINED_OBJECT_INDEX_INNER, T_BM_CONTAINED_OBJECT_INDEX_LEAF, T_BM_INT_INT_INDEX_INNER, T_BM_INT_INT_INDEX_LEAF, T_BM_LONG_DATA, T_BM_LONG_DATA_REF_INNER, T_BM_LONG_DATA_REF_LEAF, T_BM_OBJECT_DATA, T_BM_OBJECT_DATA_REF_INNER, T_BM_OBJECT_DATA_REF_LEAF, 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_CACHE_ID_DATA_REF_MVCC_INNER, T_CACHE_ID_DATA_REF_MVCC_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_DATA_REF_MVCC_INNER, T_DATA_REF_MVCC_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_EX_REF_MVCC_INNER_END, T_H2_EX_REF_MVCC_INNER_START, T_H2_EX_REF_MVCC_LEAF_END, T_H2_EX_REF_MVCC_LEAF_START, T_H2_MVCC_REF_INNER, T_H2_MVCC_REF_LEAF, 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, T_TX_LOG_INNER, T_TX_LOG_LEAF, TYPE_OFF, VER_OFF -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBPlusIO(int type, int ver, boolean leaf, boolean canGetRow, int itemSize) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanvoidcompactPage(ByteBuffer page, ByteBuffer out, int pageSize) Compacts page contents to the output buffer.abstract voidcopyItems(long srcPageAddr, long dstPageAddr, int srcIdx, int dstIdx, int cnt, boolean cpLeft) Copy items from source page to destination page.final intgetCount(long pageAddr) final longgetForward(long pageAddr) intgetItemsEnd(long pageAddr) final intabstract LgetLookupRow(BPlusTree<L, ?> tree, long pageAddr, int idx) Get lookup row.abstract intgetMaxCount(long pageAddr, int pageSize) final longgetRemoveId(long pageAddr) voidinitNewPage(long pageAddr, long pageId, int pageSize) byte[]final booleanisLeaf()booleanmerge(BPlusIO<L> prntIo, long prntPageAddr, int prntIdx, long leftPageAddr, long rightPageAddr, boolean emptyBranch, int pageSize) abstract intoffset(int idx) protected voidprintPage(long addr, int pageSize, GridStringBuilder sb) voidremove(long pageAddr, int idx, int cnt) voidrestorePage(ByteBuffer compactPage, int pageSize) Restores the original page in place.final voidsetCount(long pageAddr, int cnt) final voidsetForward(long pageAddr, long pageId) final voidsetRemoveId(long pageAddr, long rmvId) voidsplitExistingPage(long pageAddr, int mid, long fwdId) voidsplitForwardPage(long pageAddr, long fwdId, long fwdPageAddr, int mid, int cnt, int pageSize) final byte[]Store the needed info about the row in the page.abstract voidStore row info from the given source.abstract voidstoreByOffset(long pageAddr, int off, L row) Store the needed info about the row in the page.voidvisit(long pageAddr, IgniteInClosure<L> c) Methods inherited from class org.apache.ignite.internal.persistence.tree.io.PageIO
copyPage, 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, printPage, registerH2, registerH2ExtraInner, registerH2ExtraLeaf, registerTest, registerTest, setCompactedSize, setCompressedSize, setCompressionType, setCrc, setCrc, setPageId, setRotatedIdPart, setType, setVersion, toString
-
Field Details
-
ITEMS_OFF
protected static final int ITEMS_OFF- See Also:
-
itemSize
protected final int itemSizeAll the items must be of fixed size.
-
-
Constructor Details
-
BPlusIO
protected BPlusIO(int type, int ver, boolean leaf, boolean canGetRow, int itemSize) - Parameters:
type- Page type.ver- Page format version.leaf- If this is a leaf IO.canGetRow- If we can get full row from this page.
-
-
Method Details
-
getItemSize
public final int getItemSize()- Returns:
- Item size in bytes.
-
initNewPage
public void initNewPage(long pageAddr, long pageId, int pageSize) - Overrides:
initNewPagein classPageIO- Parameters:
pageAddr- Page address.pageId- Page ID.pageSize- Page size.- See Also:
-
EncryptionSpi#encryptedSize(int)
-
getForward
public final long getForward(long pageAddr) - Parameters:
pageAddr- Page address.- Returns:
- Forward page ID.
-
setForward
public final void setForward(long pageAddr, long pageId) - Parameters:
pageAddr- Page address.pageId- Forward page ID.
-
getRemoveId
public final long getRemoveId(long pageAddr) - Parameters:
pageAddr- Page address.- Returns:
- Remove ID.
-
setRemoveId
public final void setRemoveId(long pageAddr, long rmvId) - Parameters:
pageAddr- Page address.rmvId- Remove ID.
-
getCount
public final int getCount(long pageAddr) - Parameters:
pageAddr- Page address.- Returns:
- Items count in the page.
-
setCount
public final void setCount(long pageAddr, int cnt) - Parameters:
pageAddr- Page address.cnt- Count.
-
canGetRow
public final boolean canGetRow()- Returns:
trueIf we can get the full row from this page using methodBPlusTree.getRow(BPlusIO, long, int). Must always betruefor leaf pages.
-
isLeaf
public final boolean isLeaf()- Returns:
trueif it is a leaf page.
-
getMaxCount
public abstract int getMaxCount(long pageAddr, int pageSize) - Parameters:
pageAddr- Page address.pageSize- Page size without encryption overhead.- Returns:
- Max items count.
-
store
public final byte[] store(long pageAddr, int idx, L row, byte[] rowBytes, boolean needRowBytes) throws IgniteCheckedException Store the needed info about the row in the page. Leaf and inner pages can store different info.- Parameters:
pageAddr- Page address.idx- Index.row- Lookup or full row.rowBytes- Row bytes.needRowBytes- If we need stored row bytes.- Returns:
- Stored row bytes.
- Throws:
IgniteCheckedException- If failed.
-
offset
public abstract int offset(int idx) - Parameters:
idx- Index of element.- Returns:
- Offset from byte buffer begin in bytes.
-
storeByOffset
Store the needed info about the row in the page. Leaf and inner pages can store different info.- Parameters:
pageAddr- Page address.off- Offset in bytes.row- Lookup or full row.- Throws:
IgniteCheckedException- If failed.
-
store
public abstract void store(long dstPageAddr, int dstIdx, BPlusIO<L> srcIo, long srcPageAddr, int srcIdx) throws IgniteCheckedException Store row info from the given source.- Parameters:
dstPageAddr- Destination page address.dstIdx- Destination index.srcIo- Source IO.srcPageAddr- Source page address.srcIdx- Source index.- Throws:
IgniteCheckedException- If failed.
-
getLookupRow
public abstract L getLookupRow(BPlusTree<L, ?> tree, long pageAddr, int idx) throws IgniteCheckedExceptionGet lookup row.- Parameters:
tree- Tree.pageAddr- Page address.idx- Index.- Returns:
- Lookup row.
- Throws:
IgniteCheckedException- If failed.
-
copyItems
public abstract void copyItems(long srcPageAddr, long dstPageAddr, int srcIdx, int dstIdx, int cnt, boolean cpLeft) throws IgniteCheckedException Copy items from source page to destination page. Both pages must be of the same type and the same version.- Parameters:
srcPageAddr- Source page address.dstPageAddr- Destination page address.srcIdx- Source begin index.dstIdx- Destination begin index.cnt- Items count.cpLeft- Copy leftmost link (makes sense only for inner pages).- Throws:
IgniteCheckedException- If failed.
-
insert
public byte[] insert(long pageAddr, int idx, L row, byte[] rowBytes, long rightId, boolean needRowBytes) throws IgniteCheckedException - Parameters:
pageAddr- Page address.idx- Index.row- Row to insert.rowBytes- Row bytes.rightId- Page ID which will be to the right child for the inserted item.needRowBytes- If we need stored row bytes.- Returns:
- Row bytes.
- Throws:
IgniteCheckedException- If failed.
-
splitForwardPage
public void splitForwardPage(long pageAddr, long fwdId, long fwdPageAddr, int mid, int cnt, int pageSize) throws IgniteCheckedException - Parameters:
pageAddr- Splitting page address.fwdId- Forward page ID.fwdPageAddr- Forward page address.mid- Bisection index.cnt- Initial elements count in the page being split.pageSize- Page size.- Throws:
IgniteCheckedException- If failed.
-
splitExistingPage
public void splitExistingPage(long pageAddr, int mid, long fwdId) - Parameters:
pageAddr- Page address.mid- Bisection index.fwdId- New forward page ID.
-
remove
- Parameters:
pageAddr- Page address.idx- Index.cnt- Count.- Throws:
IgniteCheckedException- If failed.
-
merge
public boolean merge(BPlusIO<L> prntIo, long prntPageAddr, int prntIdx, long leftPageAddr, long rightPageAddr, boolean emptyBranch, int pageSize) throws IgniteCheckedException - Parameters:
prntIo- Parent IO.prntPageAddr- Parent page address.prntIdx- Split key index in parent.leftPageAddr- Left page address.rightPageAddr- Right page address.emptyBranch- We are merging an empty branch.pageSize- Page size without encryption overhead.- Returns:
falseIf we were not able to merge.- Throws:
IgniteCheckedException- If failed.
-
visit
- Parameters:
pageAddr- Page address.c- Closure.
-
printPage
protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException - Specified by:
printPagein classPageIO- Parameters:
addr- Address.pageSize- Page size.sb- Sb.- Throws:
IgniteCheckedException
-
getItemsEnd
public int getItemsEnd(long pageAddr) - Parameters:
pageAddr- Page address.- Returns:
- Offset after the last item.
-
compactPage
Compacts page contents to the output buffer. Implementation must not change contents, position and limit of the original page buffer.- Specified by:
compactPagein interfaceCompactablePageIO- Parameters:
page- Page buffer.out- Output buffer.pageSize- Page size.
-
restorePage
Restores the original page in place.- Specified by:
restorePagein interfaceCompactablePageIO- Parameters:
compactPage- Compact page.pageSize- Page size.
-