The PagingResultObjectProvider during initialization does checks to
determine the appropriate pageSize. While this logic caps the size to 50
and addresses determining an appropriate page size, it doesn't always
conform to the set batch size. For example with the size being 1000 and
FetchBatchSize set to say 500, the page size is determined to be 50
resulting in eager selects happening in batches of 50 when the user
expects it to be in batches of 500. If there are no objections planning
to modify this piece to honor/use the batch size, attached the initial
diff. 

 

Current code:

// try to find a good page size.  if the known size < batch size, use

// it.  if the batch size is set, then use that; if it's sorta close

// to the size, then use the size / 2 to get two full pages rather

// than a possible big one and small one.  cap everything at 50.

int batch = getFetchConfiguration().getFetchBatchSize();

int pageSize;

if (size <= batch && size <= 50)

    pageSize = (int) size;

else if (batch > 0 && batch <= 50) {

    if (size <= batch * 2) {

        if (size % 2 == 0)

            pageSize = (int) (size / 2);

        else

            pageSize = (int) (size / 2 + 1);

    } else

        pageSize = batch;

} else if (size <= 50)

    pageSize = (int) size;

else if (size <= 100) {

    if (size % 2 == 0)

        pageSize = (int) (size / 2);

    else

        pageSize = (int) (size / 2 + 1);

} else

    pageSize = 50;

 

- Srinivasa

D:\OpenJPA 0.9.5\openjpa-jdbc>svn diff
Index: 
src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java
===================================================================
--- 
src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java    
    (revision 464711)
+++ 
src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java    
    (working copy)
@@ -146,31 +146,9 @@
         if (size <= 1)
             throw new InternalException("size=" + size);

-        // try to find a good page size.  if the known size < batch size, use
-        // it.  if the batch size is set, then use that; if it's sorta close
-        // to the size, then use the size / 2 to get two full pages rather
-        // than a possible big one and small one.  cap everything at 50.
-        int batch = getFetchConfiguration().getFetchBatchSize();
-        int pageSize;
-        if (size <= batch && size <= 50)
+        int pageSize = getFetchConfiguration().getFetchBatchSize();
+        if (size < pageSize)
             pageSize = (int) size;
-        else if (batch > 0 && batch <= 50) {
-            if (size <= batch * 2) {
-                if (size % 2 == 0)
-                    pageSize = (int) (size / 2);
-                else
-                    pageSize = (int) (size / 2 + 1);
-            } else
-                pageSize = batch;
-        } else if (size <= 50)
-            pageSize = (int) size;
-        else if (size <= 100) {
-            if (size % 2 == 0)
-                pageSize = (int) (size / 2);
-            else
-                pageSize = (int) (size / 2 + 1);
-        } else
-            pageSize = 50;

         _page = new Object[pageSize];
         if (_paged.length > 1)
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

Reply via email to