db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r528374 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/store/access/ engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/impl/store/access/conglomerate/ testing/org/apache/derbyTesting/unitTests/store/
Date Fri, 13 Apr 2007 07:21:04 GMT
Author: kahatlen
Date: Fri Apr 13 00:21:02 2007
New Revision: 528374

URL: http://svn.apache.org/viewvc?view=rev&rev=528374
Log:
DERBY-2493: Use unsynchronized collections in BackingStoreHashtable

Store the duplicates in ArrayLists instead of Vectors.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.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/store/access/conglomerate/GenericScanController.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_QualifierTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java?view=diff&rev=528374&r1=528373&r2=528374
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/BackingStoreHashtable.java
Fri Apr 13 00:21:02 2007
@@ -32,12 +32,13 @@
 
 import org.apache.derby.iapi.services.cache.ClassSize;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Properties; 
-import java.util.Vector;
 import java.util.NoSuchElementException;
 
 /**
@@ -127,9 +128,10 @@
     private boolean keepAfterCommit;
 
     /**
-     * The estimated number of bytes used by Vector(0)
+     * The estimated number of bytes used by ArrayList(0)
      */  
-    private final static int vectorSize = ClassSize.estimateBaseFromCatalog(java.util.Vector.class);
+    private final static int ARRAY_LIST_SIZE =
+        ClassSize.estimateBaseFromCatalog(ArrayList.class);
     
     private DiskHashtable diskHashtable;
 
@@ -166,7 +168,7 @@
      *                          row in the table of the scan).
      *
      * @param remove_duplicates Should the HashMap automatically remove
-     *                          duplicates, or should it create the Vector of
+     *                          duplicates, or should it create the list of
      *                          duplicates?
      *
      * @param estimated_rowcnt  The estimated number of rows in the hash table.
