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

📄 btreeforwardscan.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*   Derby - Class org.apache.derby.impl.store.access.btree.BTreeForwardScan   Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License. */package org.apache.derby.impl.store.access.btree;import org.apache.derby.iapi.reference.SQLState;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.io.Storable;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.store.access.conglomerate.Conglomerate;import org.apache.derby.iapi.store.access.conglomerate.LogicalUndo;import org.apache.derby.iapi.store.access.conglomerate.ScanManager;import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo;import org.apache.derby.iapi.store.access.Qualifier;import org.apache.derby.iapi.store.access.RowUtil;import org.apache.derby.iapi.store.access.ScanController;import org.apache.derby.iapi.store.access.ScanInfo;import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;import org.apache.derby.iapi.store.access.TransactionController;import org.apache.derby.iapi.store.raw.ContainerHandle;import org.apache.derby.iapi.store.raw.LockingPolicy;import org.apache.derby.iapi.store.raw.Page;import org.apache.derby.iapi.store.raw.RecordHandle;import org.apache.derby.iapi.store.raw.Transaction;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.impl.store.access.conglomerate.ConglomerateUtil;import org.apache.derby.impl.store.access.conglomerate.TemplateRow;import org.apache.derby.iapi.services.io.FormatableBitSet;import org.apache.derby.iapi.store.access.BackingStoreHashtable;/**  A b-tree scan controller corresponds to an instance of an open b-tree scan.  <P>  <B>Concurrency Notes<\B>  <P>  The concurrency rules are derived from OpenBTree.  <P>  @see OpenBTree**/public class BTreeForwardScan extends BTreeScan{	/*	** Private/Protected methods of This class, sorted alphabetically	*/	/**	Position scan at "start" position.	<p>    Positions the scan to the slot just before the first record to be returned    from the scan.  Returns the start page latched, and sets "current_slot" to    the slot number.	@exception  StandardException  Standard exception policy.	**/    protected void positionAtStartPosition(    BTreeRowPosition    pos)        throws StandardException	{        positionAtStartForForwardScan(pos);	}	///////////////////////////////////////////////	// 	// RESOLVE (jamie): i had to add these simple	// super.init() super.close() calls to get mssdk302	// to work.  I could not determine what the problem	// is.  For the time being, please don't remove	// them even though they don't appear to serve a	// useful purpose.	// 	///////////////////////////////////////////////		/**	Initialize the scan for use.	<p>	Any changes to this method may have to be reflected in close as well.    <p>    The btree init opens the container (super.init), and stores away the    state of the qualifiers.  The actual searching for the first position    is delayed until the first next() call.	@exception  StandardException  Standard exception policy.	**/	public void init(    TransactionManager              xact_manager,    Transaction                     rawtran,    boolean                         hold,    int                             open_mode,    int                             lock_level,    BTreeLockingPolicy              btree_locking_policy,    FormatableBitSet                         scanColumnList,    DataValueDescriptor[]	        startKeyValue,    int                             startSearchOperator,    Qualifier                       qualifier[][],    DataValueDescriptor[]	        stopKeyValue,    int                             stopSearchOperator,    BTree                           conglomerate,    LogicalUndo                     undo,    StaticCompiledOpenConglomInfo   static_info,    DynamicCompiledOpenConglomInfo  dynamic_info)        throws StandardException	{		super.init(            xact_manager, rawtran, hold, open_mode, lock_level,            btree_locking_policy, scanColumnList, startKeyValue,            startSearchOperator, qualifier, stopKeyValue,			stopSearchOperator, conglomerate, undo, static_info, dynamic_info);	}    /**    Close the scan.    **/    public void close()        throws StandardException	{		super.close();	}    /**     * Fetch the next N rows from the table.     * <p>     * Utility routine used by both fetchSet() and fetchNextGroup().     *	 * @exception  StandardException  Standard exception policy.     **/    protected int fetchRows(    BTreeRowPosition        pos,    DataValueDescriptor[][] row_array,    RowLocation[]           rowloc_array,    BackingStoreHashtable   hash_table,    long                    max_rowcnt,    int[]                   key_column_numbers)        throws StandardException	{        int                     ret_row_count     = 0;        DataValueDescriptor[]   fetch_row         = null;        RecordHandle            rh;        if (max_rowcnt == -1)            max_rowcnt = Long.MAX_VALUE;        if (this.scan_state == BTreeScan.SCAN_INPROGRESS)        {            // reposition the scan at the row just before the next one to             // return.            // This routine handles the mess of repositioning if the row or             // the page has disappeared. This can happen if a lock was not             // held on the row while not holding the latch (can happen if            // this scan is read uncommitted).            //            // code path tested by readUncommitted.sql:TEST 1            //            if (!reposition(pos, true))            {                if (SanityManager.DEBUG)                {                    SanityManager.THROWASSERT(                        "can not fail with 2nd param true.");                }            }        }        else if (this.scan_state == SCAN_INIT)        {            // 1st positioning of scan (delayed from openScan).            positionAtStartPosition(pos);        }        else if (this.scan_state == SCAN_HOLD_INPROGRESS)        {            reopen();            this.scan_state = SCAN_INPROGRESS;            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(scan_position.current_positionKey != null);            }            // reposition the scan at the row just before the next one to             // return.            // This routine handles the mess of repositioning if the row or             // the page has disappeared. This can happen if a lock was not             // held on the row while not holding the latch.            //            // code path tested by holdCursor.sql: TEST 9            if (!reposition(pos, true))            {                if (SanityManager.DEBUG)                {                    SanityManager.THROWASSERT(                        "can not fail with 2nd param true.");                }            }        }        else if (this.scan_state == SCAN_HOLD_INIT)        {            reopen();            positionAtStartForForwardScan(scan_position);        }        else        {            if (SanityManager.DEBUG)                SanityManager.ASSERT(this.scan_state == SCAN_DONE);            return(0);        }		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(                init_template != null, "init_template is null");		}        if (SanityManager.DEBUG)        {            SanityManager.ASSERT(this.container != null,                "BTreeScan.next() called on a closed scan.");            if (row_array != null)                SanityManager.ASSERT(row_array[0] != null,                    "first array slot in fetchNextGroup() must be non-null.");            // Btree's don't support RowLocations yet.            if (rowloc_array != null)            {                throw StandardException.newException(                        SQLState.BTREE_UNIMPLEMENTED_FEATURE);            }        }        // System.out.println("top of fetchRows, fetch_row = " + fetch_row);        // At this point:        // current_page is latched.  current_slot is the slot on current_page        // just before the "next" record this routine should process.        // loop through successive leaf pages and successive slots on those        // leaf pages.  Stop when either the last leaf is reached (current_page        // will be null), or when stopKeyValue is reached/passed.  Along the        // way apply qualifiers to skip rows which don't qualify.		while (pos.current_leaf != null)		{            // System.out.println(              //   "1 of fetchSet loop, ret_row_count = " + ret_row_count +                // "fetch_row = " + fetch_row);

⌨️ 快捷键说明

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