Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.store.access.btree
Class LeafControlRow  view LeafControlRow download LeafControlRow.java

java.lang.Object
  extended byorg.apache.derby.impl.store.access.btree.ControlRow
      extended byorg.apache.derby.impl.store.access.btree.LeafControlRow
All Implemented Interfaces:
org.apache.derby.iapi.store.raw.AuxObject, org.apache.derby.iapi.services.io.TypedFormat

public class LeafControlRow
extends ControlRow


Field Summary
 
Fields inherited from class org.apache.derby.impl.store.access.btree.ControlRow
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 Summary
  LeafControlRow()
          No arg constructor.
(package private) LeafControlRow(OpenBTree btree, org.apache.derby.iapi.store.raw.Page page, ControlRow parent, boolean isRoot)
          Constructs a leaf-page control row, for a newly allocated leaf page.
 
Method Summary
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"
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, org.apache.derby.iapi.types.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, org.apache.derby.iapi.types.DataValueDescriptor[] key)
          Perform a recursive shrink operation for the key.
protected  long splitFor(OpenBTree open_btree, org.apache.derby.iapi.types.DataValueDescriptor[] template, BranchControlRow parent_page, org.apache.derby.iapi.types.DataValueDescriptor[] splitrow, int flag)
          Perform a top down split pass making room for the the key in "row".
 
Methods inherited from class org.apache.derby.impl.store.access.btree.ControlRow
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeafControlRow

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.


LeafControlRow

LeafControlRow(OpenBTree btree,
               org.apache.derby.iapi.store.raw.Page page,
               ControlRow parent,
               boolean isRoot)
         throws org.apache.derby.iapi.error.StandardException
Constructs a leaf-page control row, for a newly allocated leaf page.

Method Detail

Allocate

private static LeafControlRow Allocate(OpenBTree btree,
                                       ControlRow parent)
                                throws org.apache.derby.iapi.error.StandardException
Allocate a new leaf page to the conglomerate.


get_left_nondeleted_rowcnt

private float get_left_nondeleted_rowcnt(int startslot)
                                  throws org.apache.derby.iapi.error.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?


ControlRowInit

protected final void ControlRowInit()
Perform page specific initialization.

Specified by:
ControlRowInit in class ControlRow

initEmptyBtree

public static void initEmptyBtree(OpenBTree open_btree)
                           throws org.apache.derby.iapi.error.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.


getNumberOfControlRowColumns

protected final int 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.

Specified by:
getNumberOfControlRowColumns in class ControlRow

isLeftmostLeaf

public boolean isLeftmostLeaf()
                       throws org.apache.derby.iapi.error.StandardException
Is the current page the leftmost leaf of tree?

Specified by:
isLeftmostLeaf in class ControlRow

isRightmostLeaf

public boolean isRightmostLeaf()
                        throws org.apache.derby.iapi.error.StandardException
Is the current page the rightmost leaf of tree?

Specified by:
isRightmostLeaf in class ControlRow

search

public ControlRow search(SearchParameters sp)
                  throws org.apache.derby.iapi.error.StandardException
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.

Specified by:
search in class ControlRow

searchLeft

protected ControlRow searchLeft(OpenBTree btree)
                         throws org.apache.derby.iapi.error.StandardException
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()).

Specified by:
searchLeft in class ControlRow

searchRight

protected ControlRow searchRight(OpenBTree btree)
                          throws org.apache.derby.iapi.error.StandardException
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()).

Specified by:
searchRight in class ControlRow

shrinkFor

protected boolean shrinkFor(OpenBTree btree,
                            org.apache.derby.iapi.types.DataValueDescriptor[] key)
                     throws org.apache.derby.iapi.error.StandardException
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.

Specified by:
shrinkFor in class ControlRow

splitFor

protected long splitFor(OpenBTree open_btree,
                        org.apache.derby.iapi.types.DataValueDescriptor[] template,
                        BranchControlRow parent_page,
                        org.apache.derby.iapi.types.DataValueDescriptor[] splitrow,
                        int flag)
                 throws org.apache.derby.iapi.error.StandardException
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.

Specified by:
splitFor in class ControlRow

growRoot

private static void growRoot(OpenBTree open_btree,
                             org.apache.derby.iapi.types.DataValueDescriptor[] template,
                             LeafControlRow leafroot)
                      throws org.apache.derby.iapi.error.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.


getLeftChild

protected ControlRow getLeftChild(OpenBTree btree)
                           throws org.apache.derby.iapi.error.StandardException
Return the left child pointer for the page.

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

Specified by:
getLeftChild in class ControlRow

getRightChild

protected ControlRow getRightChild(OpenBTree btree)
                            throws org.apache.derby.iapi.error.StandardException
Return the right child pointer for the page.

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

Specified by:
getRightChild in class ControlRow

checkConsistency

public int checkConsistency(OpenBTree btree,
                            ControlRow parent,
                            boolean check_other_pages)
                     throws org.apache.derby.iapi.error.StandardException
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.

    Specified by:
    checkConsistency in class ControlRow

    printTree

    public void printTree(OpenBTree btree)
                   throws org.apache.derby.iapi.error.StandardException
    Recursively print the tree starting at current node in tree. This is a leaf so return.

    Specified by:
    printTree in class ControlRow

    getTypeFormatId

    public int getTypeFormatId()
    Return my format identifier.