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

📄 controlrow.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        System.out.println("ControlRow construct 2.");		// The caller is expected to have latched the pages.        if (SanityManager.DEBUG)            SanityManager.ASSERT(page.isLatched());		// Remember the page.		this.page = page;		// The rest of the fields are left null; they'll get faulted		// in if/when necessary.  See the accessors.	}    /* Private/Protected methods of ControlRow: */    /**     * Get version of the control row.     * <p>     * Returns the version of the control row, faulting it in from the page     * if necessary.     *	 * @return version of the control row.     *	 * @exception  StandardException  Standard exception policy.     **/	protected int getVersion()		throws StandardException	{		if (this.version == null)		{			// Fault in the version.			this.version = new StorableFormatId();            scratch_row[CR_VERSION_COLID] = this.version;            fetchDesc.setValidColumns(CR_VERSION_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}		return this.version.getValue();	}    /**     * Set version of the control row.     * <p>     * Sets the version of the control row.  Updates both the in-memory      * control row and the disk copy.     *	 * @exception  StandardException  Standard exception policy.     **/	protected void setVersion(int version)		throws StandardException	{		// Store the field.		if (this.version == null)			this.version = new StorableFormatId();		this.version.setValue(version);		// Write the field through to the underlying row.		this.page.updateFieldAtSlot(            CR_SLOT, CR_VERSION_COLID, this.version, null);	}	/**	 * Get the control row for this page's left sibling, or null if there is no	 * left sibling (which probably means it's the leftmost page at its level).	 * Since right-to-left traversal of an index level	is deadlock-prone, this 	 * method will only get get the left sibling if it can latch it without	 * waiting.     *	 * @exception WaitError if the latch request would have had to wait.     *     * @exception StandardException Standard exception policy.	 **/	public ControlRow getLeftSibling(OpenBTree btree)		throws StandardException, WaitError	{		ControlRow cr;				long pageno = this.getleftSiblingPageNumber();		// Is there a left sibling?		if (pageno == ContainerHandle.INVALID_PAGE_NUMBER)			return null;		// Try to get the control row without waiting		cr = ControlRow.GetNoWait(btree, pageno);		if (cr == null)			throw new WaitError();		return cr;	}	protected void setLeftSibling(ControlRow leftsib)        throws StandardException	{        long left_sib_pageno =             (leftsib == null ? ContainerHandle.INVALID_PAGE_NUMBER :                                leftsib.page.getPageNumber());        		// Store the field.		if (leftSiblingPageNumber == null)			leftSiblingPageNumber = new SQLLongint(left_sib_pageno);        else            this.leftSiblingPageNumber.setValue(left_sib_pageno);		// Write the field through to the underlying row        try        {            this.page.updateFieldAtSlot(                CR_SLOT, CR_LEFTSIB_COLID, this.leftSiblingPageNumber, null);        }        catch (StandardException se)        {            // Since this is an update of a fixed length field it should             // never fail, but it has happened enough that an assert helps            // with debugging.            if (SanityManager.DEBUG)            {                SanityManager.THROWASSERT(                    "setLeftSibling got an exception: " + se +                    "control_row = " + this +                    "trying to update field number " + CR_LEFTSIB_COLID +                     "to new value " + this.leftSiblingPageNumber);            }            throw(se);        }	}	/**	Return the control row for this page's right sibling.  Unlike getting	the left sibling, it's ok to wait for the right sibling latch since	left-to-right is the deadlock-free ordering.    @exception StandardException Standard exception policy.	**/	protected ControlRow getRightSibling(OpenBTree open_btree)		throws StandardException	{		long pageno = this.getrightSiblingPageNumber();		// Return the control row for the page.		if (pageno == ContainerHandle.INVALID_PAGE_NUMBER)			return null;		else			return ControlRow.Get(open_btree, pageno);	}	// This method will have to update the row.	protected void setRightSibling(ControlRow rightsib)        throws StandardException	{        long right_sib_pageno =             (rightsib == null ? ContainerHandle.INVALID_PAGE_NUMBER :                                 rightsib.page.getPageNumber());        		// Store the field.		if (rightSiblingPageNumber == null)			rightSiblingPageNumber = new SQLLongint(right_sib_pageno);        else            this.rightSiblingPageNumber.setValue(right_sib_pageno);		// Write the field through to the underlying row        try        {		this.page.updateFieldAtSlot(            CR_SLOT, CR_RIGHTSIB_COLID, this.rightSiblingPageNumber, null);        }        catch (StandardException se)        {            // Since this is an update of a fixed length field it should             // never fail, but it has happened enough that an assert helps            // with debugging.            if (SanityManager.DEBUG)            {                SanityManager.THROWASSERT(                    "setRightSibling got an exception: " + se +                    "control_row = " + this +                    "trying to update field number " + CR_RIGHTSIB_COLID +                     "to new value " + this.rightSiblingPageNumber);            }            throw(se);        }	}	/**	Get the page number of the left sibling. Fault it's value in if it    hasn't been yet.    @exception StandardException Standard exception policy.	**/	public long getleftSiblingPageNumber()        throws StandardException	{		if (this.leftSiblingPageNumber == null)		{			// Fault in the page number.			this.leftSiblingPageNumber = new SQLLongint();            if (SanityManager.DEBUG)                SanityManager.ASSERT(scratch_row != null);            scratch_row[CR_LEFTSIB_COLID] = this.leftSiblingPageNumber;            fetchDesc.setValidColumns(CR_LEFTSIB_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}        return(leftSiblingPageNumber.getLong());	}	/**	Get the page number of the right sibling. Fault it's value in if it    hasn't been yet.    @exception StandardException Standard exception policy.	**/	protected long getrightSiblingPageNumber()        throws StandardException	{		if (this.rightSiblingPageNumber == null)		{			// Fault in the page number.			this.rightSiblingPageNumber = new SQLLongint();            scratch_row[CR_RIGHTSIB_COLID] = this.rightSiblingPageNumber;            fetchDesc.setValidColumns(CR_RIGHTSIB_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}        return(rightSiblingPageNumber.getLong());	}	/**	Get the page number of the parent, if it's being maintained.	Note that there is intentionally no way to get the control	row for the parent page - the b-tree code NEVER traverses	up the tree, even in consistency checks.    @exception StandardException Standard exception policy.	**/	protected long getParentPageNumber()        throws StandardException	{		if (this.parentPageNumber == null)		{			// Fault in the page number.			this.parentPageNumber = new SQLLongint();            scratch_row[CR_PARENT_COLID] = this.parentPageNumber;            fetchDesc.setValidColumns(CR_PARENT_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}		// See NOTE3 about converting from int to long.		long pageno = parentPageNumber.getLong();		return pageno;	}		void setParent(long parent)        throws StandardException	{		// Store the field.		if (parentPageNumber == null)			parentPageNumber = new SQLLongint();		this.parentPageNumber.setValue(parent);		// Write the field through to the underlying row        try        {            this.page.updateFieldAtSlot(                CR_SLOT, CR_PARENT_COLID, this.parentPageNumber, null);        }        catch (StandardException se)        {            // Since this is an update of a fixed length field it should             // never fail, but it has happened enough that an assert helps            // with debugging.            if (SanityManager.DEBUG)            {                SanityManager.THROWASSERT(                    "setParent got an exception: " + se +                    "control_row = " + this +                    "trying to update field number " + CR_PARENT_COLID +                     "to new value " + this.parentPageNumber);            }            throw(se);        }        return;	}	protected int getLevel()        throws StandardException	{		if (this.level == null)		{			// Fault in the level			this.level = new SQLLongint();            scratch_row[CR_LEVEL_COLID] = this.level;            fetchDesc.setValidColumns(CR_LEVEL_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}		return((int) this.level.getLong());	}	protected void setLevel(int newlevel)        throws StandardException	{		// Store the field.		if (this.level == null)			this.level = new SQLLongint();		this.level.setValue((long) newlevel);		// Write the field through to the underlying row.		this.page.updateFieldAtSlot(CR_SLOT, CR_LEVEL_COLID, this.level, null);	}	protected boolean getIsRoot()        throws StandardException	{		// convert 1 to true, 0 to false;        		if (this.isRoot == null)		{			// Fault in the level			this.isRoot = new SQLLongint();            scratch_row[CR_ISROOT_COLID] = this.isRoot;            fetchDesc.setValidColumns(CR_ISROOT_BITSET);            this.page.fetchFromSlot(               (RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false); 		}		return((this.isRoot.getLong() == 1));	}		protected void setIsRoot(boolean isRoot)        throws StandardException	{        // RESOLVE (mmm) - need to store more efficiently //		// Store the field.		if (this.isRoot == null)			this.isRoot = new SQLLongint();		this.isRoot.setValue((isRoot) ? 1 : 0);		// Write the field through to the underlying row.		this.page.updateFieldAtSlot(            CR_SLOT, CR_ISROOT_COLID, this.isRoot, null);	}    /**     * Get format id information for row on page.     * <p>     * Returns the format id information for a row on the page. faulting it      * in from the page if necessary.     *	 * @return format id of a row on the page.     *	 * @exception  StandardException  Standard exception policy.     **/	public BTree getConglom(int format_id)		throws StandardException	{        if (SanityManager.DEBUG)        {            // this call is only valid on root pages.  If called on non            // root pages it will return a "null" conglom object.            SanityManager.ASSERT(                (this.page.getPageNumber() == BTree.ROOTPAGEID) && getIsRoot());        }

⌨️ 快捷键说明

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