db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r541061 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/
Date Wed, 23 May 2007 20:38:19 GMT
Author: djd
Date: Wed May 23 13:38:17 2007
New Revision: 541061

URL: http://svn.apache.org/viewvc?view=rev&rev=541061
Log:
Generate data values for collated types using the new three argument DataValueFactory.getCharDataValue
method (and for the other character types). This avoids the need to push the DataValueFactory
again
and pass ExpressionClassBuilder into TypeCompiler.generateDataValue.
A subsquent commit will make similar changes for generateNull.
A last commit will remove passing ExpressionClassBuilder and make that class non-public again.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -30,6 +30,10 @@
 
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
 
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.DataValueFactory;
+import org.apache.derby.iapi.types.NumberDataValue;
+import org.apache.derby.iapi.types.SQLInteger;
 import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
@@ -112,10 +116,19 @@
 	public void generateNull(ExpressionClassBuilder e,
 			MethodBuilder mb, int collationType)
 	{
+        int argCount;
+        if (false & pushCollationForDataValue(collationType))
+        {
+            mb.push(collationType);
+            argCount = 2;
+        }
+        else
+            argCount = 1;
+        
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
 									nullMethodName(),
 									interfaceName(),
-									1);
+                                    argCount);
 	}
 
     
@@ -155,6 +168,8 @@
 			MethodBuilder mb, int collationType,
 			LocalField field)
 	{
+
+            
 		String				interfaceName = interfaceName();
 
 		// push the second argument
@@ -171,11 +186,20 @@
 		{
 			mb.getField(field);
 		}
+        
+        int argCount;
+        if (pushCollationForDataValue(collationType))
+        {
+            mb.push(collationType);
+            argCount = 3;
+        }
+        else
+            argCount = 2;
 
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
 							dataValueMethodName(),
 							interfaceName,
-							2);
+                            argCount);
 
 		if (field != null)
 		{
@@ -226,16 +250,43 @@
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getValue", interfaceName(), 1);
 	}
 
-	protected abstract String nullMethodName();
+    /**
+        Return the method name to get a Derby DataValueDescriptor
+        object of the correct type set to SQL NULL. The method named will
+        be called with one argument: a holder object if pushCollationForDataValue()
+        returns false, otherwise two arguments, the second being the
+        collationType.
+    */
+    abstract String nullMethodName();
 
 	/**
 		Return the method name to get a Derby DataValueDescriptor
-		object of the correct type. This implementation returns "getDataValue".
+		object of the correct type and set it to a specific value.
+        The method named will be called with two arguments, a value to set the
+        returned value to and a holder object if pushCollationForDataValue()
+        returns false. Otherwise three arguments, the third being the
+        collationType.
+        This implementation returns "getDataValue" to map
+        to the overloaded methods
+        DataValueFactory.getDataValue(type, dvd type)
 	*/
-	protected String dataValueMethodName()
+	String dataValueMethodName()
 	{
 		return "getDataValue";
 	}
+    
+    /**
+     * Return true if the collationType is to be passed
+     * to the methods generated by generateNull and
+     * generateDataValue.
+     * 
+     * @param collationType Collation type of character values.
+     * @return true collationType will be pushed, false collationType will be ignored.
+     */
+    boolean pushCollationForDataValue(int collationType)
+    {
+        return false;
+    }
 
 	
 	/**
@@ -366,6 +417,16 @@
 		return getTypeId().getTypeFormatId();
 	}
 
+    private static DataValueDescriptor gnn(DataValueFactory dvf)
+    {
+        return dvf.getNullInteger((NumberDataValue) null);
+    }
+    
+    private static DataValueDescriptor gnn2(DataValueFactory dvf)
+    {
+        return new SQLInteger();
+    }
+    
 
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -128,7 +128,7 @@
                 return dts.getMaximumWidth();
         }
 
-        protected String nullMethodName()
+        String nullMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();
                 switch (formatId)
@@ -152,7 +152,7 @@
                 }
         }
 
-        protected String dataValueMethodName()
+        String dataValueMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();
                 switch (formatId)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -128,7 +128,7 @@
 		return TypeCompiler.BOOLEAN_MAXWIDTH_AS_CHAR;
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullBoolean";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -27,6 +27,7 @@
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
+import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
@@ -115,7 +116,7 @@
                 return dts.getMaximumWidth();
         }
 
-        protected String nullMethodName() {
+        String nullMethodName() {
             int formatId = getStoredFormatIdFromTypeId();
             switch (formatId) {
                 case StoredFormatIds.CLOB_TYPE_ID:  return "getNullClob";
@@ -127,7 +128,7 @@
             }
         }
 
-        protected String dataValueMethodName()
+        String dataValueMethodName()
         {
             int formatId = getStoredFormatIdFromTypeId();
             switch (formatId) {
@@ -139,20 +140,17 @@
                     return null;
                 }
         }
-
+        
         /**
-         * Augment the parent's method by ensuring the generated
-         * value is setup for collation if required.
-         * @see BaseTypeCompiler#generateCollationSensitiveDataValue(ExpressionClassBuilder,
MethodBuilder, int)
-         */
-    	public void generateDataValue(
-    			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType,
-    			LocalField field)
-    	{
-    		super.generateDataValue(eb, mb, collationType, field);
-    		generateCollationSensitiveDataValue(eb, mb, collationType);
-    	}
+         * Push the collation type if it is not COLLATION_TYPE_UCS_BASIC.
+         * 
+         * @param collationType Collation type of character values.
+         * @return true collationType will be pushed, false collationType will be ignored.
+         */
+        boolean pushCollationForDataValue(int collationType)
+        {
+            return collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC;
+        }
 
         /**
          * Augment the parent's method by ensuring the generated

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -29,6 +29,7 @@
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 
+import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
@@ -159,7 +160,7 @@
         }
 
 
-        protected String nullMethodName()
+        String nullMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();
                 switch (formatId)
@@ -193,18 +194,15 @@
         }
 
         /**
-         * Augment the parent's method by ensuring the generated
-         * value is setup for collation if required.
-         * @see BaseTypeCompiler#generateCollationSensitiveDataValue(ExpressionClassBuilder,
MethodBuilder, int)
+         * Push the collation type if it is not COLLATION_TYPE_UCS_BASIC.
+         * 
+         * @param collationType Collation type of character values.
+         * @return true collationType will be pushed, false collationType will be ignored.
          */