@@ -425,28 +427,28 @@
         {
             if (!remove_duplicates)
             {
-                Vector row_vec;
+                List row_vec;
 
                 // inserted a duplicate
-                if ((duplicate_value instanceof Vector))
+                if (duplicate_value instanceof List)
                 {
                     doSpaceAccounting( row, false);
-                    row_vec = (Vector) duplicate_value;
+                    row_vec = (List) duplicate_value;
                 }
                 else
                 {
-                    // allocate vector to hold duplicates
-                    row_vec = new Vector(2);
+                    // allocate list to hold duplicates
+                    row_vec = new ArrayList(2);
 
                     // insert original row into vector
-                    row_vec.addElement(duplicate_value);
+                    row_vec.add(duplicate_value);
                     doSpaceAccounting( row, true);
                 }
 
-                // insert new row into vector
-                row_vec.addElement(row);
+                // insert new row into list
+                row_vec.add(row);
 
-                // store vector of rows back into hash table,
+                // store list of rows back into hash table,
                 // overwriting the duplicate key that was 
                 // inserted.
                 hash_table.put(key, row_vec);
@@ -464,7 +466,7 @@
         {
             max_inmemory_size -= getEstimatedMemUsage(row);
             if( firstDuplicate)
-                max_inmemory_size -= vectorSize;
+                max_inmemory_size -= ARRAY_LIST_SIZE;
         }
     } // end of doSpaceAccounting
 
@@ -515,12 +517,12 @@
                 return true; // a degenerate case of spilling
             // If we are keeping duplicates then move all the duplicates from memory to disk
             // This simplifies finding duplicates: they are either all in memory or all on
disk.
-            if( duplicateValue instanceof Vector)
+            if (duplicateValue instanceof List)
             {
-                Vector duplicateVec = (Vector) duplicateValue;
+                List duplicateVec = (List) duplicateValue;
                 for( int i = duplicateVec.size() - 1; i >= 0; i--)
                 {
-                    Object[] dupRow = (Object[]) duplicateVec.elementAt(i);
+                    Object[] dupRow = (Object[]) duplicateVec.get(i);
                     diskHashtable.put( key, dupRow);
                 }
             }
@@ -611,12 +613,12 @@
      * For every qualifying unique row value an entry is placed into the 
      * hash table.
      * <p>
-     * For row values with duplicates, the value of the data is a Vector of
+     * For row values with duplicates, the value of the data is a list of
      * rows.
      * <p>
      * The caller will have to call "instanceof" on the data value
      * object if duplicates are expected, to determine if the data value
-     * of the hash table entry is a row or is a Vector of rows.
+     * of the hash table entry is a row or is a list of rows.
      * <p>
      * The BackingStoreHashtable "owns" the objects returned from the get()
      * routine.  They remain valid until the next access to the 

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?view=diff&rev=528374&r1=528373&r2=528374
==============================================================================
--- 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 Apr 13 00:21:02 2007
@@ -23,17 +23,10 @@
 
 import org.apache.derby.iapi.services.loader.GeneratedMethod;
 
-import org.apache.derby.iapi.services.monitor.Monitor;
-
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.services.io.Storable;
 
-import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
-import org.apache.derby.iapi.services.stream.InfoStreams;
-
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.i18n.MessageService;
 
@@ -46,9 +39,7 @@
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 
 import org.apache.derby.iapi.sql.Activation;
-import org.apache.derby.iapi.sql.ResultSet;
 
-import org.apache.derby.iapi.store.access.ConglomerateController;
 import org.apache.derby.iapi.store.access.Qualifier;
 import org.apache.derby.iapi.store.access.RowUtil;
 import org.apache.derby.iapi.store.access.ScanController;
@@ -56,8 +47,6 @@
 import org.apache.derby.iapi.store.access.TransactionController;
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.types.Orderable;
 import org.apache.derby.iapi.types.RowLocation;
 
 import org.apache.derby.iapi.store.access.BackingStoreHashtable;
@@ -66,18 +55,17 @@
 import org.apache.derby.iapi.services.io.FormatableIntHolder;
 import org.apache.derby.iapi.store.access.KeyHasher;
 
-import java.util.Enumeration;
+import java.util.List;
 import java.util.Properties;
-import java.util.Vector;
 
 /**
  * Takes a conglomerate and a table filter builds a hash table on the 
  * specified column of the conglomerate on the 1st open.  Look up into the
  * hash table is done on the hash key column.  The hash table consists of
- * either DataValueDescriptor[]s or Vectors of DataValueDescriptor[].  The store builds 
- * the hash table.  When a collision occurs, the store builds a Vector with
- * the colliding DataValueDescriptor[]s.
- *
+ * either <code>DataValueDescriptor[]</code>s or <code>List</code>s
of
+ * <code>DataValueDescriptor[]</code>. The store builds the hash table. When
a
+ * collision occurs, the store builds a <code>List</code> with the colliding
+ * <code>DataValueDescriptor[]</code>s.
  */
 public class HashScanResultSet extends NoPutResultSetImpl
 	implements CursorResultSet
@@ -92,7 +80,7 @@
 	protected boolean	firstNext = true;
 	private int			numFetchedOnNext;
 	private int			entryVectorSize;
-	private Vector		entryVector;
+	private List		entryVector;
 
     // set in constructor and not altered during
     // life of object.
@@ -508,12 +496,12 @@
 						hashEntry = (mh == null) ? null : hashtable.get(mh);
 					}
 
-					if (hashEntry instanceof Vector)
+					if (hashEntry instanceof List)
 					{
-						entryVector = (Vector) hashEntry;
+						entryVector = (List) hashEntry;
 						entryVectorSize = entryVector.size();
 						columns = 
-                            (DataValueDescriptor[]) entryVector.firstElement();
+                            (DataValueDescriptor[]) entryVector.get(0);
 					}
 					else
 					{
@@ -524,11 +512,9 @@
 				}
 				else if (numFetchedOnNext < entryVectorSize)
 				{
-					/* We walking a Vector and there's 
-					 * more rows left in the vector.
-					 */
+					// We are walking a list and there are more rows left.
 					columns = (DataValueDescriptor[]) 
-                        entryVector.elementAt(numFetchedOnNext);
+                        entryVector.get(numFetchedOnNext);
 				}
 
 				if (columns != null)

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?view=diff&rev=528374&r1=528373&r2=528374
==============================================================================
--- 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 Apr 13 00:21:02 2007
@@ -23,28 +23,20 @@
 
 import org.apache.derby.iapi.services.loader.GeneratedMethod;
 
-import org.apache.derby.iapi.services.monitor.Monitor;
-
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.services.io.Storable;
 
