⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controlrow.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	/**	 ** Perform checks on the siblings of this page: make sure	 ** that they're at the same level as this page, that they're	 ** mutually linked together, and that the first/last keys	 ** on sibling pages are in order.    @exception StandardException Standard exception policy.	 **/	protected void checkSiblings(OpenBTree btree)        throws StandardException	{        if (SanityManager.DEBUG)        {            // Get this page's left sibling.            ControlRow leftsib  = null;            ControlRow rightsib = null;            try            {                try                {                    leftsib = this.getLeftSibling(btree);                }                catch (WaitError e)                {                    // In a normal system it may be possible to not get                    // the left sibling (some other thread either user                    // or daemon cache cleaner thread) may already have                    // the latch on the page, and waiting on it could cause                    // a latch/latch deadlock.  So for now just give up                    // doing the consistency check in this case.                    //                    // RESOLVE (mikem) - We could do fancier things than                     // ignore this error, but the only safe way to wait for                    // a right to left latch is to release current latch which                    // will complicate all the code, and this is only a sanity                    // check.                    // SanityManager.DEBUG_PRINT(                    //   "ControlRow.checkSiblings",                    //   this + " left sibling deadlock");                    // give up on checking the left sibling.                    leftsib = null;                }                // There may not be a left sibling; if there is, check it out.                if (leftsib != null)                {                    // Check that it's at the same level as this page.					if (leftsib.getLevel() != this.getLevel())                    	SanityManager.THROWASSERT(                        	(leftsib + "not at same level as " + this));                    // Check that its right sibling is this page.                    long hopefullythis_pageno =                         leftsib.getrightSiblingPageNumber();					if (hopefullythis_pageno != this.page.getPageNumber())                    	SanityManager.THROWASSERT(                        	"right sibling of " + leftsib + " isn't "  + this);                    // Check that its last row is < this page's first row.                    compareRowsOnSiblings(btree, leftsib, this);                    // Done looking at the left sibling.                    leftsib.release();                    leftsib = null;                }                // Get the right sibling page.                rightsib = this.getRightSibling(btree);                // There may not be a right sibling; if there is, check it out.                if (rightsib != null)                {                    // Check that it's at the same level as this page.					if (rightsib.getLevel() != this.getLevel())                    	SanityManager.THROWASSERT(                        	rightsib + "not at same level as " + this);                    // Check that its left sibling is this page.                    long hopefullythis_pageno =                         rightsib.getleftSiblingPageNumber();					if (hopefullythis_pageno != this.page.getPageNumber())                    	SanityManager.THROWASSERT(                        	"left sibling of " + rightsib + " isn't "  + this);                    // Check that its first row is > this page's last row.                    compareRowsOnSiblings(btree, this, rightsib);                    // Done looking at it.                    rightsib.release();                    rightsib = null;                }            }            finally            {                if (leftsib != null)                    leftsib.release();                if (rightsib != null)                    rightsib.release();            }        }	}	/**	 ** Link this page to the right of the target page.	 ** <P>	 ** Upon entry, this page and the target must be	 ** latched.  Upon exit, this page and the target	 ** remain latched.	 ** <P>	 ** This method carefully acquires pages from left	 ** to right in order to avoid deadlocks.    @exception StandardException Standard exception policy.	 */	void linkRight(OpenBTree btree, ControlRow target)        throws StandardException	{		ControlRow rightSibling = null;        try        {            rightSibling = target.getRightSibling(btree);            this.setRightSibling(rightSibling);            this.setLeftSibling(target);            if (rightSibling != null)                rightSibling.setLeftSibling(this);            target.setRightSibling(this);        }        finally        {            if (rightSibling != null)                rightSibling.release();        }	}	/**	 ** Unlink this page from its siblings.  This method	 ** will give up and return false rather than run the	 ** risk of a deadlock.	 ** <P>	 ** On entry this page must be latched.  The siblings	 ** are latched and unlatched during the operation.  Upon	 ** exit, this page will remain latched, but unlinked from	 ** its siblings and deallocated from the container.	 ** <P>	 ** The seemingly odd situation that this page will be	 ** returned latched but deallocated is intentional.	 ** The container will not be able to reuse this page	 ** until the latch is released, and the caller may still	 ** need to read information out of it.    @exception StandardException Standard exception policy.	 **/	boolean unlink(OpenBTree btree)        throws StandardException	{		ControlRow leftsib  = null;		ControlRow rightsib = null;		        try         {            // Try to get the left sibling, and give up if             // it can't be obtained without waiting.            try            {                leftsib = this.getLeftSibling(btree);            }            catch (WaitError e)            {                return false;            }            // We can wait for the right sibling since it's            // in the deadlock-free direction.            rightsib = this.getRightSibling(btree);            // Change the links that pointed to this page to            // point to the appropriate sibling.            if (leftsib != null)                leftsib.setRightSibling(rightsib);            if (rightsib != null)                rightsib.setLeftSibling(leftsib);            // Deallocate the page.            // Would need to clear out aux object here.            //            // RESOLVE (mikem) - how to deallocate a page. //            btree.container.removePage(this.page);            // After removePage call the current page is unlatched, and should            // not be referenced anymore.            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(!this.page.isLatched());            }            return true;        }        finally        {            // Unlatch the siblings.            if (leftsib != null)                leftsib.release();            if (rightsib != null)                rightsib.release();        }	}    public Page getPage()    {        return(page);    }    /**     * Get the row.     * <p>     * Return the object array that represents the control row for use     * in raw store fetch, insert, and/or update.     *	 * @return The row.     *     **/    protected final DataValueDescriptor[] getRow()    {        return(row);    }	/*	 * The following methods must be implemented by all	 * control rows.	 */    /**     * Check consistency of the page and its children, returning the number of      * pages seen, and throwing errors if inconsistencies are found.     * <p>     *	 * @return The identifier to be used to open the conglomerate later.     *     * @param btree  The open btree to associate latches/locks with.     * @param parent The parent page of this page, "null" if this page is      *               root or if not maintaining parent links.     * @param check_other_pages     *               Should the consistency check go to other pages (this      *               option breaks the latch protocol).     *	 * @exception  StandardException  Standard exception policy.     **/	abstract protected int checkConsistency(    OpenBTree  btree,     ControlRow parent,    boolean    check_other_pages)        throws StandardException;    /**     * Return the left child pointer for the page.     * <p>     * Leaf pages don't have children, so they override this and return null.     *	 * @return The page which is the leftmost child of this page.     *     * @param btree  The open btree to associate latches/locks with.     *	 * @exception  StandardException  Standard exception policy.     **/	protected abstract ControlRow getLeftChild(OpenBTree btree)        throws StandardException;    /**     * Return the right child pointer for the page.     * <p>     * Leaf pages don't have children, so they override this and return null.     *	 * @return The page which is the rightmost child of this page.     *     * @param btree  The open btree to associate latches/locks with.     *	 * @exception  StandardException  Standard exception policy.     **/	protected abstract ControlRow getRightChild(OpenBTree btree)        throws StandardException;    /**     * Perform page specific initialization.     * <p>     *	 * @return The identifier to be used to open the conglomerate later.     *     **/    protected abstract void ControlRowInit();    /**     * Is the current page the leftmost leaf of tree?     * <p>     *	 * @return true if the current page is the leftmost leaf of the tree,     *              else return false.     *	 * @exception  StandardException  Standard exception policy.     **/    public abstract boolean isLeftmostLeaf()		throws StandardException;    /**     * Is the current page the rightmost leaf of tree?     * <p>     *	 * @return true if the current page is the rightmost leaf of the tree,     *              else return false.     *	 * @exception  StandardException  Standard exception policy.     **/    public abstract boolean isRightmostLeaf()		throws StandardException;	/**	 ** Perform a recursive search, 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 resultExact field will be true.  Otherwise,	 ** resultExact field will be false, and the row slot returned will be	 ** the one immediately preceding the position at which the key	 ** belongs.    @exception StandardException Standard exception policy.	 **/	public abstract ControlRow search(        SearchParameters    search_params)            throws StandardException;    /**     * Get the number of columns in the control row.       * <p>     * 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.     * <p>     *	 * @return The total number of columns in the control row.     **/    protected abstract int getNumberOfControlRowColumns();	    /**     * Search and return the left most leaf page.     * <p>	 * 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()).     *	 * @return The leftmost leaf page.     *     * @param btree  The open btree to associate latches/locks with.     *	 * @exception  StandardException  Standard exception policy.     **/	protected abstract ControlRow searchLeft(OpenBTree btree)        throws StandardException;    /**     * Search and return the right most leaf page.     * <p>	 * 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()).     *	 * @return The rightmost leaf page.     *     * @param btree  The open btree to associate latches/locks with.     *	 * @exception  StandardException  Standard exception policy.     **/	protected abstract ControlRow searchRight(OpenBTree btree)        throws StandardException;	/**	 **	Perform a recursive shrink operation for th

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -