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

📄 openconglomerate.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        if (pos.current_page != null)        {            try            {                pos.current_slot =                     pos.current_page.getSlotNumber(pos.current_rh);                                return(true);            }            catch (Throwable t)            {                // Assume all errors are caused by the row "disappearing",                // will handle this by returning false indicating that row                // can't be found.  This can easily happen when using read                // uncommitted isolation level.                pos.current_page.unlatch();                pos.current_page = null;            }        }        return(false);    }    /**     * Lock row at given row position for read.     * <p>     * This routine requests a row lock NOWAIT on the row located at the given     * RowPosition.  If the lock is granted NOWAIT the      * routine will return true.  If the lock cannot be granted NOWAIT, then      * the routine will release the latch on "page" and then it will request      * a WAIT lock on the row.       * <p>     * This implementation:     * Assumes latch held on current_page.     * If the current_rh field of RowPosition is non-null it is assumed that     * we want to lock that record handle and that we don't have a slot number.     * If the current_rh field of RowPosition is null, it is assumed the we     * want to lock the indicated current_slot.  Upon return current_rh will     * point to the record handle associated with current_slot.     * <p>     * After waiting and getting the lock on the row, this routine will fix up     * RowPosition to point at the row locked.  This means it will get the     * page latch again, and it will fix the current_slot to point at the      * waited for record handle - it may have moved while waiting on the lock.     *     * @param pos       Position to lock.     * @param aux_pos   If you have to give up latch to get lock, then also      *                  unlock this position if it is non-null.     * @param moveForwardIfRowDisappears     *                  If true, then this routine must handle the case where     *                  the row id we are waiting on disappears when the latch     *                  is released.  If false an exception will be thrown if     *                  the row disappears.     * @param waitForLock     *                  if true wait for lock, if lock can't be granted NOWAIT,     *                  else if false, throw a lock timeout exception if the     *                  lock can't be granted without waiting.     *	 * @return true if lock granted without releasing the latch, else return     *              false.     *	 * @exception  StandardException  Standard exception policy.     **/    public boolean lockPositionForRead(    RowPosition pos,    RowPosition aux_pos,    boolean     moveForwardIfRowDisappears,    boolean     waitForLock)        throws StandardException    {        if (pos.current_rh == null)        {            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(                    pos.current_page != null &&                    pos.current_slot != Page.INVALID_SLOT_NUMBER);            }            // work around for lockmanager problem with lock/latch releasing.            // Get RecordHandle to lock.            pos.current_rh =                 pos.current_page.getRecordHandleAtSlot(pos.current_slot);            if (SanityManager.DEBUG)            {                // make sure current_rh and current_slot are in sync                if (pos.current_slot !=                        pos.current_page.getSlotNumber(pos.current_rh))                {                    SanityManager.THROWASSERT(                        "current_slot = " + pos.current_slot +                        "current_rh = " + pos.current_rh +                        "current_rh.slot = " +                         pos.current_page.getSlotNumber(pos.current_rh));                }            }        }        if (SanityManager.DEBUG)            SanityManager.ASSERT(pos.current_rh != null);        boolean lock_granted_with_latch_held =            this.container.getLockingPolicy().lockRecordForRead(                init_rawtran, container, pos.current_rh,                 false /* NOWAIT */, forUpdate);        if (!lock_granted_with_latch_held)        {            // Could not get the lock NOWAIT, release latch and wait for lock.            pos.current_page.unlatch();            pos.current_page = null;            if (aux_pos != null)            {                aux_pos.current_page.unlatch();                aux_pos.current_page = null;            }            if (!waitForLock)            {                // throw lock timeout error.                throw StandardException.newException(SQLState.LOCK_TIMEOUT);            }            this.container.getLockingPolicy().lockRecordForRead(                init_rawtran, container, pos.current_rh,                 true /* WAIT */, forUpdate);            if (moveForwardIfRowDisappears)            {                if (latchPageAndRepositionScan(pos))                {                    if (pos.current_slot != -1)                    {                        // If scan was repositioned to just before a valid row                        // on the current page, then move forward and lock and                        // return that row (slot != -1).                          //                         // Let the caller handle the "-1"                         // case, which may be one of 3 cases - need to go to                         // slot 1 on current page, need to go to next page,                         // need to end scan as there is no "next" page.  All                        // 3 cases are handled by the generic scan loop in                         // GenericScanController.fetchRows().                        pos.positionAtNextSlot();                        lockPositionForRead(pos, aux_pos, true, true);                    }                }            }            else            {                latchPage(pos);            }        }        return(lock_granted_with_latch_held);    }    public boolean lockPositionForWrite(    RowPosition pos,    boolean     forInsert,    boolean     waitForLock)        throws StandardException    {        if (pos.current_rh == null)        {            if (SanityManager.DEBUG)            {                SanityManager.ASSERT(pos.current_page != null);                SanityManager.ASSERT(                    pos.current_slot != Page.INVALID_SLOT_NUMBER);            }            // work around for lockmanager problem with lock/latch releasing.            // Get RecordHandle to lock.            pos.current_rh =                 pos.current_page.fetchFromSlot(                    null,                     pos.current_slot,                     RowUtil.EMPTY_ROW,                     RowUtil.EMPTY_ROW_FETCH_DESCRIPTOR,                     true);            if (SanityManager.DEBUG)            {                // make sure current_rh and current_slot are in sync                if (pos.current_slot !=                        pos.current_page.getSlotNumber(pos.current_rh))                {                    SanityManager.THROWASSERT(                        "current_slot = " + pos.current_slot +                        "current_rh = " + pos.current_rh +                        "current_rh.slot = " +                         pos.current_page.getSlotNumber(pos.current_rh));                }            }        }        if (SanityManager.DEBUG)            SanityManager.ASSERT(pos.current_rh != null);        boolean lock_granted_with_latch_held =            this.container.getLockingPolicy().                lockRecordForWrite(                    init_rawtran, pos.current_rh,                     forInsert, false /* NOWAIT */);        if (!lock_granted_with_latch_held)        {            if (!waitForLock)            {                // throw lock timeout error.                throw StandardException.newException(SQLState.LOCK_TIMEOUT);            }            // Could not get the lock NOWAIT, release latch and wait for lock.            pos.current_page.unlatch();            pos.current_page = null;            if (!waitForLock)            {                // throw lock timeout error.                throw StandardException.newException(SQLState.LOCK_TIMEOUT);            }            this.container.getLockingPolicy().                lockRecordForWrite(                    init_rawtran, pos.current_rh, forInsert, true /* WAIT */);            latchPage(pos);        }        return(lock_granted_with_latch_held);    }    /**     * Unlock the record after a previous request to lock it.     * <p>     * Unlock the record after a previous call to lockRecordForRead().  It is     * expected that RowPosition contains information used to lock the record,     * Thus it is important if using a single RowPosition to track a scan to     * call unlock before you move the position forward to the next record.     * <p>     * Note that this routine assumes that the row was locked forUpdate if     * the OpenConglomerate is forUpdate, else it assumes the record was     * locked for read.     *	 * @exception  StandardException  Standard exception policy.     **/    public void unlockPositionAfterRead(    RowPosition pos)         throws StandardException    {        if (!isClosed())            container.getLockingPolicy().                unlockRecordAfterRead(                    init_rawtran, container, pos.current_rh, forUpdate,                     pos.current_rh_qualified);    }    /**************************************************************************     * Public Methods implementing ConglomPropertyQueryable Interface:      **************************************************************************     */    /**     * Request set of properties associated with a table.      * <p>     * Returns a property object containing all properties that the store     * knows about, which are stored persistently by the store.  This set     * of properties may vary from implementation to implementation of the     * store.     * <p>     * This call is meant to be used only for internal query of the properties     * by jbms, for instance by language during bulk insert so that it can     * create a new conglomerate which exactly matches the properties that     * the original container was created with.  This call should not be used     * by the user interface to present properties to users as it may contain     * properties that are meant to be internal to jbms.  Some properties are      * meant only to be specified by jbms code and not by users on the command     * line.     * <p>     * Note that not all properties passed into createConglomerate() are stored     * persistently, and that set may vary by store implementation.     *     * @param prop   Property list to add properties to.  If null, routine will     *               create a new Properties object, fill it in and return it.     *	 * @exception  StandardException  Standard exception policy.     **/    public Properties getInternalTablePropertySet(Properties prop)		throws StandardException    {        Properties  ret_properties =             ConglomerateUtil.createRawStorePropertySet(prop);

⌨️ 快捷键说明

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