db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer PlainPrefetcher.java ReferencePrefetcher.java
Date Sat, 06 Mar 2004 23:21:22 GMT
olegnitz    2004/03/06 15:21:22

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        PlainPrefetcher.java ReferencePrefetcher.java
  Log:
  Fixed performance problems pointed out by Jan Magne Hestas <jan-magne@hestas.no>
  
  Revision  Changes    Path
  1.3       +11 -10    db-ojb/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java
  
  Index: PlainPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/PlainPrefetcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PlainPrefetcher.java	8 Feb 2004 13:19:47 -0000	1.2
  +++ PlainPrefetcher.java	6 Mar 2004 23:21:22 -0000	1.3
  @@ -99,6 +99,13 @@
           Identity id2;
           Object proxy;
           Object realSubject;
  +        HashMap realSubjectsMap = new HashMap();
  +
  +        for (Iterator it = realSubjects.iterator(); it.hasNext(); )
  +        {
  +            realSubject = it.next();
  +            realSubjectsMap.put(new Identity(realSubject, pb), realSubject);
  +        }
   
           for (Iterator it = proxies.iterator(); it.hasNext(); )
           {
  @@ -111,16 +118,10 @@
               }
   
               id = handler.getIdentity();
  -
  -            for (Iterator it2 = realSubjects.iterator(); it2.hasNext(); )
  +            realSubject = realSubjectsMap.get(id);
  +            if (realSubject != null)
               {
  -                realSubject = it2.next();
  -                id2 = new Identity(realSubject, pb);
  -                if (id.equals(id2))
  -                {
  -                    handler.setRealSubject(realSubject);
  -                    break;
  -                }
  +                handler.setRealSubject(realSubject);
               }
           }
       }
  
  
  
  1.15      +12 -11    db-ojb/src/java/org/apache/ojb/broker/accesslayer/ReferencePrefetcher.java
  
  Index: ReferencePrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ReferencePrefetcher.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ReferencePrefetcher.java	1 Nov 2003 21:09:41 -0000	1.14
  +++ ReferencePrefetcher.java	6 Mar 2004 23:21:22 -0000	1.15
  @@ -57,6 +57,7 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.HashSet;
  +import java.util.HashMap;
   import java.util.Iterator;
   
   import org.apache.ojb.broker.Identity;
  @@ -102,6 +103,14 @@
           PersistenceBroker pb = getBroker();
           PersistentField field = ord.getPersistentField();
           Class topLevelClass = pb.getTopLevelClass(ord.getItemClass());
  +        HashMap childrenMap = new HashMap();
  +
  +
  +        for (Iterator it = children.iterator(); it.hasNext(); )
  +        {
  +            relatedObject = it.next();
  +            childrenMap.put(new Identity(relatedObject, pb), relatedObject);
  +        }
   
           for (Iterator it = owners.iterator(); it.hasNext(); )
           {
  @@ -113,16 +122,8 @@
                   continue;
               }
               id = new Identity(null, topLevelClass, fkValues);
  -            for (Iterator it2 = children.iterator(); it2.hasNext(); )
  -            {
  -                relatedObject = it2.next();
  -                id2 = new Identity(relatedObject, pb);
  -                if (id.equals(id2))
  -                {
  -                    field.set(owner, relatedObject);
  -                    break;
  -                }
  -            }
  +            relatedObject = childrenMap.get(id);
  +            field.set(owner, relatedObject);
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message