db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r566311 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
Date Wed, 15 Aug 2007 19:46:13 GMT
Author: djd
Date: Wed Aug 15 12:46:13 2007
New Revision: 566311

URL: http://svn.apache.org/viewvc?view=rev&rev=566311
Log:
DERBY-1876 Change currentRow in EmbedResultSet to be null if not on current row, otherwise
be a reference to the current row of the top-level language result set. Avoids an object allocation
per-EmbedResultSet that was never used.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?view=diff&rev=566311&r1=566310&r2=566311
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Wed Aug
15 12:46:13 2007
@@ -51,13 +51,10 @@
 
 import org.apache.derby.iapi.services.io.LimitInputStream;
 import org.apache.derby.iapi.services.io.NewByteArrayInputStream;
-import org.apache.derby.iapi.services.io.LimitReader;
 import org.apache.derby.iapi.error.ExceptionSeverity;
 import org.apache.derby.iapi.reference.JDBC20Translation;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.util.StringUtil;
-import org.apache.derby.iapi.util.ReuseFactory;
 
 /* can't import these due to name overlap:
 import java.sql.ResultSet;
@@ -78,8 +75,6 @@
 import java.io.IOException;
 import java.net.URL;
 
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Arrays;
 import java.util.Calendar;
 
@@ -106,10 +101,9 @@
 
 	/** 
 	 * The currentRow contains the data of the current row of the resultset.
-	 * If the containing row array is null, the cursor is not postioned on a 
-	 * row 
+	 * If currentRow is null, the cursor is not postioned on a row 
 	 */
-	private final ExecRow currentRow;	
+	private ExecRow currentRow;	
 	protected boolean wasNull;
     
     /**
@@ -257,16 +251,15 @@
 
 		// Fill in the column types
 		resultDescription = theResults.getResultDescription();
-		final ExecutionFactory factory = conn.getLanguageConnection().
-			getLanguageConnectionFactory().getExecutionFactory();
-		final int columnCount = resultDescription.getColumnCount();
-		this.currentRow = factory.getValueRow(columnCount);
-		currentRow.setRowArray(null);
-
+		
 		// Only incur the cost of allocating and maintaining
 		// updated column information if the columns can be updated.
 		if (concurrencyOfThisResultSet == JDBC20Translation.CONCUR_UPDATABLE)
 		{
+            final int columnCount = resultDescription.getColumnCount();
+            final ExecutionFactory factory = conn.getLanguageConnection().
+            getLanguageConnectionFactory().getExecutionFactory();
+            
 			try{
 				//initialize arrays related to updateRow implementation
 				columnGotUpdated = new boolean[columnCount];
@@ -279,9 +272,11 @@
 			} catch (StandardException t) {
 				throw noStateChangeException(t);
 			}
-		} else {
-			updateRow = null;
 		}
+        else
+        {
+            updateRow = null;
+        }
 
         // assign the max rows and maxfiled size limit for this result set
         if (stmt != null)
@@ -324,7 +319,7 @@
 	// or milder problems due to not having a row.
 	protected final void checkOnRow() throws SQLException 
 	{
-		if (currentRow.getRowArray() == null) {
+		if (currentRow == null) {
 			throw newSQLException(SQLState.NO_CURRENT_ROW);
 		} 
 	}
@@ -491,13 +486,7 @@
 					topWarning.setNextWarning(w);
 			}
 			
-			boolean onRow = (newRow!=null);
-			if (onRow) {
-				currentRow.setRowArray(newRow.getRowArray());
-			} else {
-				currentRow.setRowArray(null);
-			}
-			
+            boolean onRow = (currentRow = newRow) != null;			
 
 			//if (onRow && !(currentRow instanceof org.apache.derby.impl.sql.execute.ValueRow))
 			//	System.out.println(currentRow.getClass());
@@ -636,7 +625,7 @@
 			}
 
 			// the idea is to release resources, so:
-			currentRow.setRowArray(null);
+			currentRow = null;
 
 			// we hang on to theResults and messenger
 			// in case more calls come in on this resultSet
@@ -3753,7 +3742,7 @@
             act.close();
             //For forward only resultsets, after a update, the ResultSet will be positioned
right before the next row.
             if (getType() == TYPE_FORWARD_ONLY) {
-                currentRow.setRowArray(null);
+                currentRow = null;
             } else {
                 movePosition(RELATIVE, 0, "relative");
             }
@@ -3817,7 +3806,7 @@
                 act.close();
                 //After a delete, the ResultSet will be positioned right before 
                 //the next row.
-                currentRow.setRowArray(null);
+                currentRow = null;
                 lcc.popStatementContext(statementContext, null);
             } catch (StandardException t) {
                     throw closeOnTransactionError(t);
@@ -4380,7 +4369,7 @@
 
 	  closeCurrentStream();
 
-	  if (columnIndex < 1 || columnIndex > currentRow.nColumns()) {
+	  if (columnIndex < 1 || columnIndex > resultDescription.getColumnCount()) {
 		  throw newSQLException(SQLState.COLUMN_NOT_FOUND, 
 								new Integer(columnIndex));
 	  }



Mime
View raw message