db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer RsIterator.java
Date Sun, 25 Jul 2004 00:18:50 GMT
arminw      2004/07/24 17:18:50

  Modified:    src/java/org/apache/ojb/broker/accesslayer RsIterator.java
  Log:
  minor performance improvement:
  first map PK values only from result set and check against the cache, before
  map all field values from result set to internal Map class.
  
  Revision  Changes    Path
  1.65      +15 -13    db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
  
  Index: RsIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- RsIterator.java	23 Jul 2004 11:40:03 -0000	1.64
  +++ RsIterator.java	25 Jul 2004 00:18:50 -0000	1.65
  @@ -415,19 +415,17 @@
            * itemProxyClass should NOT be a member variable.
            */
   
  +        // in any case we need the PK values of result set row
  +        // provide m_row with primary key data of current row
  +        getQueryObject().getClassDescriptor().getRowReader().readPkValuesFrom(getRsAndStmt().m_rs,
getRow());
  +
           if (getItemProxyClass() != null)
           {
  -            // provide m_row with primary key data of current row
  -            getQueryObject().getClassDescriptor().getRowReader().readPkValuesFrom(getRsAndStmt().m_rs,
getRow());
               // assert: m_row is filled with primary key values from db
               return getProxyFromResultSet();
           }
           else
           {
  -            // 0. provide m_row with data of current row
  -            getQueryObject().getClassDescriptor().getRowReader().readObjectArrayFrom(getRsAndStmt().m_rs,
getRow());
  -            // assert: m_row is filled from db
  -
               // 1.read Identity
               Identity oid = getIdentityFromResultSet();
               Object result = null;
  @@ -436,9 +434,11 @@
               result = getCache().lookup(oid);
               if (result == null)
               {
  +
  +                // map all field values from the current result set
  +                getQueryObject().getClassDescriptor().getRowReader().readObjectArrayFrom(getRsAndStmt().m_rs,
getRow());
                   // 3. If Object is not in cache
  -                // materialize Object with primitive attributes filled from
  -                // current row
  +                // materialize Object with primitive attributes filled from current row
                   result = getQueryObject().getClassDescriptor().getRowReader().readObjectFrom(getRow());
                   // result may still be null!
                   if (result != null)
  @@ -464,7 +464,7 @@
                            * actual class.
                            */
                           // fill reference and collection attributes
  -                        ClassDescriptor cld = getQueryObject().getClassDescriptor().getRepository().getDescriptorFor(result.getClass());
  +                        ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass());
                           // don't force loading of reference
                           final boolean unforced = false;
                           // Maps ReferenceDescriptors to HashSets of owners
  @@ -476,11 +476,13 @@
               }
               else // Object is in cache
               {
  -                ClassDescriptor cld = getQueryObject().getClassDescriptor().getRepository().getDescriptorFor(result.getClass());
  -                // if refresh is required, update the cache instance from the
  -                // db
  +                ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass());
  +                // if refresh is required, read all values from the result set and
  +                // update the cache instance from the db
                   if (cld.isAlwaysRefresh())
                   {
  +                    // map all field values from the current result set
  +                    getQueryObject().getClassDescriptor().getRowReader().readObjectArrayFrom(getRsAndStmt().m_rs,
getRow());
                       getQueryObject().getClassDescriptor().getRowReader().refreshObject(result,
getRow());
                   }
                   getBroker().refreshRelationships(result, cld);
  
  
  

---------------------------------------------------------------------
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