public class LeafControlRow extends ControlRow
Format ID | ACCESS_BTREE_LEAFCONTROLROW_V1_ID |
Purpose | Btree pages all have a control row at the front of every page. To determine the type of row, read the first column which is a format id and it tells what kind of control row it is. |
Upgrade | This format was made obsolete in the kimono release. |
Disk Layout | column 1 - control row type : StorableFormatId column 2 - left sibling page number : SQLLongint column 3 - right sibling page number: SQLLongint column 4 - parent page number : SQLLongint column 5 - level number (0 is leaf) : SQLLongint column 6 - isRoot : SQLLongint column 7 - Conglomerate object : null unless it is root else a Conglomerate object, matching that of current table. Currently this field is only used by logical undo and the type of object is inferred by the logical undo code. |
CR_COLID_FIRST, CR_COLID_LAST, CR_CONGLOM_BITSET, CR_CONGLOM_COLID, CR_ISROOT_BITSET, CR_ISROOT_COLID, CR_LEFTSIB_BITSET, CR_LEFTSIB_COLID, CR_LEVEL_BITSET, CR_LEVEL_COLID, CR_NCOLUMNS, CR_PARENT_BITSET, CR_PARENT_COLID, CR_RIGHTSIB_BITSET, CR_RIGHTSIB_COLID, CR_SLOT, CR_VERSION_BITSET, CR_VERSION_COLID, fetchDesc, last_search_result, page, row, scratch_row, SPLIT_FLAG_FIRST_IN_TABLE, SPLIT_FLAG_FIRST_ON_PAGE, SPLIT_FLAG_LAST_IN_TABLE, SPLIT_FLAG_LAST_ON_PAGE, use_last_search_result_hint
Constructor and Description |
---|
LeafControlRow()
No arg constructor.
|
LeafControlRow(OpenBTree btree,
Page page,
ControlRow parent,
boolean isRoot)
Constructs a leaf-page control row, for a newly allocated leaf page.
|
Modifier and Type | Method and Description |
---|---|
private static LeafControlRow |
allocate(OpenBTree btree,
ControlRow parent)
Allocate a new leaf page to the conglomerate.
|
int |
checkConsistency(OpenBTree btree,
ControlRow parent,
boolean check_other_pages)
Perform consistency checks on a leaf page.
|
protected void |
controlRowInit()
Perform page specific initialization.
|
private float |
get_left_nondeleted_rowcnt(int startslot)
Return the number of non-deleted rows from slot 1 through "startslot"
Return the number of non-deleted rows that exist on the page starting
at slot one through "startslot".
|
protected ControlRow |
getLeftChild(OpenBTree btree)
Return the left child pointer for the page.
|
protected int |
getNumberOfControlRowColumns()
Get the number of columns in the control row.
|
protected ControlRow |
getRightChild(OpenBTree btree)
Return the right child pointer for the page.
|
int |
getTypeFormatId()
Return my format identifier.
|
private static void |
growRoot(OpenBTree open_btree,
DataValueDescriptor[] template,
LeafControlRow leafroot)
Grow a new root page from a leaf page.
|
static void |
initEmptyBtree(OpenBTree open_btree)
Initialize conglomerate with one page, to be a 1 page btree.
|
boolean |
isLeftmostLeaf()
Is the current page the leftmost leaf of tree?
|
boolean |
isRightmostLeaf()
Is the current page the rightmost leaf of tree?
|
void |
printTree(OpenBTree btree)
Recursively print the tree starting at current node in tree.
|
ControlRow |
search(SearchParameters sp)
Perform a search of this leaf page, ultimately returning the latched
leaf page and row slot after which the given key belongs.
|
protected ControlRow |
searchLeft(OpenBTree btree)
Search and return the left most leaf page.
|
protected ControlRow |
searchRight(OpenBTree btree)
Search and return the right most leaf page.
|
protected boolean |
shrinkFor(OpenBTree btree,
DataValueDescriptor[] key)
Perform a recursive shrink operation for the key.
|
protected long |
splitFor(OpenBTree open_btree,
DataValueDescriptor[] template,
BranchControlRow parent_page,
DataValueDescriptor[] splitrow,
int flag)
Perform a top down split pass making room for the the key in "row".
|
auxObjectInvalidated, checkGeneric, checkRowOrder, checkSiblings, compareIndexRowFromPageToKey, compareIndexRowToKey, compareRowsOnSiblings, debugPage, get, get, getConglom, getControlRowForPage, getIsRoot, getLeftSibling, getleftSiblingPageNumber, getLevel, getNoWait, getPage, getParentPageNumber, getRightSibling, getrightSiblingPageNumber, getRow, getRowTemplate, getVersion, linkRight, release, searchForEntry, searchForEntryBackward, setIsRoot, setLeftSibling, setLevel, setParent, setRightSibling, setVersion, toString, unlink
public LeafControlRow()
Public no arg constructor is for the monitor to call for format id implemenation, it should not be called for any other reason.
LeafControlRow(OpenBTree btree, Page page, ControlRow parent, boolean isRoot) throws StandardException
btree
- The open btree to allocate this page from.page
- The newly allocated page where the control row will
be inserted.parent
- The parent of the leaf page. Set to null for root.
RESOLVE (mikem) - set to null otherwise?isRoot
- Is this page the root of the tree?StandardException
- Standard exception policy.private static LeafControlRow allocate(OpenBTree btree, ControlRow parent) throws StandardException
btree
- The open conglomerate from which to get the leaf fromparent
- The parent page of the newly allocated page, null if
allocating root page.StandardException
- Standard exception policy.private float get_left_nondeleted_rowcnt(int startslot) throws StandardException
Return the number of non-deleted rows that exist on the page starting at slot one through "startslot".
RESOLVE (mikem) - is the expense of this routine worth it, it is only used for costing. Could an estimate from the nonDeletedRecordCount() be used instead?
startslot
- Count non deleted row up to and including this slot.StandardException
- Standard exception policy.protected final void controlRowInit()
controlRowInit
in class ControlRow
public static void initEmptyBtree(OpenBTree open_btree) throws StandardException
open_btree
- The open btree to initialize (container is open).StandardException
- Standard exception policy.protected final int getNumberOfControlRowColumns()
Control rows all share the first columns as defined by this class and then add columns to the end of the control row. For instance a branch control row add a child page pointer field.
getNumberOfControlRowColumns
in class ControlRow
public boolean isLeftmostLeaf() throws StandardException
isLeftmostLeaf
in class ControlRow
StandardException
- Standard exception policy.public boolean isRightmostLeaf() throws StandardException
isRightmostLeaf
in class ControlRow
StandardException
- Standard exception policy.public ControlRow search(SearchParameters sp) throws StandardException
search
in class ControlRow
StandardException
- Standard exception policy.protected ControlRow searchLeft(OpenBTree btree) throws StandardException
Perform a recursive search, ultimately returning the leftmost leaf page which is the first leaf page in the leaf sibling chain. (This method might better be called getFirstLeafPage()).
searchLeft
in class ControlRow
btree
- The open btree to associate latches/locks with.StandardException
- Standard exception policy.protected ControlRow searchRight(OpenBTree btree) throws StandardException
Perform a recursive search, ultimately returning the rightmost leaf page which is the last leaf page in the leaf sibling chain. (This method might better be called getLastLeafPage()).
searchRight
in class ControlRow
btree
- The open btree to associate latches/locks with.StandardException
- Standard exception policy.protected boolean shrinkFor(OpenBTree btree, DataValueDescriptor[] key) throws StandardException
The receiver page must be latched on entry and is returned unlatched.
shrinkFor
in class ControlRow
StandardException
- Standard exception policy.protected long splitFor(OpenBTree open_btree, DataValueDescriptor[] template, BranchControlRow parent_page, DataValueDescriptor[] splitrow, int flag) throws StandardException
Perform a split such that a subsequent call to insert given the argument index row will likely find room for it. Since latches are released the client must code for the case where another user has grabbed the space made available by the split pass and be ready to do another split.
On entry, the parent is either null or latched, and the current page is latched. On exit, all pages will have been unlatched. If the parent is null, then this page is a root leaf page.
splitFor
in class ControlRow
open_btree
- The open btree to associate latches with.template
- A scratch area to use while searching for split pass.parent_page
- The parent page of the current page in the split pass.
starts at null for root.splitrow
- The key to make room for during the split pass.flag
- A flag used to direct where point of split should be
chosen.StandardException
- Standard exception policy.private static void growRoot(OpenBTree open_btree, DataValueDescriptor[] template, LeafControlRow leafroot) throws StandardException
On entry, the current leaf root page is expected to be latched. On exit, all latches will have been released.
The caller cannot not assume success. If we have to release latches this routine just returns and assumes the caller will retry the grow root if necessary.
StandardException
protected ControlRow getLeftChild(OpenBTree btree) throws StandardException
Leaf pages don't have children, so they override this and return null.
getLeftChild
in class ControlRow
btree
- The open btree to associate latches/locks with.StandardException
- Standard exception policy.protected ControlRow getRightChild(OpenBTree btree) throws StandardException
Leaf pages don't have children, so they override this and return null.
getRightChild
in class ControlRow
btree
- The open btree to associate latches/locks with.StandardException
- Standard exception policy.public int checkConsistency(OpenBTree btree, ControlRow parent, boolean check_other_pages) throws StandardException
checkConsistency
in class ControlRow
btree
- The open btree to associate latches/locks with.parent
- The parent page of this page, "null" if this page is
root or if not maintaining parent links.check_other_pages
- Should the consistency check go to other pages (this
option breaks the latch protocol).StandardException
- Standard exception policy.ControlRow.checkGeneric(org.apache.derby.impl.store.access.btree.OpenBTree, org.apache.derby.impl.store.access.btree.ControlRow, boolean)
public void printTree(OpenBTree btree) throws StandardException
printTree
in class ControlRow
StandardException
- Standard exception policy.public int getTypeFormatId()
TypedFormat.getTypeFormatId()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.