-     	public void generateDataValue(
-    			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType,
-    			LocalField field)
-    	{
-    		super.generateDataValue(eb, mb, collationType, field);
-    		generateCollationSensitiveDataValue(eb, mb, collationType);
-    	}
+        boolean pushCollationForDataValue(int collationType)
+        {
+            return collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC;
+        }
 
         /**
          * Augment the parent's method by ensuring the generated
@@ -219,7 +217,7 @@
     		generateCollationSensitiveDataValue(eb, mb, collationType);
     	}
 
-        protected String dataValueMethodName()
+        String dataValueMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();
                 switch (formatId)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -126,7 +126,7 @@
 		return 10;
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullDate";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -114,7 +114,7 @@
                 return dts.getMaximumWidth();
         }
 
-        protected String nullMethodName() {
+        String nullMethodName() {
             int formatId = getStoredFormatIdFromTypeId();
             switch (formatId) {
                 case StoredFormatIds.BLOB_TYPE_ID:  return "getNullBlob";
@@ -125,7 +125,7 @@
             }
         }
 
-        protected String dataValueMethodName()
+        String dataValueMethodName()
         {
             int formatId = getStoredFormatIdFromTypeId();
             switch (formatId) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -333,7 +333,7 @@
 		Return the method name to get a Derby DataValueDescriptor
 		object of the correct type. This implementation returns "getDataValue".
 	*/
-	protected String dataValueMethodName()
+	String dataValueMethodName()
 	{
 		if (getStoredFormatIdFromTypeId() == StoredFormatIds.DECIMAL_TYPE_ID)
 			return "getDecimalDataValue";
@@ -341,7 +341,7 @@
 			return super.dataValueMethodName();
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		int formatId = getStoredFormatIdFromTypeId();
 		switch (formatId)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -91,7 +91,7 @@
 		return ClassName.RefDataValue;
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullRef";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -132,7 +132,7 @@
 		return 12.0;
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullTime";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -153,7 +153,7 @@
 	{
 		return 12.0;
 	}
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullTimestamp";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -113,7 +113,7 @@
 		return -1;
 	}
 
-	protected String nullMethodName()
+	String nullMethodName()
 	{
 		return "getNullObject";
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java?view=diff&rev=541061&r1=541060&r2=541061
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
Wed May 23 13:38:17 2007
@@ -130,18 +130,16 @@
     /**
      * @see BaseTypeCompiler#nullMethodName
      */
-    protected String nullMethodName()
+    String nullMethodName()
     {
-        int formatId = getStoredFormatIdFromTypeId();
-        if (formatId == StoredFormatIds.XML_TYPE_ID)
-            return "getNullXML";
-
         if (SanityManager.DEBUG) {
-            SanityManager.THROWASSERT(
-                "unexpected formatId in nullMethodName(): " + formatId);
+            if (getStoredFormatIdFromTypeId() != StoredFormatIds.XML_TYPE_ID)
+                SanityManager.THROWASSERT(
+                "unexpected formatId in nullMethodName(): " + 
+                     getStoredFormatIdFromTypeId());
         }
-
-        return null;
+        
+        return "getNullXML";
     }
 
     /**



Mime
View raw message