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

📄 ramtransaction.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	private Conglomerate findConglomerate(long conglomId)		throws StandardException	{		Conglomerate conglom = null;		if (conglomId >= 0)        {            conglom = accessmanager.conglomCacheFind(this, conglomId);        }        else		{			if (tempCongloms != null)				conglom = (Conglomerate) tempCongloms.get(new Long(conglomId));		}        return(conglom);	}	void setContext(RAMTransactionContext rtc)	{		context = rtc;	}	/**		Get cache statistics for the specified cache	*/	public long[] getCacheStats(String cacheName) {		return getRawStoreXact().getCacheStats(cacheName);	}    private ConglomerateController openConglomerate(    Conglomerate                    conglom,    boolean                         hold,    int                             open_mode,    int                             lock_level,    int                             isolation_level,    StaticCompiledOpenConglomInfo   static_info,    DynamicCompiledOpenConglomInfo  dynamic_info)		throws StandardException	{        if (SanityManager.DEBUG)        {            if ((open_mode &                     ~(ContainerHandle.MODE_UNLOGGED                 |                      ContainerHandle.MODE_CREATE_UNLOGGED          |                      ContainerHandle.MODE_FORUPDATE                |                      ContainerHandle.MODE_READONLY	                |                      ContainerHandle.MODE_TRUNCATE_ON_COMMIT       |                      ContainerHandle.MODE_DROP_ON_COMMIT           |                      ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY       |                      ContainerHandle.MODE_LOCK_NOWAIT              |                      ContainerHandle.MODE_TRUNCATE_ON_ROLLBACK     |                      ContainerHandle.MODE_FLUSH_ON_COMMIT          |                      ContainerHandle.MODE_NO_ACTIONS_ON_COMMIT     |                      ContainerHandle.MODE_TEMP_IS_KEPT		        |                      ContainerHandle.MODE_USE_UPDATE_LOCKS	        |                      ContainerHandle.MODE_SECONDARY_LOCKED         |                      ContainerHandle.MODE_BASEROW_INSERT_LOCKED)) != 0)               {                SanityManager.THROWASSERT(                    "Bad open mode to openConglomerate:" +                         Integer.toHexString(open_mode));            }            SanityManager.ASSERT(conglom != null);                        if (lock_level != MODE_RECORD && lock_level != MODE_TABLE)            {                SanityManager.THROWASSERT(                    "Bad lock level to openConglomerate:" + lock_level);            }        }		// Get a conglomerate controller.		ConglomerateController cc =             conglom.open(                this, rawtran, hold, open_mode,                 determine_lock_level(lock_level),                 determine_locking_policy(lock_level, isolation_level),                static_info,                dynamic_info);		// Keep track of it so we can release on close.		conglomerateControllers.addElement(cc);		return cc;    }	private ScanController openScan(    Conglomerate                    conglom,    boolean                         hold,    int                             open_mode,    int                             lock_level,    int                             isolation_level,    FormatableBitSet                         scanColumnList,    DataValueDescriptor[]           startKeyValue,    int                             startSearchOperator,    Qualifier                       qualifier[][],    DataValueDescriptor[]           stopKeyValue,    int                             stopSearchOperator,    StaticCompiledOpenConglomInfo   static_info,    DynamicCompiledOpenConglomInfo  dynamic_info)        throws StandardException	{        if (SanityManager.DEBUG)        {            if ((open_mode &                  ~(TransactionController.OPENMODE_FORUPDATE |                   TransactionController.OPENMODE_USE_UPDATE_LOCKS |                   TransactionController.OPENMODE_FOR_LOCK_ONLY |                   TransactionController.OPENMODE_LOCK_NOWAIT |                   TransactionController.OPENMODE_SECONDARY_LOCKED)) != 0)            {                SanityManager.THROWASSERT(                    "Bad open mode to openScan:" +                    Integer.toHexString(open_mode));            }            if (!((lock_level == MODE_RECORD | lock_level == MODE_TABLE)))            {                SanityManager.THROWASSERT(                    "Bad lock level to openScan:" + lock_level);            }        }		// Get a scan controller.		ScanManager sm =            conglom.openScan(                this, rawtran, hold, open_mode,                determine_lock_level(lock_level),                determine_locking_policy(lock_level, isolation_level),                isolation_level,                scanColumnList,                startKeyValue, startSearchOperator,                qualifier,                stopKeyValue, stopSearchOperator,                static_info,                dynamic_info);		// Keep track of it so we can release on close.		scanControllers.addElement(sm);		return(sm);	}	/**		Reset the cache statistics for the specified cache	*/	public void resetCacheStats(String cacheName) {		getRawStoreXact().resetCacheStats(cacheName);	}    /**     * Invalidate the conglomerate cache, if necessary.  If an alter table     * call has been made then invalidate the cache.     *	 * @exception  StandardException  Standard exception policy.     **/    protected void invalidateConglomerateCache()        throws StandardException    {        if (alterTableCallMade)        {            accessmanager.conglomCacheInvalidate();            alterTableCallMade = false;        }    }    /**************************************************************************     * Public Methods of TransactionController interface:     **************************************************************************     */    /**    Add a column to a conglomerate.  The conglomerate must not be open in	the current transaction.  This also means that there must not be any    active scans on it.    The column can only be added at the spot just after the current set of    columns.    The template_column must be nullable.    After this call has been made, all fetches of this column from rows that    existed in the table prior to this call will return "null".	@param conglomId        The identifier of the conglomerate to drop.	@param column_id        The column number to add this column at.	@param template_column  An instance of the column to be added to table.	@exception StandardException Only some types of conglomerates can support        adding a column, for instance "heap" conglomerates support adding a        column while "btree" conglomerates do not.  If the column can not be        added an exception will be thrown.    **/    public void addColumnToConglomerate(    long        conglomId,    int         column_id,    Storable    template_column)		throws StandardException    {        boolean is_temporary = (conglomId < 0);		Conglomerate conglom = findConglomerate(conglomId);		if (conglom == null)        {			throw StandardException.newException(                SQLState.AM_NO_SUCH_CONGLOMERATE_DROP, new Long(conglomId));        }        // Get exclusive lock on the table being altered.		ConglomerateController cc =            conglom.open(                this, rawtran, false, OPENMODE_FORUPDATE,                MODE_TABLE,                accessmanager.table_level_policy[                    TransactionController.ISOLATION_SERIALIZABLE],                (StaticCompiledOpenConglomInfo) null,                (DynamicCompiledOpenConglomInfo) null);		conglom.addColumn(this, column_id, template_column);        // remove the old entry in the Conglomerate directory, and add the        // new one.		if (is_temporary)		{            // remove old entry in the Conglomerate directory, and add new one			if (tempCongloms != null)				tempCongloms.remove(new Long(conglomId));			tempCongloms.put(new Long(conglomId), conglom);		}		else        {            alterTableCallMade = true;            // have access manager update the conglom to this new one.			accessmanager.conglomCacheUpdateEntry(conglomId, conglom);        }        cc.close();        return;    }    /**     * Return static information about the conglomerate to be included in a     * a compiled plan.     * <p>     * The static info would be valid until any ddl was executed on the     * conglomid, and would be up to the caller to throw away when that     * happened.  This ties in with what language already does for other     * invalidation of static info.  The type of info in this would be     * containerid and array of format id's from which templates can be created.     * The info in this object is read only and can be shared among as many     * threads as necessary.     * <p>     *	 * @return The static compiled information.     *     * @param conglomId The identifier of the conglomerate to open.     *	 * @exception  StandardException  Standard exception policy.     **/    public StaticCompiledOpenConglomInfo getStaticCompiledConglomInfo(    long        conglomId)		throws StandardException    {        return(            findExistingConglomerate(                conglomId).getStaticCompiledConglomInfo(this, conglomId));    }    /**     * Return dynamic information about the conglomerate to be dynamically     * reused in repeated execution of a statement.     * <p>     * The dynamic info is a set of variables to be used in a given     * ScanController or ConglomerateController.  It can only be used in one     * controller at a time.  It is up to the caller to insure the correct     * thread access to this info.  The type of info in this is a scratch     * template for btree traversal, other scratch variables for qualifier     * evaluation, ...     * <p>     *	 * @return The dynamic information.     *     * @param conglomId The identifier of the conglomerate to open.     *	 * @exception  StandardException  Standard exception policy.     **/    public DynamicCompiledOpenConglomInfo getDynamicCompiledConglomInfo(    long        conglomId)		throws StandardException    {        return(            findExistingConglomerate(                conglomId).getDynamicCompiledConglomInfo(conglomId));    }    private final int countCreatedSorts()    {        int ret_val = 0;        if (sorts != null)        {            for (int i = 0; i < sorts.size(); i++)            {                if (sorts.elementAt(i) != null)                    ret_val++;            }        }        return(ret_val);    }    /**     * Report on the number of open conglomerates in the transaction.     * <p>     * There are 4 types of open "conglomerates" that can be tracked, those     * opened by each of the following: openConglomerate(), openScan(),      * openSort(), and openSortScan().  This routine can be used to either     * report on the number of all opens, or may be used to track one      * particular type of open.     *     * This routine is expected to be used for debugging only.  An      * implementation may only track this info under SanityManager.DEBUG mode.     * If the implementation does not track the info it will return -1 (so     * code using this call to verify that no congloms are open should check     * for return <= 0 rather than == 0).     *     * The return value depends on the "which_to_count" parameter as follows:     * OPEN_CONGLOMERATE  - return # of openConglomerate() calls not close()'d.     * OPEN_SCAN          - return # of openScan() calls not close()'d.     * OPEN_CREATED_SORTS - return # of sorts created (createSort()) in      *                      current xact.  There is currently no way to get     *                      rid of these sorts before end of transaction.     * OPEN_SORT          - return # of openSort() calls not close()'d.     * OPEN_TOTAL         - return total # of all above calls not close()'d.     *     - note an implementation may return -1 if it does not track the     *       above information.     *	 * @return The nunber of open's of a type indicated by "which_to_count"     *         parameter.     *     * @param which_to_count Which kind of open to report on.     *	 * @exception  StandardException  Standard exception policy.     **/    public int countOpens(int which_to_count)		throws StandardException	{        int         ret_val = -1;        switch (which_to_count)        {            case OPEN_CONGLOMERATE:                ret_val = conglomerateControllers.size();                break;            case OPEN_SCAN:                ret_val = scanControllers.size();                break;            case OPEN_CREATED_SORTS:                ret_val = countCreatedSorts();                break;            case OPEN_SORT:                ret_val =                     ((sortControllers != null) ? sortControllers.size() : 0);                break;            case OPEN_TOTAL:                ret_val =                     conglomerateControllers.size() + scanControllers.size() +                    ((sortControllers != null) ? sortControllers.size() : 0) +                    countCreatedSorts();                break;        }        return(ret_val);	}    /**     * Create a new conglomerate.     * <p>     * @see TransactionController#createConglomerate     *	 * @exception  StandardException  Standard exception policy.     **/    public long createConglomerate(    String                  implementation,    DataValueDescriptor[]   template,    ColumnOrdering[]        columnOrder,    Properties              properties,    int                     temporaryFlag)		throws StandardException	{		// Find the appropriate factory for the desired implementation.		MethodFactory mfactory;		mfactory = accessmanager.findMethodFactoryByImpl(implementation);		if (mfactory == null || !(mfactory instanceof ConglomerateFactory))        {			throw StandardException.newException(

⌨️ 快捷键说明

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