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

📄 btreescan.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            ret_val =                scan_position.current_leaf.page.delete(                    delete_rh, this.btree_undo);            // See if we just deleted the last row on the page, in a btree a            // page with all rows still has 1 left - the control row.  	    // Beetle 5750: we do not reclaim the root page of the btree if             // there are no children since we were    	    // doing too many post commit actions in a benchmark which does an    	    // insert/commit/delete/commit operations in a single user system. now ,    	    // with this change the work will move to the user       	    // thread which does the insert             if (scan_position.current_leaf.page.nonDeletedRecordCount() == 1 &&		!(scan_position.current_leaf.getIsRoot() && 		  scan_position.current_leaf.getLevel() == 0 ))             {                this.getXactMgr().addPostCommitWork(new BTreePostCommit(                    this.getXactMgr().getAccessManager(),                    this.getConglomerate(),                    scan_position.current_leaf.page.getPageNumber()));            }        }        finally        {            if (scan_position.current_leaf != null)            {                // release latch on page                scan_position.current_leaf.release();                scan_position.current_leaf = null;            }        }        return(ret_val);	}    /**     * A call to allow client to indicate that current row does not qualify.     * <p>     * Indicates to the ScanController that the current row does not     * qualify for the scan.  If the isolation level of the scan allows,      * this may result in the scan releasing the lock on this row.     * <p>     * Note that some scan implimentations may not support releasing locks on      * non-qualifying rows, or may delay releasing the lock until sometime     * later in the scan (ie. it may be necessary to keep the lock until      * either the scan is repositioned on the next row or page).     * <p>     * This call should only be made while the scan is positioned on a current     * valid row.     *	 * @exception  StandardException  Standard exception policy.     **/    public void didNotQualify()        throws StandardException    {    }    /**     * Returns true if the current position of the scan still qualifies     * under the set of qualifiers passed to the openScan().  When called     * this routine will reapply all qualifiers against the row currently     * positioned and return true if the row still qualifies.  If the row     * has been deleted or no longer passes the qualifiers then this routine     * will return false.     * <p>     * This case can come about if the current scan     * or another scan on the same table in the same transaction     * deleted the row or changed columns referenced by the qualifier after     * the next() call which positioned the scan at this row.     * <p>     * Note that for comglomerates which don't support update, like btree's,     * there is no need to recheck the qualifiers.     * <p>     * The results of a fetch() performed on a scan positioned on     * a deleted row are undefined.     * <p>	 * @exception StandardException Standard exception policy.    **/    public boolean doesCurrentPositionQualify()		throws StandardException    {        if (scan_state != SCAN_INPROGRESS)            throw StandardException.newException(                SQLState.AM_SCAN_NOT_POSITIONED);        if (SanityManager.DEBUG)        {            SanityManager.ASSERT(this.container != null,            "BTreeScan.doesCurrentPositionQualify() called on a closed scan.");        }        try        {            // Get current page of scan, with latch            if (!reposition(scan_position, false))            {                // TODO - write unit test to get here, language always calls                // isCurrentPositionDeleted() right before calling this, so                // hard to write .sql test to exercise this.                // if reposition fails it means the position of the scan                // has been purged from the table - for example if this is                // a uncommitted read scan and somehow the row was purged                 // since the last positioning.                return(false);            }            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(                    scan_position.current_leaf.page.fetchNumFieldsAtSlot(                        scan_position.current_slot) > 1);            }            // Since btree row don't get updated, the only way a current            // position may not qualify is if it got deleted.            return(                !scan_position.current_leaf.page.isDeletedAtSlot(                    scan_position.current_slot));        }        finally        {            if (scan_position.current_leaf != null)            {                // release latch on page.                scan_position.current_leaf.release();                scan_position.current_leaf = null;            }        }    }    /**    Fetch the row at the current position of the Scan.	@see ScanController#fetch	@exception  StandardException  Standard exception policy.    **/	public void fetch(DataValueDescriptor[] row)		throws StandardException	{        if (scan_state != SCAN_INPROGRESS)            throw StandardException.newException(                SQLState.AM_SCAN_NOT_POSITIONED);        if (SanityManager.DEBUG)        {            SanityManager.ASSERT(this.container != null,                "BTreeScan.fetch() called on a closed scan.");                        TemplateRow.checkPartialColumnTypes(                this.getConglomerate().format_ids,                 init_scanColumnList, (int []) null, row);        }        try        {            // Get current page of scan, with latch            if (!reposition(scan_position, false))            {                // TODO - write unit test to get here, language always calls                // isCurrentPositionDeleted() right before calling this, so                // hard to write .sql test to exercise this.                throw StandardException.newException(                        SQLState.AM_RECORD_NOT_FOUND,                        new Long(err_containerid),                        new Long(scan_position.current_rh.getId()));            }            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(                    scan_position.current_leaf.page.fetchNumFieldsAtSlot(                        scan_position.current_slot) > 1);            }            scan_position.current_rh =                 scan_position.current_leaf.page.fetchFromSlot(                (RecordHandle) null,                 scan_position.current_slot, row, init_fetchDesc,                true);            // The possibility is that the row at the current position            // has been marked as deleted (it cannot have been purged            // since the scan maintains a lock on the row, and purges            // are always done from system transactions).  I'm not sure            // what the desired behavior is in this case.  For now,            // just return null.            // RESOLVE (mikem) - what should be done here?            if (scan_position.current_leaf.page.isDeletedAtSlot(                    scan_position.current_slot))            {                if (SanityManager.DEBUG)                    SanityManager.ASSERT(false, "positioned on deleted row");            }        }        finally        {            if (scan_position.current_leaf != null)            {                // release latch on page.                scan_position.current_leaf.release();                scan_position.current_leaf = null;            }        }		return;	}    /**     * Return ScanInfo object which describes performance of scan.     * <p>     * Return ScanInfo object which contains information about the current     * scan.     * <p>     *     * @see ScanInfo     *	 * @return The ScanInfo object which contains info about current scan.     *	 * @exception  StandardException  Standard exception policy.     **/    public ScanInfo getScanInfo()		throws StandardException    {        return(new BTreeScanInfo(this));    }    /**    Returns true if the current position of the scan is at a    deleted row.  This case can come about if the current scan    or another scan on the same table in the same transaction    deleted the row after the next() call which positioned the    scan at this row.    The results of a fetch() performed on a scan positioned on    a deleted row are undefined.	@exception StandardException Standard exception policy.    **/    public boolean isCurrentPositionDeleted()		throws StandardException    {        boolean     ret_val;        if (scan_state != SCAN_INPROGRESS)            throw StandardException.newException(                SQLState.AM_SCAN_NOT_POSITIONED);        if (SanityManager.DEBUG)        {            SanityManager.ASSERT(this.container != null,                "BTreeScan.isCurrentPositionDeleted() called on closed scan.");        }        try        {            // Get current page of scan, with latch            if (reposition(scan_position, false))            {                if (SanityManager.DEBUG)                {                    SanityManager.ASSERT(                        scan_position.current_leaf.page.fetchNumFieldsAtSlot(                            scan_position.current_slot) > 1);                }                ret_val =                     scan_position.current_leaf.page.isDeletedAtSlot(                        scan_position.current_slot);            }            else            {                ret_val = false;            }        }        finally        {            if (scan_position.current_leaf != null)            {                // release latch on page.                scan_position.current_leaf.release();                scan_position.current_leaf = null;            }        }		return(ret_val);    }    /**     * Return whether this is a keyed conglomerate.     * <p>     *	 * @return whether this is a keyed conglomerate.     **/	public boolean isKeyed()    {        return(true);    }    /**    Move to the next position in the scan.	@see ScanController#next	@exception  StandardException  Standard exception policy.    **/    public boolean next()		throws StandardException	{        // Turn this call into a group fetch of a 1 element group.        fetchNext_one_slot_array[0] = runtime_mem.get_scratch_row();        boolean ret_val =             fetchRows(                scan_position,                fetchNext_one_slot_array,                 (RowLocation[]) null,                (BackingStoreHashtable) null,                1,                (int[]) null) == 1;        return(ret_val);    }    /**    Fetch the row at the next position of the Scan.    If there is a valid next position in the scan then	the value in the template storable row is replaced	with the value of the row at the current scan	position.  The columns of the template row must	be of the same type as the actual columns in the	underlying conglomerate.    The resulting contents of templateRow after a fetchN

⌨️ 快捷键说明

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