-import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
-import org.apache.derby.iapi.services.stream.InfoStreams;
-
 import org.apache.derby.iapi.error.StandardException;
 
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.conn.StatementContext;
 
-
 import org.apache.derby.iapi.sql.execute.CursorResultSet;
 import org.apache.derby.iapi.sql.execute.ExecRow;
 import org.apache.derby.iapi.sql.execute.NoPutResultSet;
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.sql.Activation;
-import org.apache.derby.iapi.sql.ResultSet;
 
 import org.apache.derby.iapi.store.access.Qualifier;
 import org.apache.derby.iapi.store.access.RowSource;
@@ -59,8 +51,8 @@
 
 import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
 
+import java.util.List;
 import java.util.Properties;
-import java.util.Vector;
 
 /**
  * Builds a hash table on the underlying result set tree.
@@ -96,7 +88,7 @@
 	private boolean		firstNext = true;
 	private int			numFetchedOnNext;
 	private int			entryVectorSize;
-	private Vector		entryVector;
+	private List		entryVector;
 
 	private boolean hashTableBuilt;
 	private boolean firstIntoHashtable = true;
@@ -346,12 +338,12 @@
 						hashEntry = ht.get(mh);
 					}
 
-					if (hashEntry instanceof Vector)
+					if (hashEntry instanceof List)
 					{
-						entryVector = (Vector) hashEntry;
+						entryVector = (List) hashEntry;
 						entryVectorSize = entryVector.size();
 						columns = 
-                            (DataValueDescriptor[]) entryVector.firstElement();
+                            (DataValueDescriptor[]) entryVector.get(0);
 					}
 					else
 					{
@@ -362,11 +354,9 @@
 				}
 				else if (numFetchedOnNext < entryVectorSize)
 				{
-					/* We walking a Vector and there's 
-					 * more rows left in the vector.
-					 */
+					// We are walking a list and there are more rows left.
 					columns = (DataValueDescriptor[]) 
-                        entryVector.elementAt(numFetchedOnNext);
+                        entryVector.get(numFetchedOnNext);
 				}
 
 				if (columns != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java?view=diff&rev=528374&r1=528373&r2=528374
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
Fri Apr 13 00:21:02 2007
@@ -40,8 +40,6 @@
 import org.apache.derby.iapi.store.raw.Page;
 import org.apache.derby.iapi.store.raw.RecordHandle;
 
-import org.apache.derby.iapi.store.access.Qualifier;
-
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
 import org.apache.derby.iapi.types.RowLocation;
@@ -1158,10 +1156,10 @@
      * Hashtable has a key value of the object stored in 
      * row[key_column_number], and the value of the data is row.  For row 
      * values with duplicates, the key value is also row[key_column_number], 
-     * but the value of the data is a Vector of
+     * but the value of the data is a <code>List</code> of
      * rows.  The caller will have to call "instanceof" on the data value
      * object if duplicates are expected, to determine if the data value
-     * of the Hashtable entry is a row or is a Vector of rows.
+     * of the Hashtable entry is a row or is a <code>List</code> of rows.
      * <p>
      * Note, that for this routine to work efficiently the caller must 
      * ensure that the object in row[key_column_number] implements 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_QualifierTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_QualifierTest.java?view=diff&rev=528374&r1=528373&r2=528374
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_QualifierTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_QualifierTest.java
Fri Apr 13 00:21:02 2007
@@ -27,6 +27,7 @@
 
 import java.util.Properties;
 import java.util.HashSet;
+import java.util.List;
 
 import java.io.PrintWriter;
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
@@ -48,7 +49,6 @@
 import org.apache.derby.iapi.store.access.BackingStoreHashtable;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import java.util.Enumeration;
-import java.util.Vector;
 
 public class T_QualifierTest 
 {
@@ -1042,15 +1042,13 @@
                 }
                 numrows++;
             }
-            else if (obj instanceof Vector)
+            else if (obj instanceof List)
             {
-
-
-                Vector row_vect = (Vector) obj;
+                List row_vect = (List) obj;
 
                 for (int i = 0; i < row_vect.size(); i++)
                 {
-                    row = (DataValueDescriptor[] ) row_vect.elementAt(i);
+                    row = (DataValueDescriptor[]) row_vect.get(i);
 
                     key = ((SQLLongint)(row[2])).getLong();
 



Mime
View raw message