db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r497334 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/conn/ impl/sql/conn/ impl/sql/execute/
Date Thu, 18 Jan 2007 07:48:27 GMT
Author: kahatlen
Date: Wed Jan 17 23:48:26 2007
New Revision: 497334

URL: http://svn.apache.org/viewvc?view=rev&rev=497334
Log:
DERBY-2150: Reduce use of synchronized collections in GenericLanguageConnectionContext

Use HashMap instead of Hashtable.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?view=diff&rev=497334&r1=497333&r2=497334
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
Wed Jan 17 23:48:26 2007
@@ -22,7 +22,6 @@
 package org.apache.derby.iapi.sql.conn;
 
 import org.apache.derby.iapi.services.context.Context;
-import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.db.Database;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
@@ -35,25 +34,19 @@
 import org.apache.derby.iapi.sql.depend.Provider;
 import org.apache.derby.iapi.sql.execute.ConstantAction;
 import org.apache.derby.iapi.sql.execute.CursorActivation;
-import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
 import org.apache.derby.iapi.sql.execute.ExecutionContext;
 import org.apache.derby.iapi.sql.execute.ExecutionStmtValidator;
 import org.apache.derby.iapi.sql.Activation;
 import org.apache.derby.iapi.sql.LanguageFactory;
 import org.apache.derby.iapi.sql.PreparedStatement;
-import org.apache.derby.iapi.sql.ResultSet;
 import org.apache.derby.iapi.sql.ParameterValueSet;
 
 import org.apache.derby.iapi.store.access.TransactionController;
-import org.apache.derby.iapi.store.access.AccessFactory;
 import org.apache.derby.iapi.db.TriggerExecutionContext;
-import org.apache.derby.iapi.services.i18n.LocaleFinder;
 import org.apache.derby.iapi.sql.execute.RunTimeStatistics;
 import org.apache.derby.catalog.UUID;
 
-import java.util.Locale;
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.Map;
 
 /**
  * LanguageConnectionContext keeps the result sets,
@@ -978,10 +971,10 @@
 	public boolean getAutoincrementUpdate();
 
 	/**
-	 * copy a hashtable of autoincrement key value pairs into the cache of 
+	 * Copy a map of autoincrement key value pairs into the cache of
 	 * ai values stored in the language connection context.
 	 */
-	public void copyHashtableToAIHT(Hashtable from);
+	public void copyHashtableToAIHT(Map from);
 	
 	/**
 	 * returns the <b>next</b> value to be inserted into an autoincrement col.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=497334&r1=497333&r2=497334
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Wed Jan 17 23:48:26 2007
@@ -30,10 +30,8 @@
 import org.apache.derby.impl.sql.GenericPreparedStatement;
 import org.apache.derby.impl.sql.GenericStatement;
 import org.apache.derby.iapi.sql.Statement;
-import org.apache.derby.impl.sql.conn.CachedStatement;
 
 import org.apache.derby.iapi.services.property.PropertyUtil;
-import org.apache.derby.iapi.services.context.Context;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.sanity.SanityManager;
@@ -72,7 +70,6 @@
 import org.apache.derby.iapi.sql.ParameterValueSet;
 
 import org.apache.derby.iapi.store.access.TransactionController;
-import org.apache.derby.iapi.store.access.AccessFactory;
 import org.apache.derby.iapi.store.access.XATransactionController;
 import org.apache.derby.iapi.util.IdUtil;
 import org.apache.derby.iapi.util.StringUtil;
@@ -84,12 +81,9 @@
 
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Properties;
-import java.util.Stack;
-import java.io.Serializable;
+import java.util.Map;
 
 /**
  * LanguageConnectionContext keeps the pool of prepared statements,
@@ -249,7 +243,7 @@
 	 * To support lastAutoincrementValue: This is a hashtable which maps
 	 * schemaName,tableName,columnName to a Long value.
 	 */
-	private Hashtable autoincrementHT;
+	private HashMap autoincrementHT;
 	/**
 	 * whether to allow updates or not. 
 	 */
