Top Fields Constructors Methods
org.apache.derby.impl.store.access.btree

public Class LeafControlRow

extends ControlRow
Class Inheritance
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.StoredFormatIds, .FormatableBitSet, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, org.apache.derby.iapi.store.access.AccessFactoryGlobals, .ConglomerateController, org.apache.derby.iapi.store.raw.ContainerHandle, .FetchDescriptor, .Page, .RecordHandle, org.apache.derby.iapi.types.DataValueDescriptor

Field Summary

Inherited from org.apache.derby.impl.store.access.btree.ControlRow:
CR_COLID_FIRSTCR_COLID_LASTCR_CONGLOM_BITSETCR_CONGLOM_COLIDCR_ISROOT_BITSETCR_ISROOT_COLIDCR_LEFTSIB_BITSETCR_LEFTSIB_COLIDCR_LEVEL_BITSETCR_LEVEL_COLIDCR_NCOLUMNSCR_PARENT_BITSETCR_PARENT_COLIDCR_RIGHTSIB_BITSETCR_RIGHTSIB_COLIDCR_SLOTCR_VERSION_BITSETCR_VERSION_COLIDfetchDesclast_search_resultpagerowscratch_rowSPLIT_FLAG_FIRST_IN_TABLESPLIT_FLAG_FIRST_ON_PAGESPLIT_FLAG_LAST_IN_TABLESPLIT_FLAG_LAST_ON_PAGEuse_last_search_result_hint

Constructor Summary

AccessConstructor and Description
public
LeafControlRow()

No arg constructor.

pack-priv
LeafControlRow(OpenBTree
The open btree to allocate this page from.
btree
,
Page
The newly allocated page where the control row will be inserted.
page
,
ControlRow
The parent of the leaf page. Set to null for root. RESOLVE (mikem) - set to null otherwise?
parent
,
boolean
Is this page the root of the tree?
isRoot
)

Constructs a leaf-page control row, for a newly allocated leaf page.

Method Summary

Modifier and TypeMethod and Description
private static LeafControlRow
allocate(OpenBTree
The open conglomerate from which to get the leaf from
btree
,
ControlRow
The parent page of the newly allocated page, null if allocating root page.
parent
)

Allocate a new leaf page to the conglomerate.

