db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1420579 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/execute/ impl/sql/compile/ impl/sql/execute/
Date Wed, 12 Dec 2012 09:14:53 GMT
Author: kahatlen
Date: Wed Dec 12 09:14:44 2012
New Revision: 1420579

URL: http://svn.apache.org/viewvc?rev=1420579&view=rev
Log:
DERBY-6003: Create row templates outside of the generated code

Make SortResultSet, VTIResultSet, aggregates and WindowResultSet use an
ExecRowBuilder instead of a generated method to allocate row templates.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
Wed Dec 12 09:14:44 2012
@@ -382,7 +382,7 @@ public interface ResultSetFactory {
 		@param distinct true if distinct SELECT list
 		@param isInSortedOrder	true if the source result set is in sorted order
 		@param orderItem entry in preparedStatement's savedObjects for order
-		@param rowAllocator a reference to a method in the activation
+		@param rowAllocator a reference to a saved object
 			that generates rows of the right size and shape for the source
 		@param rowSize the size of the row that is allocated by rowAllocator.
 			size should be the maximum size of the sum of all the datatypes.
@@ -399,7 +399,7 @@ public interface ResultSetFactory {
 		boolean distinct, 
 		boolean isInSortedOrder,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int rowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -415,7 +415,7 @@ public interface ResultSetFactory {
 		@param isInSortedOrder	true if the source result set is in sorted order
 		@param aggregateItem entry in preparedStatement's savedObjects for aggregates
 		@param orderingItem		Ignored to allow same signature as getDistinctScalarAggregateResultSet
-		@param rowAllocator a reference to a method in the activation
+		@param rowAllocator     a reference to a saved object
 			that generates rows of the right size and shape for the source
 		@param rowSize			Ignored to allow same signature as getDistinctScalarAggregateResultSet
 		@param resultSetNumber	The resultSetNumber for the ResultSet
@@ -431,7 +431,7 @@ public interface ResultSetFactory {
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderingItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int rowSize,
 		int resultSetNumber, 
 		boolean singleInputRow,
@@ -449,7 +449,7 @@ public interface ResultSetFactory {
 		@param isInSortedOrder	true if the source result set is in sorted order
 		@param aggregateItem entry in preparedStatement's savedObjects for aggregates
 		@param orderingItem entry in preparedStatement's savedObjects for order
-		@param rowAllocator a reference to a method in the activation
+		@param rowAllocator a reference to a saved object
 			that generates rows of the right size and shape for the source
 		@param rowSize the size of the row that is allocated by rowAllocator.
 			size should be the maximum size of the sum of all the datatypes.
@@ -467,7 +467,7 @@ public interface ResultSetFactory {
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderingItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int rowSize,
 		int resultSetNumber, 
 		boolean singleInputRow,
@@ -484,7 +484,7 @@ public interface ResultSetFactory {
 		@param isInSortedOrder	true if the source result set is in sorted order
 		@param aggregateItem entry in preparedStatement's savedObjects for aggregates
 		@param orderingItem		Ignored to allow same signature as getDistinctScalarAggregateResultSet
-		@param rowAllocator a reference to a method in the activation
+		@param rowAllocator     a reference to a saved object
 			that generates rows of the right size and shape for the source
 		@param rowSize			Ignored to allow same signature as getDistinctScalarAggregateResultSet
 		@param resultSetNumber	The resultSetNumber for the ResultSet
@@ -500,7 +500,7 @@ public interface ResultSetFactory {
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderingItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int rowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -518,7 +518,7 @@ public interface ResultSetFactory {
 		@param isInSortedOrder	true if the source result set is in sorted order
 		@param aggregateItem entry in preparedStatement's savedObjects for aggregates
 		@param orderingItem entry in preparedStatement's savedObjects for order
-		@param rowAllocator a reference to a method in the activation
+		@param rowAllocator a reference to a saved object
 			that generates rows of the right size and shape for the source
 		@param rowSize the size of the row that is allocated by rowAllocator.
 			size should be the maximum size of the sum of all the datatypes.
@@ -536,7 +536,7 @@ public interface ResultSetFactory {
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderingItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int rowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -640,11 +640,8 @@ public interface ResultSetFactory {
 		@param activation the activation for this result set,
 			against which the row operation is performed to
 			create the result set.
-		@param row a reference to a method in the activation
+		@param row a reference to a saved object
 			that creates the expected row.
-			<verbatim>
-				ExecRow row() throws StandardException;
-			</verbatim>
 		@param resultSetNumber	The resultSetNumber for the ResultSet
 		@param constructor		The GeneratedMethod for the user's constructor
 		@param javaClassName	The java class name for the VTI
@@ -661,7 +658,7 @@ public interface ResultSetFactory {
 		@exception StandardException thrown when unable to create the
 			result set
 	 */
-	public NoPutResultSet getVTIResultSet(Activation activation, GeneratedMethod row,
+	public NoPutResultSet getVTIResultSet(Activation activation, int row,
 									 int resultSetNumber,
 									 GeneratedMethod constructor,
 									 String javaClassName,
@@ -1101,7 +1098,7 @@ public interface ResultSetFactory {
 	   <p>
 	   @param activation   Activation
 	   @param source       The result set input to this result set.
-	   @param rowAllocator A reference to a method in the activation
+	   @param rowAllocator A reference to a saved object
 			               that generates rows of the right size and
 						   shape for the source.
 	   @param resultSetNumber The resultSetNumber for the ResultSet
@@ -1118,7 +1115,7 @@ public interface ResultSetFactory {
 	public NoPutResultSet getWindowResultSet(
 								Activation activation,
 								NoPutResultSet source,
-								GeneratedMethod rowAllocator,
+								int rowAllocator,
 								int resultSetNumber,
 								int erdNumber,
 								GeneratedMethod restriction,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DistinctNode.java Wed
Dec 12 09:14:44 2012
@@ -313,7 +313,7 @@ public class DistinctNode extends Single
 		mb.push(true);
 		mb.push(inSortedOrder);
 		mb.push(orderItem);
-		resultColumns.generateHolder(acb, mb);
+        mb.push(acb.addItem(resultColumns.buildRowTemplate(null)));
 		mb.push(resultColumns.getTotalColumnSize());
 		mb.push(resultSetNumber);
 		mb.push(costEstimate.rowCount());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java Wed Dec
12 09:14:44 2012
@@ -1661,8 +1661,8 @@ public class FromVTI extends FromTable i
 
 		acb.pushThisAsActivation(mb); // arg 1
 
-        // get a function to allocate scan rows of the right shape and size
-		resultColumns.generateHolder(acb, mb); // arg 2
+        // Get a row builder to allocate scan rows of the right shape and size.
+        mb.push(acb.addItem(resultColumns.buildRowTemplate(null))); // arg 2
 
 		// For a Version 2 VTI we never maintain the java.sql.PreparedStatement
 		// from compile time to execute time. This would rquire the PreparedStatement

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java Wed
Dec 12 09:14:44 2012
@@ -1088,7 +1088,7 @@ public class GroupByNode extends SingleC
 		mb.push(aggInfoItem);
 		mb.push(orderingItem);
 
-		resultColumns.generateHolder(acb, mb);
+        mb.push(acb.addItem(resultColumns.buildRowTemplate(null)));
 
 		mb.push(resultColumns.getTotalColumnSize());
 		mb.push(resultSetNumber);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java Wed
Dec 12 09:14:44 2012
@@ -398,7 +398,7 @@ public class OrderByList extends Ordered
 		mb.push(orderItem);
 
 		// row allocator
-		child.getResultColumns().generateHolder(acb, mb);
+        mb.push(acb.addItem(child.getResultColumns().buildRowTemplate(null)));
 
 		mb.push(child.getResultColumns().getTotalColumnSize());
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Wed Dec 12 09:14:44 2012
@@ -1561,25 +1561,6 @@ public class ResultColumnList extends Qu
 		@exception StandardException
 	 */
 	void generateHolder(ExpressionClassBuilder acb,
-								MethodBuilder mb)
-							throws StandardException 
-	{
-		generateHolder(acb, mb, (FormatableBitSet) null, (FormatableBitSet) null);
-	}
-
-	/**
-		Generates a row with the size and shape of the ResultColumnList.
-
-		Some structures, like FromBaseTable and DistinctNode,
-		need to generate rowAllocator functions to get a row
-		the size and shape of their ResultColumnList.  
-
-		We return the method pointer, which is a field access
-		in the generated class.
-
-		@exception StandardException
-	 */
-	void generateHolder(ExpressionClassBuilder acb,
 								MethodBuilder mb,
 								FormatableBitSet referencedCols,
 								FormatableBitSet propagatedCols)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
Wed Dec 12 09:14:44 2012
@@ -410,7 +410,7 @@ public class WindowResultSetNode extends
         mb.upCast(ClassName.NoPutResultSet);
 
         /* row allocator */
-        resultColumns.generateHolder(acb, mb); // arg 3
+        mb.push(acb.addItem(resultColumns.buildRowTemplate(null))); // arg 3
 
         mb.push(resultSetNumber); //arg 4
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctGroupedAggregateResultSet.java
Wed Dec 12 09:14:44 2012
@@ -52,8 +52,7 @@ class DistinctGroupedAggregateResultSet 
 	 *		SavedObject off of the PreparedStatement that holds the
 	 *		ColumOrdering array used by this routine
 	 * @param	a				activation
-	 * @param	ra				generated method to build an empty
-	 *	 	output row 
+	 * @param	ra				saved object that builds an empty output row
 	 * @param	maxRowSize		approx row size, passed to sorter
 	 * @param	resultSetNumber	The resultSetNumber for this result set
 	 *
@@ -64,7 +63,7 @@ class DistinctGroupedAggregateResultSet 
 					int	aggregateItem,
 					int	orderingItem,
 					Activation a,
-					GeneratedMethod ra,
+					int ra,
 					int maxRowSize,
 					int resultSetNumber,
 					double optimizerEstimatedRowCount,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DistinctScalarAggregateResultSet.java
Wed Dec 12 09:14:44 2012
@@ -35,9 +35,6 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.store.access.SortController;
 import org.apache.derby.iapi.store.access.ScanController;
 
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
-
-
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.services.io.FormatableArrayHolder;
@@ -77,8 +74,7 @@ class DistinctScalarAggregateResultSet e
 	 *		SavedObject off of the PreparedStatement that holds the
 	 *		AggregatorInfoList used by this routine. 
 	 * @param	a				activation
-	 * @param	ra				generated method to build an empty
-	 *	 	output row 
+	 * @param	ra				saved object that builds an empty output row
 	 * @param	resultSetNumber	The resultSetNumber for this result set
 	 *
 	 * @exception StandardException Thrown on error
@@ -88,7 +84,7 @@ class DistinctScalarAggregateResultSet e
 					int	aggregateItem,
 					int	orderingItem,
 					Activation a,
-					GeneratedMethod ra,
+					int ra,
 					int maxRowSize,
 					int resultSetNumber,
 					boolean singleInputRow,
@@ -133,8 +129,8 @@ class DistinctScalarAggregateResultSet e
 		if (SanityManager.DEBUG)
 	    	SanityManager.ASSERT( ! isOpen, "DistinctScalarResultSet already open");
 
-		sortResultRow = getExecutionFactory().getIndexableRow(sortTemplateRow.getClone());
-		sourceExecIndexRow = getExecutionFactory().getIndexableRow(sortTemplateRow.getClone());
+        sortResultRow = (ExecIndexRow) getRowTemplate().getClone();
+        sourceExecIndexRow = (ExecIndexRow) getRowTemplate().getClone();
 
         source.openCore();
 
@@ -353,6 +349,7 @@ class DistinctScalarAggregateResultSet e
 	{
 		SortController 			sorter;
 		ExecRow 				sourceRow;
+        ExecIndexRow            sortTemplateRow = getRowTemplate();
 		int						inputRowCountEstimate = (int) optimizerEstimatedRowCount;
 
 		TransactionController tc = getTransactionController();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericAggregateResultSet.java
Wed Dec 12 09:14:44 2012
@@ -27,11 +27,13 @@ import org.apache.derby.iapi.error.SQLWa
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.loader.ClassFactory;
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
 import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.execute.ExecIndexRow;
+import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
 import org.apache.derby.iapi.sql.execute.ExecRow;
+import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
+import org.apache.derby.iapi.sql.execute.ExecutionFactory;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 
 /**
@@ -41,16 +43,16 @@ import org.apache.derby.iapi.sql.execute
 abstract class GenericAggregateResultSet extends NoPutResultSetImpl
 {
 	protected GenericAggregator[]		aggregates;	
-	protected GeneratedMethod			rowAllocator;
 	protected AggregatorInfoList	aggInfoList;	
 	public NoPutResultSet source;
 	protected	NoPutResultSet	originalSource; // used for run time stats only
+    private final ExecIndexRow rowTemplate;
 
 	/**
 	 * Constructor
 	 *
 	 * @param a activation
-	 * @param ra row allocator generated method
+	 * @param ra reference to a saved row allocator instance
 	 * @param resultSetNumber result set number
 	 * @param optimizerEstimatedRowCount optimizer estimated row count
 	 * @param optimizerEstimatedCost optimizer estimated cost
@@ -62,7 +64,7 @@ abstract class GenericAggregateResultSet
 		NoPutResultSet s,
 		int	aggregateItem,
 		Activation 	a,
-		GeneratedMethod	ra,
+		int ra,
 		int 			resultSetNumber,
 		double 			optimizerEstimatedRowCount,
 		double 			optimizerEstimatedCost
@@ -73,14 +75,28 @@ abstract class GenericAggregateResultSet
 		source = s;
 		originalSource = s;
 
+        ExecPreparedStatement ps = a.getPreparedStatement();
+        ExecutionFactory ef = a.getExecutionFactory();
 
-		rowAllocator = ra;
+        rowTemplate = ef.getIndexableRow(
+                ((ExecRowBuilder) ps.getSavedObject(ra)).build(ef));
 
-		aggInfoList = (AggregatorInfoList) (a.getPreparedStatement().getSavedObject(aggregateItem));
+		aggInfoList = (AggregatorInfoList) ps.getSavedObject(aggregateItem);
 		aggregates = getSortAggregators(aggInfoList, false, 
 				a.getLanguageConnectionContext(), s);
 	}
 
+    /**
+     * Get a template row of the right shape for sorting or returning results.
+     * The template is cached, so it may need to be cloned if callers use it
+     * for multiple purposes at the same time.
+     *
+     * @return a row template of the right shape for this result set
+     */
+    ExecIndexRow getRowTemplate() {
+        return rowTemplate;
+    }
+
 	/**
 	 * For each AggregatorInfo in the list, generate a
 	 * GenericAggregator and stick it in an array of
@@ -160,7 +176,7 @@ abstract class GenericAggregateResultSet
 		*/ 
 		if (row == null)
 		{
-			row = getExecutionFactory().getIndexableRow((ExecRow) rowAllocator.invoke(activation));
+			row = getRowTemplate();
 		}
 
 		setCurrentRow(row);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
Wed Dec 12 09:14:44 2012
@@ -270,7 +270,7 @@ public class GenericResultSetFactory imp
 		boolean distinct, 
 		boolean isInSortedOrder,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int maxRowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -297,7 +297,7 @@ public class GenericResultSetFactory imp
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int maxRowSize,
 		int resultSetNumber, 
 		boolean singleInputRow,
@@ -320,7 +320,7 @@ public class GenericResultSetFactory imp
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int maxRowSize,
 		int resultSetNumber, 
 		boolean singleInputRow,
@@ -343,7 +343,7 @@ public class GenericResultSetFactory imp
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int maxRowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -365,7 +365,7 @@ public class GenericResultSetFactory imp
 		boolean isInSortedOrder,
 		int aggregateItem,
 		int orderItem,
-		GeneratedMethod rowAllocator, 
+		int rowAllocator,
 		int maxRowSize,
 		int resultSetNumber, 
 		double optimizerEstimatedRowCount,
@@ -436,7 +436,7 @@ public class GenericResultSetFactory imp
 		@see ResultSetFactory#getVTIResultSet
 		@exception StandardException thrown on error
 	 */
-	public NoPutResultSet getVTIResultSet(Activation activation, GeneratedMethod row,
+	public NoPutResultSet getVTIResultSet(Activation activation, int row,
 									 int resultSetNumber,
 									 GeneratedMethod constructor,
 									 String javaClassName,
@@ -842,7 +842,7 @@ public class GenericResultSetFactory imp
 	public NoPutResultSet getWindowResultSet(
 								Activation activation,
 								NoPutResultSet source,
-								GeneratedMethod rowAllocator,
+								int rowAllocator,
 								int resultSetNumber,
 								int erdNumber,
 								GeneratedMethod restriction,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GroupedAggregateResultSet.java
Wed Dec 12 09:14:44 2012
@@ -28,7 +28,6 @@ import java.util.HashSet;
 
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.io.FormatableArrayHolder;
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
@@ -85,7 +84,6 @@ class GroupedAggregateResultSet extends 
     // set in constructor and not altered during
     // life of object.
 	private ColumnOrdering[] order;
-	private ExecIndexRow sortTemplateRow;
 	public	boolean	hasDistinctAggregate;	// true if distinct aggregate
 	public	boolean isInSortedOrder;				// true if source results in sorted order
 	private	int numDistinctAggs = 0;
@@ -145,8 +143,7 @@ class GroupedAggregateResultSet extends 
 	 *		SavedObject off of the PreparedStatement that holds the
 	 *		ColumOrdering array used by this routine
 	 * @param	a				activation
-	 * @param	ra				generated method to build an empty
-	 *	 	output row 
+	 * @param	ra				saved object that builds an empty output row
 	 * @param	maxRowSize		approx row size, passed to sorter
 	 * @param	resultSetNumber	The resultSetNumber for this result set
 	 *
@@ -157,7 +154,7 @@ class GroupedAggregateResultSet extends 
 					int	aggregateItem,
 					int	orderingItem,
 					Activation a,
-					GeneratedMethod ra,
+					int ra,
 					int maxRowSize,
 					int resultSetNumber,
 				    double optimizerEstimatedRowCount,
@@ -168,7 +165,6 @@ class GroupedAggregateResultSet extends 
 		this.isInSortedOrder = isInSortedOrder;
 		rollup = isRollup;
 		finishedResults = new ArrayList();
-		sortTemplateRow = getExecutionFactory().getIndexableRow((ExecRow) rowAllocator.invoke(activation));
 		order = (ColumnOrdering[])
 					((FormatableArrayHolder)
 						(a.getPreparedStatement().getSavedObject(orderingItem)))
@@ -213,8 +209,8 @@ class GroupedAggregateResultSet extends 
 		if (SanityManager.DEBUG)
 	    	SanityManager.ASSERT( ! isOpen, "GroupedAggregateResultSet already open");
 
-		sortResultRow = getExecutionFactory().getIndexableRow(sortTemplateRow.getClone());
-		sourceExecIndexRow = getExecutionFactory().getIndexableRow(sortTemplateRow.getClone());
+        sortResultRow = (ExecIndexRow) getRowTemplate().getClone();
+        sourceExecIndexRow = (ExecIndexRow) getRowTemplate().getClone();
 
         source.openCore();
 
@@ -282,9 +278,9 @@ class GroupedAggregateResultSet extends 
 		throws StandardException
 	{
 		SortController 			sorter;
-		ExecRow 				sourceRow;
 		ExecRow 				inputRow;
 		int						inputRowCountEstimate = (int) optimizerEstimatedRowCount;
+        ExecIndexRow            sortTemplateRow = getRowTemplate();
 
 		tc = getTransactionController();
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScalarAggregateResultSet.java
Wed Dec 12 09:14:44 2012
@@ -22,7 +22,6 @@
 package org.apache.derby.impl.sql.execute;
 
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
@@ -48,7 +47,6 @@ class ScalarAggregateResultSet extends G
     // set in constructor and not altered during
     // life of object.
 	public 		boolean 			singleInputRow;
-	protected 	ExecIndexRow 		sortTemplateRow;
 	protected 	boolean 			isInSortedOrder;		// true if source results in sorted order
 
 	// Cache ExecIndexRow for scalar aggregates
@@ -66,8 +64,7 @@ class ScalarAggregateResultSet extends G
 	 *		SavedObject off of the PreparedStatement that holds the
 	 *		AggregatorInfoList used by this routine. 
 	 * @param	a				activation
-	 * @param	ra				generated method to build an empty
-	 *	 	output row 
+	 * @param	ra				saved object that builds an empty output row
 	 * @param	resultSetNumber	The resultSetNumber for this result set
 	 *
 	 * @exception StandardException Thrown on error
@@ -76,7 +73,7 @@ class ScalarAggregateResultSet extends G
 					boolean isInSortedOrder,
 					int	aggregateItem,
 					Activation a,
-					GeneratedMethod ra,
+					int ra,
 					int resultSetNumber,
 					boolean singleInputRow,
 				    double optimizerEstimatedRowCount,
@@ -91,7 +88,6 @@ class ScalarAggregateResultSet extends G
 			SanityManager.ASSERT(source != null,
 				"SARS(), source expected to be non-null");
 		}
-		sortTemplateRow = getExecutionFactory().getIndexableRow((ExecRow) rowAllocator.invoke(activation));
 		this.singleInputRow = singleInputRow;
 
 		if (SanityManager.DEBUG)
@@ -128,7 +124,7 @@ class ScalarAggregateResultSet extends G
 	    	SanityManager.ASSERT( ! isOpen, "ScalarAggregateResultSet already open");
 		}
 
-		sourceExecIndexRow = getExecutionFactory().getIndexableRow(sortTemplateRow);
+		sourceExecIndexRow = (ExecIndexRow) getRowTemplate().getClone();
 
         source.openCore();
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java Wed
Dec 12 09:14:44 2012
@@ -21,17 +21,10 @@
 
 package org.apache.derby.impl.sql.execute;
 
-import org.apache.derby.iapi.services.monitor.Monitor;
-
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
-import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
-import org.apache.derby.iapi.services.stream.InfoStreams;
-
-import org.apache.derby.iapi.services.io.Formatable;
-
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
-import org.apache.derby.iapi.sql.ResultSet;
+import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
 import org.apache.derby.iapi.sql.execute.ExecRow;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 
@@ -44,10 +37,6 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.store.access.SortController;
 import org.apache.derby.iapi.store.access.ScanController;
 
-import org.apache.derby.iapi.services.loader.GeneratedMethod;
-
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.types.RowLocation;
@@ -55,8 +44,7 @@ import org.apache.derby.iapi.types.RowLo
 import org.apache.derby.iapi.services.io.FormatableArrayHolder;
 
 import java.util.Properties;
-import java.util.Vector;
-import java.util.Enumeration;
+import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
 
 /**
  * Takes a source result set, sends it to the sorter,
@@ -122,7 +110,6 @@ class SortResultSet extends NoPutResultS
     // set in constructor and not altered during
     // life of object.
     public NoPutResultSet source;
-	private GeneratedMethod rowAllocator;
 	private ColumnOrdering[] order;
 	private ColumnOrdering[] savedOrder;
 	private SortObserver observer;
@@ -164,8 +151,7 @@ class SortResultSet extends NoPutResultS
 	 *		SavedObject off of the PreparedStatement that holds the
 	 *		ColumOrdering array used by this routine
 	 * @param	a				activation
-	 * @param	ra				generated method to build an empty
-	 *	 	output row 
+     * @param   ra              saved object that generates an empty row
 	 * @param	maxRowSize		approx row size, passed to sorter
 	 * @param	resultSetNumber	The resultSetNumber for this result set
 	 *
@@ -176,7 +162,7 @@ class SortResultSet extends NoPutResultS
 					boolean isInSortedOrder,
 					int	orderingItem,
 					Activation a,
-					GeneratedMethod ra,
+					int ra,
 					int maxRowSize,
 					int resultSetNumber,
 				    double optimizerEstimatedRowCount,
@@ -187,12 +173,15 @@ class SortResultSet extends NoPutResultS
 		this.isInSortedOrder = isInSortedOrder;
         source = s;
         originalSource = s;
-		rowAllocator = ra;
 		this.maxRowSize = maxRowSize;
-		sortTemplateRow = (ExecRow) rowAllocator.invoke(activation);
+
+        ExecPreparedStatement ps = a.getPreparedStatement();
+
+		sortTemplateRow = ((ExecRowBuilder) ps.getSavedObject(ra))
+                                .build(a.getExecutionFactory());
+
 		order = (ColumnOrdering[])
-					((FormatableArrayHolder)
-						(a.getPreparedStatement().getSavedObject(orderingItem)))
+					((FormatableArrayHolder) ps.getSavedObject(orderingItem))
 					.getArray(ColumnOrdering.class);
 
 		/* NOTE: We need to save order to another variable

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java Wed
Dec 12 09:14:44 2012
@@ -26,7 +26,9 @@ import org.apache.derby.catalog.TypeDesc
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
+import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
 import org.apache.derby.iapi.sql.execute.ExecRow;
+import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 
 import org.apache.derby.iapi.sql.Activation;
@@ -70,11 +72,10 @@ class VTIResultSet extends NoPutResultSe
 	public int rowsReturned;
 	public String javaClassName;
 
-    private GeneratedMethod row;
     private GeneratedMethod constructor;
 	private PreparedStatement userPS;
 	private ResultSet userVTI;
-	private ExecRow allocatedRow;
+	private final ExecRow allocatedRow;
 	private FormatableBitSet referencedColumns;
 	private boolean version2;
 	private boolean reuseablePs;
@@ -107,7 +108,7 @@ class VTIResultSet extends NoPutResultSe
     //
     // class interface
     //
-    VTIResultSet(Activation activation, GeneratedMethod row, int resultSetNumber,
+    VTIResultSet(Activation activation, int row, int resultSetNumber,
 				 GeneratedMethod constructor,
 				 String javaClassName,
 				 Qualifier[][] pushedQualifiers,
@@ -127,7 +128,6 @@ class VTIResultSet extends NoPutResultSe
 	{
 		super(activation, resultSetNumber, 
 			  optimizerEstimatedRowCount, optimizerEstimatedCost);
-        this.row = row;
 		this.constructor = constructor;
 		this.javaClassName = javaClassName;
 		this.version2 = version2;
@@ -137,6 +137,11 @@ class VTIResultSet extends NoPutResultSe
 		this.scanIsolationLevel = scanIsolationLevel;
 		this.isDerbyStyleTableFunction = isDerbyStyleTableFunction;
 
+        ExecPreparedStatement ps = activation.getPreparedStatement();
+
+        this.allocatedRow = ((ExecRowBuilder) ps.getSavedObject(row))
+                .build(activation.getExecutionFactory());
+
         this.returnType = returnTypeNumber == -1 ? null :
             (TypeDescriptor)
             activation.getPreparedStatement().getSavedObject(returnTypeNumber);
@@ -592,11 +597,6 @@ class VTIResultSet extends NoPutResultSe
 	private ExecRow getAllocatedRow()
 		throws StandardException
 	{
-		if (allocatedRow == null)
-		{
-			allocatedRow = (ExecRow) row.invoke(activation);
-		}
-
 		return allocatedRow;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java?rev=1420579&r1=1420578&r2=1420579&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/WindowResultSet.java
Wed Dec 12 09:14:44 2012
@@ -32,6 +32,8 @@ import org.apache.derby.iapi.types.DataV
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
+import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
+import org.apache.derby.iapi.sql.execute.ExecRowBuilder;
 
 /**
  * WindowResultSet
@@ -46,8 +48,6 @@ import org.apache.derby.iapi.services.io
 class WindowResultSet extends NoPutResultSetImpl
 {
     private GeneratedMethod restriction = null;
-    private GeneratedMethod row;
-
 
     /**
      * Source result set,
@@ -56,7 +56,7 @@ class WindowResultSet extends NoPutResul
 
 
     /**
-     * Cumulative time needed to evalute any restriction on this result set.
+     * Cumulative time needed to evaluate any restriction on this result set.
      */
     public long restrictionTime;
 
@@ -81,12 +81,13 @@ class WindowResultSet extends NoPutResul
 
     WindowResultSet(Activation activation,
         NoPutResultSet         source,
-        GeneratedMethod        rowAllocator,
+        int                    rowAllocator,
         int                    resultSetNumber,
         int                    erdNumber,
         GeneratedMethod        restriction,
         double                 optimizerEstimatedRowCount,
         double                 optimizerEstimatedCost)
+      throws StandardException
     {
 
         super(activation,
@@ -103,14 +104,16 @@ class WindowResultSet extends NoPutResul
 
         this.restriction = restriction;
         this.source = source;
-        this.row = rowAllocator;
-        this.allocatedRow = null;
         this.rownumber = 0;
 
+        ExecPreparedStatement ps = activation.getPreparedStatement();
+
+        this.allocatedRow = ((ExecRowBuilder) ps.getSavedObject(rowAllocator))
+                .build(activation.getExecutionFactory());
+
         if (erdNumber != -1) {
             this.referencedColumns =
-                (FormatableBitSet)(activation.getPreparedStatement().
-                                   getSavedObject(erdNumber));
+                (FormatableBitSet) ps.getSavedObject(erdNumber);
         }
 
         recordConstructorTime();
@@ -316,13 +319,7 @@ class WindowResultSet extends NoPutResul
      *
      * @exception StandardException thrown on failure.
      */
-    private ExecRow getAllocatedRow()
-        throws StandardException {
-
-        if (allocatedRow == null) {
-            allocatedRow = (ExecRow) row.invoke(activation);
-        }
-
+    private ExecRow getAllocatedRow() throws StandardException {
         return allocatedRow;
     }
 }



Mime
View raw message