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

📄 baseactivation.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	  a cursor, this is used as a string name of the	  result set for messages from things like the	  dependency manager.	  <p>	  Activations that do support cursors will override	  this.		*/	public String getCursorName() {		return isCursorActivation() ? cursorName : null;	}	public void setResultSetHoldability(boolean resultSetHoldability)	{		this.resultSetHoldability = resultSetHoldability;	}	public boolean getResultSetHoldability()	{		return resultSetHoldability;	}	/** @see Activation#setAutoGeneratedKeysResultsetInfo */	public void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes, String[] columnNames)	{		autoGeneratedKeysResultSetMode = true;		autoGeneratedKeysColumnIndexes = columnIndexes;		autoGeneratedKeysColumnNames = columnNames;	}	/** @see Activation#getAutoGeneratedKeysResultsetMode */	public boolean getAutoGeneratedKeysResultsetMode()	{		return autoGeneratedKeysResultSetMode;	}	/** @see Activation#getAutoGeneratedKeysColumnIndexes */	public int[] getAutoGeneratedKeysColumnIndexes()	{		return autoGeneratedKeysColumnIndexes;	}	/** @see Activation#getAutoGeneratedKeysColumnNames */	public String[] getAutoGeneratedKeysColumnNames()	{		return autoGeneratedKeysColumnNames;	}	//	// class implementation	//	/**		Used in the execute method of activations for		generating the result sets that they concatenate together.	 */	public ResultSetFactory getResultSetFactory() {		return rsFactory;	}	/**		Used in activations for generating rows.	 */	public ExecutionFactory getExecutionFactory() {		return exFactory;	}	/**		Used in CurrentOfResultSet to get to the target result set		for a cursor. Overridden by activations generated for		updatable cursors.  Those activations capture the target		result set in a field in their execute() method, and then		return the value of that field in their version of this method.		@return null.	 */	public CursorResultSet getTargetResultSet() {		if (SanityManager.DEBUG)			SanityManager.THROWASSERT("Must be overridden to be used.");		return null;	}	/*	 * Called by generated code to compute the next autoincrement value.	 * 	 * @return The next autoincrement value which should be inserted.	 * returns the correct number datatype.	 */	protected DataValueDescriptor 		getSetAutoincrementValue(int columnPosition, long increment)	       throws StandardException	{		DataValueDescriptor l =			((InsertResultSet)resultSet).getSetAutoincrementValue(columnPosition, increment);		return l;	}	/**		Used in CurrentOfResultSet to get to the cursor result set		for a cursor.  Overridden by activations generated for		updatable cursors.  Those activations capture the cursor		result set in a field in their execute() method, and then		return the value of that field in their version of this method.		@return null	 */	public CursorResultSet getCursorResultSet() {		if (SanityManager.DEBUG)			SanityManager.THROWASSERT("Must be overridden to be used.");		return null;	}	/**		Various activation methods need to disallow their		invocation if the activation is closed. This lets them		check and throw without generating alot of code.		<p>		The code to write to generate the call to this is approximately:		<verbatim>			// jf is a JavaFactory			CallableExpression ce = jf.newMethodCall(				jf.thisExpression(),				BaseActivation.CLASS_NAME,				"throwIfClosed",				"void",				acb.exprArray(jf.newStringLiteral(...some literal here...)));			//mb is a MethodBuilder			mb.addStatement(jf.newStatement(ce));		</verbatim>		The java code to write to call this is:		<verbatim>			this.throwIfClosed(...some literal here...);		</verbatim>		In both cases, "...some literal here..." gets replaced with		an expression of type String that evaluates to the name		of the operation that is being checked, like "execute" or		"reset".		@exception StandardException thrown if closed	 */	public void throwIfClosed(String op) throws StandardException {		if (closed)			throw StandardException.newException(SQLState.LANG_ACTIVATION_CLOSED, op);	}	/**	 * Set a column position in an array of column positions.	 *	 * @param columnPositions	The array of column positions	 * @param positionToSet		The place to put the column position	 * @param column			The column position	 *	 * @return	Nothing	 */	public static void setColumnPosition(							int[] columnPositions,							int positionToSet,							int column)	{		columnPositions[positionToSet] = column;	}	/**	 * Allocate an array of qualifiers and initialize in Qualifier[][]	 *	 * @param qualifiers	The array of Qualifier arrays.	 * @param position		The position in the array to set	 * @param length		The array length of the qualifier array to allocate.	 */	public static void allocateQualArray(    Qualifier[][]   qualifiers,    int             position,    int             length)	{        qualifiers[position] = new Qualifier[length];	}	/**	 * Set a Qualifier in a 2 dimensional array of Qualifiers.     *     * Set a single Qualifier into one slot of a 2 dimensional array of      * Qualifiers.  @see Qualifier for detailed description of layout of     * the 2-d array.	 *	 * @param qualifiers	The array of Qualifiers	 * @param qualifier		The Qualifier	 * @param position_1    The Nth array index into qualifiers[N][M]	 * @param position_1    The Nth array index into qualifiers[N][M]	 */	public static void setQualifier(    Qualifier[][]   qualifiers,    Qualifier	    qualifier,    int			    position_1,    int             position_2)	{		qualifiers[position_1][position_2] = qualifier;	}	/**	 * Reinitialize all Qualifiers in an array of Qualifiers.	 *	 * @param qualifiers	The array of Qualifiers	 */	public static void reinitializeQualifiers(Qualifier[][] qualifiers)	{		if (qualifiers != null)		{            for (int term = 0; term < qualifiers.length; term++)            {                for (int i = 0; i < qualifiers[term].length; i++)                {                    qualifiers[term][i].reinitialize();                }            }		}	}	/**	 * Mark the activation as unused.  	 */	public final void markUnused()	{		inUse = false;	}	/**	 * Is the activation in use?	 *	 * @return true/false	 */	public final boolean isInUse()	{		return inUse;	}	/**	  @see org.apache.derby.iapi.sql.Activation#addWarning	  */	public void addWarning(SQLWarning w)	{		if (warnings == null)			warnings = w;		else			warnings.setNextWarning(w);	}	/**	  @see org.apache.derby.iapi.sql.Activation#getWarnings	  */	public SQLWarning getWarnings()	{		return warnings;	}	/**	  @see org.apache.derby.iapi.sql.Activation#clearWarnings	  */	public void clearWarnings()	{		warnings = null;	}	/**	 * @exception StandardException on error	 */	protected static void nullToPrimitiveTest(DataValueDescriptor dvd, String primitiveType)		throws StandardException	{		if (dvd.isNull())		{			throw StandardException.newException(SQLState.LANG_NULL_TO_PRIMITIVE_PARAMETER, primitiveType);		}	}	/**		@see Activation#informOfRowCount		@exception StandardException	Thrown on error	 */	public void informOfRowCount(NoPutResultSet resultSet, long currentRowCount)					throws StandardException	{		/* Do we want to check the row counts during this execution? */		if (checkRowCounts)		{			boolean significantChange = false;			int resultSetNumber = resultSet.resultSetNumber();			Integer rsn = ReuseFactory.getInteger(resultSetNumber);			/* Check each result set only once per execution */			if (rowCountsCheckedThisExecution.add(rsn))			{				synchronized (getPreparedStatement())				{					Vector rowCountCheckVector = getRowCountCheckVector();					if (rowCountCheckVector == null) {						rowCountCheckVector = new Vector();						setRowCountCheckVector(rowCountCheckVector);					}					Long firstRowCount = null;					/*					** Check whether this resultSet has been seen yet.					*/					if (resultSetNumber < rowCountCheckVector.size())					{						firstRowCount =							(Long) rowCountCheckVector.elementAt(resultSetNumber);					}					else					{						rowCountCheckVector.setSize(resultSetNumber + 1);					}					if (firstRowCount != null)					{						/*						** This ResultSet has been seen - has the row count						** changed significantly?						*/						long n1 = firstRowCount.longValue();						if (currentRowCount != n1)						{							if (n1 >= TEN_PERCENT_THRESHOLD)							{								/*								** For tables with more than								** TEN_PERCENT_THRESHOLD rows, the								** threshold is 10% of the size of the table.								*/								long changeFactor = n1 / (currentRowCount - n1);								if (Math.abs(changeFactor) <= 10)									significantChange = true;							}							else							{								/*								** For tables with less than								** TEN_PERCENT_THRESHOLD rows, the threshold								** is non-linear.  This is because we want								** recompilation to happen sooner for small								** tables that change size.  This formula								** is for a second-order equation (a parabola).								** The derivation is:								**								**   c * n1 = (difference in row counts) ** 2								**				- or - 								**   c * n1 = (currentRowCount - n1) ** 2								**								** Solving this for currentRowCount, we get:								**								**   currentRowCount = n1 + sqrt(c * n1)								**								**				- or -								**								**   difference in row counts = sqrt(c * n1)								**								**				- or -								**								**   (difference in row counts) ** 2 =								**					c * n1								**								** Which means that we should recompile when								** the current row count exceeds n1 (the first								** row count) by sqrt(c * n1), or when the								** square of the difference exceeds c * n1.								** A good value for c seems to be 4.								**								** We don't use this formula when c is greater								** than TEN_PERCENT_THRESHOLD because we never								** want to recompile unless the number of rows								** changes by more than 10%, and this formula								** is more sensitive than that for values of								** n1 greater than TEN_PERCENT_THRESHOLD.								*/								long changediff = currentRowCount - n1;								/*								** Square changediff rather than take the square								** root of (4 * n1), because multiplying is								** faster than taking a square root.  Also,								** check to be sure that squaring changediff								** will not cause an overflow by comparing it								** with the square root of the maximum value								** for a long (this square root is taken only								** once, when the class is loaded, or during								** compilation if the compiler is smart enough).								*/								if (Math.abs(changediff) <= MAX_SQRT)								{									if ((changediff * changediff) >															Math.abs(4 * n1))									{										significantChange = true;									}								}							}						}					}					else					{						firstRowCount = new Long(currentRowCount);						rowCountCheckVector.setElementAt(														firstRowCount,														resultSetNumber														);					}				}			}			/* Invalidate outside of the critical section */			if (significantChange)			{				preStmt.makeInvalid(DependencyManager.INTERNAL_RECOMPILE_REQUEST, lcc);			}		}	}	/**	 * The subclass calls this method when it begins an execution.	 *	 * @exception StandardException		Thrown on error	 */	public void startExecution() throws StandardException	{		// determine if we should check row counts during this execution		shouldWeCheckRowCounts();		// If we are to check row counts, clear the hash table of row counts		// we have checked.		if (checkRowCounts)			rowCountsCheckedThisExecution.clear();	}	/**	 * @see Activation#getHeapConglomerateController	 */	public ConglomerateController getHeapConglomerateController()	{		return updateHeapCC;	}	/**	 * @see Activation#setHeapConglomerateController	 */	public void setHeapConglomerateController(ConglomerateController updateHeapCC)	{		this.updateHeapCC = updateHeapCC;	}	/**	 * @see Activation#clearHeapConglomerateController	 */	public void clearHeapConglomerateController()	{		updateHeapCC = null;	}	/**	 * @see Activation#getIndexScanController	 */	public ScanController getIndexScanController()	{		return indexSC;	}	/**	 * @see Activation#setIndexScanController	 */	public void setIndexScanController(ScanController indexSC)	{		this.indexSC = indexSC;	}	/**	 * @see Activation#getIndexConglomerateNumber	 */	public long getIndexConglomerateNumber()	{		return indexConglomerateNumber;	}	/**	 * @see Activation#setIndexConglomerateNumber	 */	public void setIndexConglomerateNumber(long indexConglomerateNumber)	{		this.indexConglomerateNumber = indexConglomerateNumber;	}	/**	 * @see Activation#clearIndexScanInfo	 */	public void clearIndexScanInfo()	{		indexSC = null;		indexConglomerateNumber = -1;	}	/**	 * @see Activation#setForCreateTable()	 */	public void setForCreateTable()	{		forCreateTable = true;	}	/**	 * @see Activation#getForCreateTable()	 */	public boolean getForCreateTable()	{		return forCreateTable;	}	/**	 * @see Activation#setDDLTableDescriptor	 */	public void setDDLTableDescriptor(TableDescriptor td)	{		ddlTableDescriptor = td;	}	/**	 * @see Activation#getDDLTableDescriptor	 */	public TableDescriptor getDDLTableDescriptor()	{		return ddlTableDescriptor;	}	/**	 * @see Activation#setMaxRows	 */	public void setMaxRows(int maxRows)	{		this.maxRows = maxRows;	}	/**	 * @see Activation#getMaxRows

⌨️ 快捷键说明

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