cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1334391 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/
Date Sat, 05 May 2012 10:48:40 GMT
Author: aadamchik
Date: Sat May  5 10:48:40 2012
New Revision: 1334391

URL: http://svn.apache.org/viewvc?rev=1334391&view=rev
Log:
CAY-1700 Split long DISJOINT_BY_ID prefetch query on several smaller queries

testing edge cases
fixing endless loop on non-positive value in the incrementalfaultlist

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1334391&r1=1334390&r2=1334391&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sat May  5 10:48:40 2012
@@ -55,6 +55,7 @@ CAY-1686 StringIdQuery - a query providi
 CAY-1688 [PATCH] rename DataDomain.getNode to getDataNode
 CAY-1693 Initial support for bitwise operators in Expression and SelectQuery - MySQL
 CAY-1698 ObjectIdRelationship support for AuditableChild
+CAY-1700 Split long DISJOINT_BY_ID prefetch query on several smaller queries
 
 Bug Fixes Since 3.1M3:
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java?rev=1334391&r1=1334390&r2=1334391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
Sat May  5 10:48:40 2012
@@ -254,8 +254,11 @@ public class IncrementalFaultList<E> imp
 
             // fetch the range of objects in fetchSize chunks
             boolean fetchesDataRows = internalQuery.isFetchingDataRows();
-            List objects = new ArrayList(qualsSize);
-            int fetchEnd = Math.min(qualsSize, maxFetchSize);
+            List<?> objects = new ArrayList<Object>(qualsSize);
+            
+            int fetchSize = maxFetchSize > 0 ? maxFetchSize : Integer.MAX_VALUE;
+            
+            int fetchEnd = Math.min(qualsSize, fetchSize);
             int fetchBegin = 0;
             while (fetchBegin < qualsSize) {
                 SelectQuery query = new SelectQuery(rootEntity, ExpressionFactory
@@ -269,7 +272,7 @@ public class IncrementalFaultList<E> imp
 
                 objects.addAll(dataContext.performQuery(query));
                 fetchBegin = fetchEnd;
-                fetchEnd += Math.min(maxFetchSize, qualsSize - fetchEnd);
+                fetchEnd += Math.min(fetchSize, qualsSize - fetchEnd);
             }
 
             // sanity check - database data may have changed
@@ -366,8 +369,6 @@ public class IncrementalFaultList<E> imp
      * database. This setting governs the size/complexity of the where clause generated to
      * retrieve the next page of records. If the fetch size is less than the page size,
      * then multiple fetches will be made to resolve a page.
-     * 
-     * @return int
      */
     public int getMaxFetchSize() {
         return maxFetchSize;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java?rev=1334391&r1=1334390&r2=1334391&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java
Sat May  5 10:48:40 2012
@@ -38,8 +38,6 @@ public class DataContextMaxIdQualifierTe
     @Override
     protected void setUpAfterInjection() throws Exception {
 
-        runtime.getDataDomain().setMaxIdQualifierSite(100);
-
         dbHelper.deleteAll("BALL");
         dbHelper.deleteAll("BOX_THING");
         dbHelper.deleteAll("THING");
@@ -55,11 +53,14 @@ public class DataContextMaxIdQualifierTe
     }
 
     public void testDisjointByIdPrefetch() throws Exception {
+
         for (int i = 0; i < 1000; i++) {
             tBag.insert(i + 1, "bag" + (i + 1));
             tBox.insert(i + 1, i + 1, "box" + (i + 1));
         }
 
+        runtime.getDataDomain().setMaxIdQualifierSite(100);
+
         final SelectQuery query = new SelectQuery(Bag.class);
         query.addPrefetch(Bag.BOXES_PROPERTY).setSemantics(
                 PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
@@ -74,23 +75,160 @@ public class DataContextMaxIdQualifierTe
         assertEquals(11, queriesCount);
     }
 
-    public void testIncrementalFaultList() throws Exception {
+    public void testDisjointByIdPrefetch_Zero() throws Exception {
+        for (int i = 0; i < 1000; i++) {
+            tBag.insert(i + 1, "bag" + (i + 1));
+            tBox.insert(i + 1, i + 1, "box" + (i + 1));
+        }
+
+        runtime.getDataDomain().setMaxIdQualifierSite(0);
+        
+        final SelectQuery query = new SelectQuery(Bag.class);
+        query.addPrefetch(Bag.BOXES_PROPERTY).setSemantics(
+                PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
+
+        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                context.performQuery(query);
+            }
+        });
+
+        assertEquals(2, queriesCount);
+    }
+    
+    public void testDisjointByIdPrefetch_Negative() throws Exception {
+        for (int i = 0; i < 1000; i++) {
+            tBag.insert(i + 1, "bag" + (i + 1));
+            tBox.insert(i + 1, i + 1, "box" + (i + 1));
+        }
+
+        runtime.getDataDomain().setMaxIdQualifierSite(-1);
+        
+        final SelectQuery query = new SelectQuery(Bag.class);
+        query.addPrefetch(Bag.BOXES_PROPERTY).setSemantics(
+                PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
+
+        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                context.performQuery(query);
+            }
+        });
+
+        assertEquals(2, queriesCount);
+    }
+
+
+    public void testIncrementalFaultList_Lower() throws Exception {
         tBag.insert(1, "bag1");
         for (int i = 0; i < 1000; i++) {
             tBox.insert(i + 1, 1, "box" + (i + 1));
         }
 
+        runtime.getDataDomain().setMaxIdQualifierSite(50);
+
         final SelectQuery query = new SelectQuery(Box.class);
         query.setPageSize(100);
         int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
 
             public void execute() {
                 final List<Box> boxes = context.performQuery(query);
+                for(Box box : boxes) {
+                    box.getBag();
+                }
+            }
+        });
+
+        assertEquals(21, queriesCount);
+        
+        queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                final List<Box> boxes = context.performQuery(query);
                 List<Box> tempList = new ArrayList<Box>();
                 tempList.addAll(boxes);
             }
         });
 
