db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1504808 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/io/ impl/sql/compile/ impl/sql/execute/
Date Fri, 19 Jul 2013 09:35:06 GMT
Author: kahatlen
Date: Fri Jul 19 09:35:05 2013
New Revision: 1504808

URL: http://svn.apache.org/r1504808
Log:
DERBY-6292: Use Arrays.copyOf() in FormatableArrayHolder.getArray()

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.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/execute/ColumnInfo.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/GroupedAggregateResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java?rev=1504808&r1=1504807&r2=1504808&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableArrayHolder.java
Fri Jul 19 09:35:05 2013
@@ -21,14 +21,13 @@
 
 package org.apache.derby.iapi.services.io;
 
-import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
 import java.io.IOException;
 
-import java.lang.reflect.Array;
+import java.util.Arrays;
 
 /**
  * A formatable holder for an array of formatables.
@@ -95,30 +94,15 @@ public class FormatableArrayHolder imple
 
 	/**
 	 * Get the held array of formatables, and return
-	 * it in an array of type inputClass.
+     * it in an array that is an instance of {@code arrayClass}.
 	 *
-	 * @param inputClass	the class to use for the returned array
+     * @param arrayClass the type of array to return
 	 *
 	 * @return an array of formatables
 	 */
-	public Object[] getArray(Class inputClass)
+    public <E> E[] getArray(Class<E[]> arrayClass)
 	{
-		Object[] outArray = (Object[])Array.newInstance(inputClass, array.length);
-		
-		/*
-		** HACK: on as400 the following arraycopy() throws an
-		** ArrayStoreException because the output array isn't
-		** assignment compatible with the input array.  This
-		** is a bug on as400, but to get around it we are
-		** going to do an element by element copy.
-		*/
-		//System.arraycopy(array, 0, outArray, 0, outArray.length);
-		for (int i = 0; i < outArray.length; i++)
-		{
-			outArray[i] = array[i];
-		}
-
-		return outArray;
+        return Arrays.copyOf(array, array.length, arrayClass);
 	}
 
 	//////////////////////////////////////////////

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java?rev=1504808&r1=1504807&r2=1504808&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
Fri Jul 19 09:35:05 2013
@@ -546,8 +546,8 @@ abstract	class ExpressionClassBuilder im
 		** We don't expect a lot of order by columns, so
 		** linear search.
 		*/
-		ColumnOrdering[] ordering = (ColumnOrdering[])orderingHolder.
-										getArray(ColumnOrdering.class);
+        ColumnOrdering[] ordering =
+                orderingHolder.getArray(ColumnOrdering[].class);
 		int length = ordering.length;
 		for (int i = 0; i < length; i++)
 		{

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=1504808&r1=1504807&r2=1504808&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 Fri
Jul 19 09:35:05 2013
@@ -1024,8 +1024,8 @@ class GroupByNode extends SingleChildRes
                 StringBuilder s = new StringBuilder();
 					
 				s.append("Group by column ordering is (");
-				ColumnOrdering[] ordering = 
-						(ColumnOrdering[])orderingHolder.getArray(ColumnOrdering.class);
+                ColumnOrdering[] ordering =
+                        orderingHolder.getArray(ColumnOrdering[].class);
 
 				for (int i = 0; i < ordering.length; i++)	
 				{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java?rev=1504808&r1=1504807&r2=1504808&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ColumnInfo.java Fri
Jul 19 09:35:05 2013
@@ -179,7 +179,7 @@ public class ColumnInfo implements Forma
         FormatableArrayHolder   fah = (FormatableArrayHolder) fh.get( "providers" );
         if ( fah != null )
         {
-            providers = (ProviderInfo[]) fah.getArray( ProviderInfo.class );
+            providers = fah.getArray(ProviderInfo[].class);
         }
 	}
 

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=1504808&r1=1504807&r2=1504808&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
Fri Jul 19 09:35:05 2013
@@ -97,10 +97,9 @@ class DistinctScalarAggregateResultSet e
 			  optimizerEstimatedRowCount,
 			  optimizerEstimatedCost);
 
-		order = (ColumnOrdering[])
-					((FormatableArrayHolder)
-						(a.getPreparedStatement().getSavedObject(orderingItem)))
-					.getArray(ColumnOrdering.class);
+        order = ((FormatableArrayHolder)
+                    (a.getPreparedStatement().getSavedObject(orderingItem)))
+                        .getArray(ColumnOrdering[].class);
 
 		this.maxRowSize = maxRowSize;
 

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=1504808&r1=1504807&r2=1504808&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
Fri Jul 19 09:35:05 2013
@@ -166,10 +166,9 @@ class GroupedAggregateResultSet extends 
 		this.isInSortedOrder = isInSortedOrder;
 		rollup = isRollup;
 		finishedResults = new ArrayList<ExecRow>();
-		order = (ColumnOrdering[])
-					((FormatableArrayHolder)
-						(a.getPreparedStatement().getSavedObject(orderingItem)))
-					.getArray(ColumnOrdering.class);
+        order = ((FormatableArrayHolder)
+                    (a.getPreparedStatement().getSavedObject(orderingItem)))
+                        .getArray(ColumnOrdering[].class);
 
 		if (SanityManager.DEBUG)
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java?rev=1504808&r1=1504807&r2=1504808&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashScanResultSet.java
Fri Jul 19 09:35:05 2013
@@ -176,7 +176,8 @@ public class HashScanResultSet extends S
 		FormatableArrayHolder fah = (FormatableArrayHolder)
 										(activation.getPreparedStatement().
 											getSavedObject(hashKeyItem));
-		FormatableIntHolder[] fihArray = (FormatableIntHolder[]) fah.getArray(FormatableIntHolder.class);
+        FormatableIntHolder[] fihArray =
+                fah.getArray(FormatableIntHolder[].class);
 		keyColumns = new int[fihArray.length];
 		for (int index = 0; index < fihArray.length; index++)
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java?rev=1504808&r1=1504807&r2=1504808&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/HashTableResultSet.java
Fri Jul 19 09:35:05 2013
@@ -133,7 +133,7 @@ class HashTableResultSet extends NoPutRe
         projection = p;
 		projectMapping = ((ReferencedColumnsDescriptorImpl) a.getPreparedStatement().getSavedObject(mapRefItem)).getReferencedColumnPositions();
 		FormatableArrayHolder fah = (FormatableArrayHolder) a.getPreparedStatement().getSavedObject(keyColItem);
-		FormatableIntHolder[] fihArray = (FormatableIntHolder[]) fah.getArray(FormatableIntHolder.class);
+        FormatableIntHolder[] fihArray = fah.getArray(FormatableIntHolder[].class);
 		keyColumns = new int[fihArray.length];
 		for (int index = 0; index < fihArray.length; index++)
 		{

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=1504808&r1=1504807&r2=1504808&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 Fri
Jul 19 09:35:05 2013
@@ -180,9 +180,8 @@ class SortResultSet extends NoPutResultS
 		sortTemplateRow = ((ExecRowBuilder) ps.getSavedObject(ra))
                                 .build(a.getExecutionFactory());
 
-		order = (ColumnOrdering[])
-					((FormatableArrayHolder) ps.getSavedObject(orderingItem))
-					.getArray(ColumnOrdering.class);
+        order = ((FormatableArrayHolder) ps.getSavedObject(orderingItem))
+                .getArray(ColumnOrdering[].class);
 
 		/* NOTE: We need to save order to another variable
 		 * in the constructor and reset it on every open.



Mime
View raw message