db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r900714 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java
Date Tue, 19 Jan 2010 09:57:38 GMT
Author: kahatlen
Date: Tue Jan 19 09:57:38 2010
New Revision: 900714

URL: http://svn.apache.org/viewvc?rev=900714&view=rev
Log:
DERBY-4512: Avoid unnecessary lookup in transaction table when adding transaction

The transaction table should not contain a transaction with the same
id as the one that's added with TransactionTable.add(). Therefore, put
the new transaction in the table unconditionally instead of checking
first whether there is an existing entry to reuse. This saves one
lookup in the transaction table per transaction.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java?rev=900714&r1=900713&r2=900714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/TransactionTable.java
Tue Jan 19 09:57:38 2010
@@ -125,36 +125,27 @@
 	{
 		TransactionId id = xact.getId();
 
+        TransactionTableEntry newEntry = new TransactionTableEntry(
+                xact, id, 0, exclude ? TransactionTableEntry.EXCLUDE : 0);
+
 		synchronized(this)
 		{
-			TransactionTableEntry ent = findTransactionEntry(id);
-
-			if (ent == null)
-			{
-				ent = new TransactionTableEntry
-					(xact, id, 0, 
-					 exclude ? TransactionTableEntry.EXCLUDE : 0);
+            Object oldEntry = trans.put(id, newEntry);
 
-				trans.put(id, ent);
+            if (SanityManager.DEBUG)
+            {
+                SanityManager.ASSERT(
+                        oldEntry == null,
+                        "Trying to add a transaction that's already " +
+                        "in the transaction table");
 
-				if (SanityManager.DEBUG)
+                if (SanityManager.DEBUG_ON("TranTrace"))
                 {
-                    if (SanityManager.DEBUG_ON("TranTrace"))
-                    {
-                        SanityManager.DEBUG(
-                            "TranTrace", "adding transaction " + id);
-                        SanityManager.showTrace(new Throwable("TranTrace"));
-                    }
+                    SanityManager.DEBUG(
+                        "TranTrace", "adding transaction " + id);
+                    SanityManager.showTrace(new Throwable("TranTrace"));
                 }
-			}
-
-			if (SanityManager.DEBUG)
-			{
-				if (exclude != ent.needExclusion())
-					SanityManager.THROWASSERT(
-					  "adding the same transaction with different exclusion: " +
-					  exclude + " " + ent.needExclusion());
-			}
+            }
 		}
 
 		if (SanityManager.DEBUG) {



Mime
View raw message