cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/7] cayenne git commit: CAY-2141 Skip repetitive query parameters
Date Sun, 27 Nov 2016 14:22:24 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 0e3a07c1e -> 949e3831a


CAY-2141
Skip repetitive query parameters


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/a1176941
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/a1176941
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/a1176941

Branch: refs/heads/master
Commit: a11769410261056bc21d018b85a0176acf999974
Parents: b0d0faf
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Fri Nov 18 18:34:11 2016 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Fri Nov 18 18:34:11 2016 +0300

----------------------------------------------------------------------
 .../access/HierarchicalObjectResolver.java      | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a1176941/cayenne-server/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
index ec45d7c..9d1e5f6 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
@@ -176,34 +176,45 @@ class HierarchicalObjectResolver {
             List<PrefetchSelectQuery> queries = new ArrayList<PrefetchSelectQuery>();
             int qualifiersCount = 0;
             PrefetchSelectQuery currentQuery = null;
+            List<DbJoin> joins = lastDbRelationship.getJoins();
+            Set<List<Object>> values = new HashSet<>();
 
             for (Object dataRow : parentDataRows) {
                 Expression allJoinsQualifier = null;
-                List<DbJoin> joins = lastDbRelationship.getJoins();
 
                 // handling too big qualifiers
                 if (currentQuery == null
                         || (maxIdQualifierSize > 0 && qualifiersCount + joins.size()
> maxIdQualifierSize)) {
+
+                    if(currentQuery != null) {
+                        for(List<Object> joinValues : values) {
+                            for(int i=0; i<joins.size(); i++) {
+                                Expression joinQualifier = ExpressionFactory.matchDbExp(pathPrefix
+                                        + joins.get(i).getTargetName(), joinValues.get(i));
+                                if (allJoinsQualifier == null) {
+                                    allJoinsQualifier = joinQualifier;
+                                } else {
+                                    allJoinsQualifier = allJoinsQualifier.andExp(joinQualifier);
+                                }
+                            }
+                            currentQuery.orQualifier(allJoinsQualifier);
+                        }
+                    }
+
                     currentQuery = new PrefetchSelectQuery(node.getPath(), relationship);
                     queries.add(currentQuery);
                     qualifiersCount = 0;
                 }
 
+                List<Object> joinValues = new ArrayList<>();
                 for (DbJoin join : joins) {
-
                     Object targetValue = ((DataRow) dataRow).get(join.getSourceName());
-                    Expression joinQualifier = ExpressionFactory.matchDbExp(pathPrefix
-                            + join.getTargetName(), targetValue);
-                    if (allJoinsQualifier == null) {
-                        allJoinsQualifier = joinQualifier;
-                    }
-                    else {
-                        allJoinsQualifier = allJoinsQualifier.andExp(joinQualifier);
-                    }
+                    joinValues.add(targetValue);
                 }
 
-                currentQuery.orQualifier(allJoinsQualifier);
-                qualifiersCount += joins.size();
+                if(values.add(joinValues)) {
+                    qualifiersCount += joins.size();
+                }
             }
 
             PrefetchTreeNode jointSubtree = node.cloneJointSubtree();


Mime
View raw message