db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/odmg/oql OQLQueryImpl.java
Date Tue, 24 Dec 2002 13:34:49 GMT
arminw      2002/12/24 05:34:49

  Modified:    src/java/org/apache/ojb/odmg/oql OQLQueryImpl.java
  Log:
  performance improvement
  
  Revision  Changes    Path
  1.10      +20 -3     jakarta-ojb/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java
  
  Index: OQLQueryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- OQLQueryImpl.java	8 Nov 2002 13:47:38 -0000	1.9
  +++ OQLQueryImpl.java	24 Dec 2002 13:34:49 -0000	1.10
  @@ -286,7 +286,7 @@
   		Transaction tx,
   		PersistenceBroker broker,
   		ManageableCollection result)
  -	{		
  +	{
   		OdmgConfiguration config = getConfiguration();
   		// if tx is available and implicit locking is required,
   		// we do READ-lock all found objects
  @@ -295,14 +295,31 @@
   		    // read-lock all resulting objects to the current transaction
   		    Iterator iter = result.ojbIterator();
   		    Object toBeLocked = null;
  +            Class lastUsed = null;
  +            boolean didLockedLastUsed = false;
  +            Class current;
   		    while (iter.hasNext())
   		    {
   		        toBeLocked = iter.next();
  -		        // we can only lock objects, not attributes
  -		        if (broker.hasClassDescriptor(toBeLocked.getClass()))
  +                current = toBeLocked.getClass();
  +		        /*
  +                we can only lock objects, not attributes
  +                arminw:
  +                method #hasClassDescriptor is costly, so we try
  +                to speed up lock-check by checking last used class first.
  +                */
  +		        if ((current.equals(lastUsed) && didLockedLastUsed) ||
  +                        broker.hasClassDescriptor(toBeLocked.getClass()))
   		        {
   		            tx.lock(toBeLocked, Transaction.READ);
  +                    lastUsed = current;
  +                    didLockedLastUsed = true;
   		        }
  +                else
  +                {
  +                    lastUsed = current;
  +                    didLockedLastUsed = false;
  +                }
   		    }
   		}
   	}
  
  
  

Mime
View raw message