db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1145926 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/types/XML.java impl/sql/compile/SubqueryNode.java impl/sql/compile/TableElementList.java impl/store/access/sort/MergeSort.java
Date Wed, 13 Jul 2011 09:18:26 GMT
Author: kristwaa
Date: Wed Jul 13 09:18:25 2011
New Revision: 1145926

URL: http://svn.apache.org/viewvc?rev=1145926&view=rev
Log:
DERBY-5077: [patch] remove non productive instanceof checks

Removed useless instanceof checks.
Made checkColumnOrdering in MergeSort private and rewrote the comment, and
merged two SanityManager.DEBUG blocks.

Patch provided by Dave Brosius (dbrosius at apache dot org), extended by kristwaa at apache
dot org.

Patch file: derby-5077-1a-remove_useless_instanceofs.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/XML.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/XML.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/XML.java?rev=1145926&r1=1145925&r2=1145926&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/XML.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/XML.java Wed Jul 13 09:18:25
2011
@@ -718,17 +718,15 @@ public class XML
             // passed collation type in determining whether we should
             // generate SQLChar vs CollatorSQLChar for instance. Keep in mind
             // that collation applies only to character string types.
-    		if (result instanceof StringDataValue) {
-    			try {
-    				RuleBasedCollator rbs = ConnectionUtil.getCurrentLCC().getDataValueFactory().
-    				getCharacterCollator(targetCollationType);
-    				result = ((StringDataValue)result).getValue(rbs);
-    			}
-    			catch( java.sql.SQLException sqle)
-    			{
-    				throw StandardException.plainWrapException( sqle);
-    			}
-    		}
+            try {
+                RuleBasedCollator rbs = ConnectionUtil.getCurrentLCC().getDataValueFactory().
+                getCharacterCollator(targetCollationType);
+                result = ((StringDataValue)result).getValue(rbs);
+            }
+            catch( java.sql.SQLException sqle)
+            {
+                throw StandardException.plainWrapException( sqle);
+            }
         }
 
         // Else we're reusing a StringDataValue.  We only reuse

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1145926&r1=1145925&r2=1145926&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Wed
Jul 13 09:18:25 2011
@@ -689,7 +689,7 @@ public class SubqueryNode extends ValueN
                       offset == null &&
                       fetchFirst == null &&
 					  !isWhereExistsAnyInWithWhereSubquery() &&
-					  parentComparisonOperator instanceof BinaryComparisonOperatorNode;
+                      parentComparisonOperator != null;
 
 		if (flattenable)
 		{
@@ -791,7 +791,7 @@ public class SubqueryNode extends ValueN
 				 * of the comparison in case we pull the comparison into
 				 * the flattened subquery.
 				 */
-				if (parentComparisonOperator instanceof BinaryComparisonOperatorNode)
+                if (parentComparisonOperator != null)
 				{
 					leftOperand = parentComparisonOperator.getLeftOperand();
 				}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java?rev=1145926&r1=1145925&r2=1145926&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
Wed Jul 13 09:18:25 2011
@@ -290,8 +290,7 @@ public class TableElementList extends Qu
 			}
 
 			/* Make sure that there are no duplicate constraint names in the list */
-			if (cdn instanceof ConstraintDefinitionNode)
-				checkForDuplicateConstraintNames(ddlStmt, constraintHT, cdn.getConstraintMoniker());
+            checkForDuplicateConstraintNames(ddlStmt, constraintHT, cdn.getConstraintMoniker());
 
 			/* Make sure that the constraint we are trying to drop exists */
 			if (cdn.getConstraintType() == DataDictionary.DROP_CONSTRAINT)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java?rev=1145926&r1=1145925&r2=1145926&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/sort/MergeSort.java
Wed Jul 13 09:18:25 2011
@@ -384,13 +384,17 @@ class MergeSort implements Sort
 	 * Methods of MergeSort.  Arranged alphabetically.
 	 */
 
-	/**
-	Check the column ordering against the template, making
-	sure that each column is present in the template,
-	implements Orderable, and is not mentioned more than
-	once.  Intended to be called as part of a sanity check.
-	**/
-	protected boolean checkColumnOrdering(
+    /**
+     * Check the column ordering against the template, making sure that each
+     * column is present in the template, is not mentioned more than once, and
+     * that the columns isn't {@code null}.
+     * <p>
+     * Intended to be called as part of a sanity check. All columns are
+     * orderable, since {@code DataValueDescriptor} extends {@code Orderable}.
+     *
+     * @return {@code true} if the ordering is valid, {@code false} if not.
+     */
+    private boolean checkColumnOrdering(
     DataValueDescriptor[]   template, 
     ColumnOrdering          columnOrdering[])
 	{
@@ -415,7 +419,7 @@ class MergeSort implements Sort
 			Object columnVal = 
                 RowUtil.getColumn(template, (FormatableBitSet) null, colid);
 
-			if (!(columnVal instanceof Orderable))
+            if (columnVal == null)
 				return false;
 		}
 
@@ -518,11 +522,7 @@ class MergeSort implements Sort
         if (SanityManager.DEBUG)
         {
     		SanityManager.ASSERT(state == STATE_CLOSED);
-    	}
-
-		// Make sure the column ordering makes sense
-        if (SanityManager.DEBUG)
-        {
+            // Make sure the column ordering makes sense
     		SanityManager.ASSERT(checkColumnOrdering(template, columnOrdering),
 	    		"column ordering error");
 	    }



Mime
View raw message