@@ -258,7 +252,7 @@
 	private boolean identityNotNull;	//frugal programmer
 
 	// cache of ai being handled in memory (bulk insert + alter table).
-	private Hashtable autoincrementCacheHashtable;
+	private HashMap autoincrementCacheHashtable;
 
 	// temp public
 	public CacheManager statementCache;
@@ -2925,7 +2919,7 @@
 		
 		if (autoincrementCacheHashtable == null)
 		{
-			autoincrementCacheHashtable = new Hashtable();
+			autoincrementCacheHashtable = new HashMap();
 		}
 
 		AutoincrementCounter aic = 
@@ -2997,13 +2991,13 @@
 			return;
 
 		if (autoincrementHT == null)
-			autoincrementHT = new Hashtable();
+			autoincrementHT = new HashMap();
 
 		DataDictionary dd = getDataDictionary();
-		for (Enumeration e = autoincrementCacheHashtable.keys(); 
-			 e.hasMoreElements(); )
+		for (Iterator it = autoincrementCacheHashtable.keySet().iterator();
+			 it.hasNext(); )
 		{
-			Object key = e.nextElement();
+			Object key = it.next();
 			AutoincrementCounter aic = 
 				(AutoincrementCounter)autoincrementCacheHashtable.get(key);
 			Long value = aic.getCurrentValue();
@@ -3017,23 +3011,18 @@
 	}
 
 	/**
-	 * Copies an existing hashtable of autoincrement mappings 
+	 * Copies an existing autoincrement mapping
 	 * into autoincrementHT, the cache of autoincrement values 
 	 * kept in the languageconnectioncontext.
 	 */
-	public void copyHashtableToAIHT(Hashtable from)
+	public void copyHashtableToAIHT(Map from)
 	{
 		if (from.isEmpty())
 			return;
 		if (autoincrementHT == null)
-			autoincrementHT = new Hashtable();
+			autoincrementHT = new HashMap();
 		
-		for (Enumeration e = from.keys(); e.hasMoreElements(); )
-		{
-			Object key = e.nextElement();
-			Object value = from.get(key);
-			autoincrementHT.put(key, value);
-		}
+		autoincrementHT.putAll(from);
 	}
 	
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java?view=diff&rev=497334&r1=497333&r2=497334
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
Wed Jan 17 23:48:26 2007
@@ -22,6 +22,7 @@
 package org.apache.derby.impl.sql.execute;
 
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Properties;
 import java.util.Vector;
@@ -512,7 +513,7 @@
 
 		if (aiCache != null)
 		{
-			Hashtable aiHashtable = new Hashtable();
+			HashMap aiHashtable = new HashMap();
 			int numColumns = aiCache.length;
 			// this insert updated ai values, store them in some persistent
 			// place so that I can see these values.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java?view=diff&rev=497334&r1=497333&r2=497334
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InternalTriggerExecutionContext.java
Wed Jan 17 23:48:26 2007
@@ -40,6 +40,7 @@
 import java.util.Enumeration;
 import java.util.Vector;
 import java.util.Hashtable;
+import java.util.Map;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -619,22 +620,17 @@
 		return null;
 	}
 	/**
-	 * Copy a hashtable of autoincrement values into the trigger 
+	 * Copy a map of autoincrement values into the trigger 
 	 * execution context hashtable of autoincrement values.
 	 */
-	public void copyHashtableToAIHT(Hashtable from)
+	public void copyHashtableToAIHT(Map from)
 	{
 		if (from == null)
 			return;
 		if (aiHT == null)
 			aiHT = new Hashtable();
-		for (Enumeration e = from.keys(); e.hasMoreElements(); )
-		{
-			Object key = e.nextElement();
-			Object value = from.get(key);
-			aiHT.put(key, value);
-			//			System.out.println(" in itec:chte-- " + key + " " + value);
-		}
+
+		aiHT.putAll(from);
 	}
 		
 	/** 



Mime
View raw message