cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1334385 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/configuration/server/ test/java/org/apache/cayenne/
Date Sat, 05 May 2012 10:29:59 GMT
Author: aadamchik
Date: Sat May  5 10:29:59 2012
New Revision: 1334385

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

refactoring property access. Instead of deep injection of RuntimeProperties, created
a special property of the DataDomain that can be read directly.
Simplifies unit tests too

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContextQueryAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataContextMaxIdQualifierTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContextQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContextQueryAction.java?rev=1334385&r1=1334384&r2=1334385&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContextQueryAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContextQueryAction.java
Sat May  5 10:29:59 2012
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
-import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.Query;
@@ -109,8 +108,7 @@ class DataContextQueryAction extends Obj
             DbEntity dbEntity = metadata.getDbEntity();
             Integer maxIdQualifierSize = actingDataContext
                     .getParentDataDomain()
-                    .getRuntimeProperties()
-                    .getInt(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, -1);
+                    .getMaxIdQualifierSite();
             List<?> paginatedList;
             if (dbEntity != null && dbEntity.getPrimaryKeys().size() == 1) {
                 paginatedList = new SimpleIdIncrementalFaultList<Object>(

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java?rev=1334385&r1=1334384&r2=1334385&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomain.java
Sat May  5 10:29:59 2012
@@ -38,8 +38,8 @@ import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.access.jdbc.BatchQueryBuilderFactory;
 import org.apache.cayenne.cache.NestedQueryCache;
 import org.apache.cayenne.cache.QueryCache;
+import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.ObjectContextFactory;
-import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.di.BeforeScopeEnd;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.event.EventManager;
@@ -80,8 +80,7 @@ public class DataDomain implements Query
     /**
      * @since 3.1
      */
-    @Inject
-    protected RuntimeProperties runtimeProperties;
+    protected int maxIdQualifierSite;
 
     /**
      * @since 3.1
@@ -944,15 +943,6 @@ public class DataDomain implements Query
         return jdbcEventLogger;
     }
 
-    /**
-     * Returns global runtime properties for this data domain.
-     * 
-     * @since 3.1
-     */
-    RuntimeProperties getRuntimeProperties() {
-        return runtimeProperties;
-    }
-
     void refreshEntitySorter() {
         if (entitySorter != null) {
             entitySorter.setEntityResolver(getEntityResolver());
@@ -1061,4 +1051,26 @@ public class DataDomain implements Query
     public void setDefaultNode(DataNode defaultNode) {
         this.defaultNode = defaultNode;
     }
+
+    /**
+     * Returns a maximum number of object IDs to match in a single query for queries that
+     * select objects based on collection of ObjectIds. This affects queries generated by
+     * Cayenne when processing paginated queries and DISJOINT_BY_ID prefetches and is
+     * intended to address database limitations on the size of SQL statements as well as
+     * to cap memory use in Cayenne when generating such queries. The default is 10000. It
+     * can be changed either by calling {@link #setMaxIdQualifierSite(int)} or changing
+     * the value for property {@link Constants#SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY}.
+     * 
+     * @since 3.1
+     */
+    public int getMaxIdQualifierSite() {
+        return maxIdQualifierSite;
+    }
+
+    /**
+     * @since 3.1
+     */
+    public void setMaxIdQualifierSite(int maxIdQualifierSite) {
+        this.maxIdQualifierSite = maxIdQualifierSite;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java?rev=1334385&r1=1334384&r2=1334385&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
Sat May  5 10:29:59 2012
@@ -29,7 +29,6 @@ import java.util.Set;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.Persistent;
-import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.map.DbJoin;
@@ -171,8 +170,7 @@ class HierarchicalObjectResolver {
 
             int maxIdQualifierSize = context
                     .getParentDataDomain()
-                    .getRuntimeProperties()
-                    .getInt(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, -1);
+                    .getMaxIdQualifierSite();
 
             List<PrefetchSelectQuery> queries = new ArrayList<PrefetchSelectQuery>();
             int qualifiersCount = 0;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java?rev=1334385&r1=1334384&r2=1334385&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/server/DataDomainProvider.java
Sat May  5 10:29:59 2012
@@ -37,6 +37,7 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.DataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.DataChannelDescriptorMerger;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.di.Injector;
@@ -96,6 +97,9 @@ public class DataDomainProvider implemen
     @Inject
     protected QueryCache queryCache;
 
+    @Inject
+    protected RuntimeProperties runtimeProperties;
+
     public DataDomain get() throws ConfigurationException {
 
         try {
@@ -174,6 +178,10 @@ public class DataDomainProvider implemen
         DataChannelDescriptor descriptor = descriptorMerger.merge(descriptors);
         DataDomain dataDomain = createDataDomain(descriptor.getName());
 
+        dataDomain.setMaxIdQualifierSite(runtimeProperties.getInt(
+                Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY,
+                -1));
+
         dataDomain.setQueryCache(new NestedQueryCache(queryCache));
         dataDomain.setEntitySorter(injector.getInstance(EntitySorter.class));
         dataDomain.setEventManager(injector.getInstance(EventManager.class));

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=1334385&r1=1334384&r2=1334385&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:29:59 2012
@@ -4,7 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cayenne.access.DataContext;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.SelectQuery;
@@ -29,13 +29,16 @@ public class DataContextMaxIdQualifierTe
     @Inject
     protected DataChannelInterceptor queryInterceptor;
 
+    @Inject
+    protected ServerRuntime runtime;
+
     protected TableHelper tBag;
     protected TableHelper tBox;
 
     @Override
     protected void setUpAfterInjection() throws Exception {
 
-        System.setProperty(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, "100");
+        runtime.getDataDomain().setMaxIdQualifierSite(100);
 
         dbHelper.deleteAll("BALL");
         dbHelper.deleteAll("BOX_THING");
@@ -51,11 +54,6 @@ public class DataContextMaxIdQualifierTe
         tBox.setColumns("ID", "BAG_ID", "NAME");
     }
 
-    @Override
-    protected void tearDownBeforeInjection() throws Exception {
-        System.getProperties().remove(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY);
-    }
-
     public void testDisjointByIdPrefetch() throws Exception {
         for (int i = 0; i < 1000; i++) {
             tBag.insert(i + 1, "bag" + (i + 1));



Mime
View raw message