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

📄 openbtree.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *                        done on this open btree.     *     *	 * @exception  StandardException  Standard exception policy.     **/	public void init(    TransactionManager              open_user_scans,    TransactionManager              xact_manager,    ContainerHandle                 input_container,    Transaction                     rawtran,    boolean                         hold,	int                             open_mode,    int                             lock_level,    BTreeLockingPolicy              btree_locking_policy,    BTree                           conglomerate,    LogicalUndo                     undo,    DynamicCompiledOpenConglomInfo  dynamic_info)        throws StandardException	{		// If the b-tree is already open, close it.		if (this.container != null)        {            if (SanityManager.DEBUG)                SanityManager.ASSERT(false, "why is the container open?");			close();        }        err_containerid = conglomerate.id.getContainerId();        // Locking policy to pass back to concrete implementation lock calls        this.init_btree_locking_policy = btree_locking_policy;		// if the conglomerate is temporary, open with IS_KEPT set.		// RESOLVE(mikem): track 1825		// don't want to open temp cantainer with IS_KEPT always.		if (conglomerate.isTemporary())			open_mode |= ContainerHandle.MODE_TEMP_IS_KEPT;        // now open the container if it wasn't already opened by the client.        // No locks will be requested by raw store on this open.        if (input_container == null)        {            // Open the container.             this.container =                 rawtran.openContainer(                    conglomerate.id,                     (LockingPolicy) null /* get no locks on btree */,					open_mode);        }        else        {            // Use the open container passed in.            this.container = input_container;			// RESOLVE (sku) - ContainerHandle should have an interface to			// verify that it is opened with open_mode        }		if (this.container == null)        {            throw StandardException.newException(                    SQLState.BTREE_CONTAINER_NOT_FOUND,                    new Long(err_containerid));        }		// Remember the conglomerate so its properties can be found.        init_conglomerate   = conglomerate;        // Remember the transaction manager so commit() can be called        init_xact_manager   = xact_manager;        init_rawtran        = rawtran;        init_openmode       = open_mode;        // Isolation level of this btree.        init_lock_level     = lock_level;        init_dynamic_info   = dynamic_info;        init_hold           = hold;        // Remember the transaction manager so saveScanPositions() can be called        this.init_open_user_scans = open_user_scans;        // Logical undo class to pass to raw store, on inserts/deletes.        this.btree_undo = undo;        // either use passed in "compiled" runtime scratch space, or create        // new space.        this.runtime_mem    =             (dynamic_info != null ?              ((OpenConglomerateScratchSpace) dynamic_info) :              new OpenConglomerateScratchSpace(conglomerate.format_ids));	}    /**     * Open the container after it has been closed previously.     * <p>     * Open the container, obtaining necessary locks.  Most work is actually     * done by RawStore.openContainer().  Will only reopen() if the container     * is not already open.     *	 * @exception  StandardException  Standard exception policy.     **/    public ContainerHandle reopen()        throws StandardException    {        // reget transaction from context manager, in the case of XA        // transaction this may have changed.        //        /* TODO - XA transactions my change the current transaction on the          * context stack.  Will want to something like:         *         * init_rawtran = context_manager.getcurrenttransaction()         */		// If the b-tree is already open, close it.        /*		if (this.container != null)        {			close();        }        */        if (SanityManager.DEBUG)        {            SanityManager.ASSERT(init_xact_manager != null);            SanityManager.ASSERT(init_xact_manager.getRawStoreXact() != null);            SanityManager.ASSERT(init_conglomerate != null);        }             if (container == null)        {            // Open the container.             this.container =                 init_xact_manager.getRawStoreXact().openContainer(                    init_conglomerate.id,                     (LockingPolicy) null /* get no locks on btree */,                    init_openmode);        }        return(this.container);    }    /**    Close the open conglomerate.    **/    public void close()        throws StandardException	{		if (container != null)			container.close();		container = null;	}    /**    Check if all the     columns are Indexable and Storable.  Eventually this routine could    check whether all the types were right also.    @exception StandardException Standard Exception Policy.    **/    void isIndexableRowConsistent(DataValueDescriptor[] row)        throws StandardException    {        if (SanityManager.DEBUG)        {            DataValueDescriptor[] template =                 this.init_conglomerate.createTemplate();            // RESOLVE - could just compare format id's rather than allocate            // objects.            for (int i = 0; i < row.length; i++)            {                // RESOLVE (mikem) - use format id's for more efficient test.				if (!row[i].getClass().equals(template[i].getClass()))                {                    SanityManager.THROWASSERT(                        "type of inserted column[" + i + "] = " +                         row[i].getClass().getName()                +                        "type of template column[" + i + "] = " +                        template[i].getClass().getName());                }            }        }    }    /**     * Return the container handle.     * <p>	 * @return The open container handle of the btree.     **/    public ContainerHandle getContainerHandle()    {        return(container);    }		/**     * get height of the tree.     * <p>     * Read in root and return the height (number of levels) of the tree.     * The level of a tree is 0 in the leaf and increases by 1 for each     * level of the tree as you go up the tree.       *	 * @exception  StandardException  Standard exception policy.     **/    public int getHeight()		throws StandardException    {		// container.checkConsistency();		ControlRow root = null;        try        {            root = ControlRow.Get(this, BTree.ROOTPAGEID);            int height = root.getLevel() + 1;            return(height);        }        finally        {            if (root != null)                root.release();        }    }    public RecordHandle makeRecordHandle(    long    page_number,    int     rec_id)        throws StandardException    {        return(            container.makeRecordHandle(                page_number, rec_id));    }    /**     * Dump information about tree into the log.     * <p>     * Traverse the tree dumping info about tree into the log.     *	 * @exception  StandardException  Standard exception policy.     **/    public void debugConglomerate()		throws StandardException    {		// container.checkConsistency();		ControlRow root = null;        try        {            if (SanityManager.DEBUG)            {                SanityManager.DEBUG_PRINT(                    "p_tree", "BTREE Dump: containerId " + container.getId());                SanityManager.DEBUG_PRINT(                    "p_tree", "BTREE Dump: btree " + this.init_conglomerate);            }            root = ControlRow.Get(this, BTree.ROOTPAGEID);            root.printTree(this);        }        finally        {            if (root != null)                root.release();        }    }    /**     * Testing infrastructure to cause unusual paths through the code.     * <p>     * Through the use of debug flags allow test code to cause otherwise     * hard to cause paths through the code.       * <p>     *	 * @return whether the latch has been released by this routine.     *	 * @exception  StandardException  Standard exception policy.     **/    public static boolean test_errors(    OpenBTree           open_btree,    String              debug_string,    boolean             release_scan_lock,    BTreeLockingPolicy  btree_locking_policy,    LeafControlRow      leaf,    boolean             input_latch_released)        throws StandardException    {        boolean latch_released = input_latch_released;        // special test to see if latch release code works        if (SanityManager.DEBUG)        {            String debug_lost_latch = debug_string + "1";            if (SanityManager.DEBUG_ON(debug_lost_latch))            {                // Simulate a lost latch because of a wait for a lock.                if (!latch_released)                {                    if (release_scan_lock)                    {                        btree_locking_policy.unlockScan(                            leaf.page.getPageNumber());                    }                    leaf.release();                    latch_released = true;                    SanityManager.DEBUG_PRINT(                        debug_lost_latch, debug_lost_latch);                    SanityManager.DEBUG_CLEAR(debug_lost_latch);                }            }            String debug_deadlock = debug_string + "2";            if (SanityManager.DEBUG_ON(debug_deadlock))            {                SanityManager.DEBUG_PRINT(debug_deadlock, debug_deadlock);                SanityManager.DEBUG_CLEAR(debug_deadlock);                // Simulate a deadlock error.                StandardException se =                     StandardException.newException(                        SQLState.DEADLOCK, "fake deadlock", "fake victim");				se.setReport(StandardException.REPORT_ALWAYS);				throw se;            }        }        return(latch_released);    }    public SpaceInfo getSpaceInfo()        throws StandardException    {        return container.getSpaceInfo();    }	// return column Sort order information	public boolean[] getColumnSortOrderInfo()		throws	StandardException	{		return init_conglomerate.ascDescInfo;	}}

⌨️ 快捷键说明

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