public int
checkConsistency(OpenBTree
The open btree to associate latches/locks with.
btree
,
ControlRow
The parent page of this page, "null" if this page is root or if not maintaining parent links.
parent
,
boolean
Should the consistency check go to other pages (this option breaks the latch protocol).
check_other_pages
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

Perform consistency checks on a leaf page.</menu>

protected final void
controlRowInit()

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.controlRowInit.

Perform page specific initialization.

private float

Returns:

The requested non_deleted_row_count.
get_left_nondeleted_rowcnt
(int
Count non deleted row up to and including this slot.
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

Returns:

The page which is the leftmost child of this page.
getLeftChild
(OpenBTree
The open btree to associate latches/locks with.
btree
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getLeftChild.

Return the left child pointer for the page.

protected final int

Returns:

The total number of columns in the control row.
getNumberOfControlRowColumns
()

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getNumberOfControlRowColumns.

Get the number of columns in the control row.

protected ControlRow

Returns:

The page which is the rightmost child of this page.
getRightChild
(OpenBTree
The open btree to associate latches/locks with.
btree
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getRightChild.

Return the right child pointer for the page.

public int
private static void
growRoot(OpenBTree open_btree, DataValueDescriptor[] template, LeafControlRow leafroot)

Grow a new root page from a leaf page.

public static void
initEmptyBtree(OpenBTree
The open btree to initialize (container is open).
open_btree
)

Initialize conglomerate with one page, to be a 1 page btree.

public boolean

Returns:

true if the current page is the leftmost leaf of the tree, else return false.
isLeftmostLeaf
()

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.isLeftmostLeaf.

Is the current page the leftmost leaf of tree?

public boolean

Returns:

true if the current page is the rightmost leaf of the tree, else return false.
isRightmostLeaf
()

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.isRightmostLeaf.

Is the current page the rightmost leaf of tree?

public void
printTree(OpenBTree btree)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.printTree.

Recursively print the tree starting at current node in tree.

public ControlRow
search(SearchParameters sp)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.search.

Perform a search of this leaf page, ultimately returning the latched leaf page and row slot after which the given key belongs.

protected ControlRow

Returns:

The leftmost leaf page.
searchLeft
(OpenBTree
The open btree to associate latches/locks with.
btree
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.searchLeft.

Search and return the left most leaf page.

protected ControlRow

Returns:

The rightmost leaf page.
searchRight
(OpenBTree
The open btree to associate latches/locks with.
btree
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.searchRight.

Search and return the right most leaf page.

protected boolean
shrinkFor(OpenBTree btree, DataValueDescriptor[] key)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.shrinkFor.

Perform a recursive shrink operation for the key.

protected long

Returns:

page number of the newly allocated leaf page created by split.
splitFor
(OpenBTree
The open btree to associate latches with.
open_btree
,
DataValueDescriptor[]
A scratch area to use while searching for split pass.
template
,
BranchControlRow
The parent page of the current page in the split pass. starts at null for root.
parent_page
,
DataValueDescriptor[]
The key to make room for during the split pass.
splitrow
,
int
A flag used to direct where point of split should be chosen.
flag
)

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.splitFor.

Perform a top down split pass making room for the the key in "row".

Inherited from org.apache.derby.impl.store.access.btree.ControlRow:
auxObjectInvalidatedcheckGenericcheckRowOrdercheckSiblingscompareIndexRowFromPageToKeycompareIndexRowToKeycompareRowsOnSiblingsdebugPagegetgetgetConglomgetControlRowForPagegetIsRootgetLeftSiblinggetleftSiblingPageNumbergetLevelgetNoWaitgetPagegetParentPageNumbergetRightSiblinggetrightSiblingPageNumbergetRowgetRowTemplategetVersionlinkRightreleasesearchForEntrysearchForEntryBackwardsetIsRootsetLeftSiblingsetLevelsetParentsetRightSiblingsetVersiontoStringunlink

Constructor Detail

LeafControlRowback to summary
public LeafControlRow()

No arg constructor.

Public no arg constructor is for the monitor to call for format id implemenation, it should not be called for any other reason.

LeafControlRowback to summary
pack-priv LeafControlRow(OpenBTree btree, Page page, ControlRow parent, boolean isRoot) throws StandardException

Constructs a leaf-page control row, for a newly allocated leaf page.

Parameters
btree:OpenBTree

The open btree to allocate this page from.

page:Page

The newly allocated page where the control row will be inserted.

parent:ControlRow

The parent of the leaf page. Set to null for root. RESOLVE (mikem) - set to null otherwise?

isRoot:boolean

Is this page the root of the tree?

Exceptions
StandardException:
Standard exception policy.

Method Detail

allocateback to summary
private static LeafControlRow allocate(OpenBTree btree, ControlRow parent) throws StandardException

Allocate a new leaf page to the conglomerate.

Parameters
btree:OpenBTree

The open conglomerate from which to get the leaf from

parent:ControlRow

The parent page of the newly allocated page, null if allocating root page.

Exceptions
StandardException:
Standard exception policy.
checkConsistencyback to summary
public int checkConsistency(OpenBTree btree, ControlRow parent, boolean check_other_pages) throws StandardException

Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

Perform consistency checks on a leaf page. Check consistency of the page and its children, returning the number of pages seen, and throwing errors if inconsistencies are found. The checks specific to a leaf page are:

  • Page is at level 0.
  • Version is a valid leaf page version.
  • Control row has right number of columns for leaf.
  • This method also performs the consistency checks that are common to both leaf and branch pages.
    Parameters
    btree:OpenBTree

    Doc from org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

    The open btree to associate latches/locks with.

    parent:ControlRow

    Doc from org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

    The parent page of this page, "null" if this page is root or if not maintaining parent links.

    check_other_pages:boolean

    Doc from org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

    Should the consistency check go to other pages (this option breaks the latch protocol).

    Returns:int

    Doc from org.apache.derby.impl.store.access.btree.ControlRow.checkConsistency.

    The identifier to be used to open the conglomerate later.

    Exceptions
    StandardException:
    Standard exception policy.
    See Also
    ControlRow#checkGeneric
    controlRowInitback to summary
    protected final void controlRowInit()

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.controlRowInit.

    Perform page specific initialization.

    get_left_nondeleted_rowcntback to summary
    private float get_left_nondeleted_rowcnt(int startslot) throws StandardException

    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".

    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?

    Parameters
    startslot:int

    Count non deleted row up to and including this slot.

    Returns:float

    The requested non_deleted_row_count.

    Exceptions
    StandardException:
    Standard exception policy.
    getLeftChildback to summary
    protected ControlRow getLeftChild(OpenBTree btree) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getLeftChild.

    Return the left child pointer for the page.

    Leaf pages don't have children, so they override this and return null.

    Parameters
    btree:OpenBTree

    The open btree to associate latches/locks with.

    Returns:ControlRow

    The page which is the leftmost child of this page.

    Exceptions
    StandardException:
    Standard exception policy.
    getNumberOfControlRowColumnsback to summary
    protected final int getNumberOfControlRowColumns()

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getNumberOfControlRowColumns.

    Get the number of columns in the control row.

    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.

    Returns:int

    The total number of columns in the control row.

    getRightChildback to summary
    protected ControlRow getRightChild(OpenBTree btree) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.getRightChild.

    Return the right child pointer for the page.

    Leaf pages don't have children, so they override this and return null.

    Parameters
    btree:OpenBTree

    The open btree to associate latches/locks with.

    Returns:ControlRow

    The page which is the rightmost child of this page.

    Exceptions
    StandardException:
    Standard exception policy.
    getTypeFormatIdback to summary
    public int getTypeFormatId()

    Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

    Return my format identifier.

    Returns:int

    Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

    The identifier. (A UUID stuffed in an array of 16 bytes).

    See Also
    org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
    growRootback to summary
    private static void growRoot(OpenBTree open_btree, DataValueDescriptor[] template, LeafControlRow leafroot) throws StandardException

    Grow a new root page from a leaf page. Slightly tricky because we want to retain page 0 as the root.

    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.

    initEmptyBtreeback to summary
    public static void initEmptyBtree(OpenBTree open_btree) throws StandardException

    Initialize conglomerate with one page, to be a 1 page btree. Given a conglomerate which already has one page allocated to it, initialize the page to be a leaf-root page with no entries. Allocate the control row and store it on the page.

    Parameters
    open_btree:OpenBTree

    The open btree to initialize (container is open).

    Exceptions
    StandardException:
    Standard exception policy.
    isLeftmostLeafback to summary
    public boolean isLeftmostLeaf() throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.isLeftmostLeaf.

    Is the current page the leftmost leaf of tree?

    Returns:boolean

    true if the current page is the leftmost leaf of the tree, else return false.

    Exceptions
    StandardException:
    Standard exception policy.
    isRightmostLeafback to summary
    public boolean isRightmostLeaf() throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.isRightmostLeaf.

    Is the current page the rightmost leaf of tree?

    Returns:boolean

    true if the current page is the rightmost leaf of the tree, else return false.

    Exceptions
    StandardException:
    Standard exception policy.
    printTreeback to summary
    public void printTree(OpenBTree btree) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.printTree.

    Recursively print the tree starting at current node in tree. This is a leaf so return.

    Exceptions
    StandardException:
    Standard exception policy.
    searchback to summary
    public ControlRow search(SearchParameters sp) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.search.

    Perform a search of this leaf page, ultimately returning the latched leaf page and row slot after which the given key belongs. The slot is returned in the result structure. If the key exists on the page, the result.exact will be true. Otherwise, result.exact will be false, and the row slot returned will be the one immediately preceding the position at which the key belongs.

    Exceptions
    StandardException:
    Standard exception policy.
    searchLeftback to summary
    protected ControlRow searchLeft(OpenBTree btree) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.searchLeft.

    Search and return the left most leaf page.

    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()).

    Parameters
    btree:OpenBTree

    The open btree to associate latches/locks with.

    Returns:ControlRow

    The leftmost leaf page.

    Exceptions
    StandardException:
    Standard exception policy.
    searchRightback to summary
    protected ControlRow searchRight(OpenBTree btree) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.searchRight.

    Search and return the right most leaf page.

    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()).

    Parameters
    btree:OpenBTree

    The open btree to associate latches/locks with.

    Returns:ControlRow

    The rightmost leaf page.

    Exceptions
    StandardException:
    Standard exception policy.
    shrinkForback to summary
    protected boolean shrinkFor(OpenBTree btree, DataValueDescriptor[] key) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.shrinkFor.

    Perform a recursive shrink operation for the key. If this method returns true, the caller should remove the corresponding entry for the page. This routine is not guaranteed to successfully shrink anything. The page lead to by the key might turn out not to be empty by the time shrink gets there, and shrinks will give up if there is a deadlock.

    The receiver page must be latched on entry and is returned unlatched.

    Exceptions
    StandardException:
    Standard exception policy.
    splitForback to summary
    protected long splitFor(OpenBTree open_btree, DataValueDescriptor[] template, BranchControlRow parent_page, DataValueDescriptor[] splitrow, int flag) throws StandardException

    Implements abstract org.apache.derby.impl.store.access.btree.ControlRow.splitFor.

    Perform a top down split pass making room for the the key in "row".

    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.

    Parameters
    open_btree:OpenBTree

    The open btree to associate latches with.

    template:DataValueDescriptor[]

    A scratch area to use while searching for split pass.

    parent_page:BranchControlRow

    The parent page of the current page in the split pass. starts at null for root.

    splitrow:DataValueDescriptor[]

    The key to make room for during the split pass.

    flag:int

    A flag used to direct where point of split should be chosen.

    Returns:long

    page number of the newly allocated leaf page created by split.

    Exceptions
    StandardException:
    Standard exception policy.