+        assertEquals(21, queriesCount);
+    }
+    
+    public void testIncrementalFaultList_Higher() throws Exception {
+        tBag.insert(1, "bag1");
+        for (int i = 0; i < 1000; i++) {
+            tBox.insert(i + 1, 1, "box" + (i + 1));
+        }
+
+        runtime.getDataDomain().setMaxIdQualifierSite(1001);
+
+        final SelectQuery query = new SelectQuery(Box.class);
+        query.setPageSize(100);
+        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                final List<Box> boxes = context.performQuery(query);
+                for(Box box : boxes) {
+                    box.getBag();
+                }
+            }
+        });
+
         assertEquals(11, queriesCount);
+        
+        queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                final List<Box> boxes = context.performQuery(query);
+                List<Box> tempList = new ArrayList<Box>();
+                tempList.addAll(boxes);
+            }
+        });
+
+        assertEquals(2, queriesCount);
+    }
+    
+    public void testIncrementalFaultList_Zero() throws Exception {
+        tBag.insert(1, "bag1");
+        for (int i = 0; i < 1000; i++) {
+            tBox.insert(i + 1, 1, "box" + (i + 1));
+        }
+
+        runtime.getDataDomain().setMaxIdQualifierSite(0);
+
+        final SelectQuery query = new SelectQuery(Box.class);
+        query.setPageSize(100);
+        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                final List<Box> boxes = context.performQuery(query);
+                List<Box> tempList = new ArrayList<Box>();
+                tempList.addAll(boxes);
+            }
+        });
+
+        assertEquals(2, queriesCount);
+    }
+    
+    public void testIncrementalFaultList_Negative() throws Exception {
+        tBag.insert(1, "bag1");
+        for (int i = 0; i < 1000; i++) {
+            tBox.insert(i + 1, 1, "box" + (i + 1));
+        }
+
+        runtime.getDataDomain().setMaxIdQualifierSite(-1);
+
+        final SelectQuery query = new SelectQuery(Box.class);
+        query.setPageSize(100);
+        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                final List<Box> boxes = context.performQuery(query);
+                List<Box> tempList = new ArrayList<Box>();
+                tempList.addAll(boxes);
+            }
+        });
+
+        assertEquals(2, queriesCount);
     }
 }



Mime
View raw message