cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2122 Vertical Inheritance: Cannot Insert Record For Implementing Class with Attribute And Relationship
Date Sat, 08 Oct 2016 15:10:49 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 377a1ef27 -> 5611ca2aa


CAY-2122 Vertical Inheritance: Cannot Insert Record For Implementing Class with Attribute
And Relationship

a note on performance degradation of the flattened queries


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

Branch: refs/heads/master
Commit: 5611ca2aa24de41184e876bc80b2ab4151130eb1
Parents: 377a1ef
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Sat Oct 8 16:43:34 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sat Oct 8 18:10:31 2016 +0300

----------------------------------------------------------------------
 .../access/DataDomainFlattenedBucket.java       | 28 ++++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/5611ca2a/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlattenedBucket.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlattenedBucket.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlattenedBucket.java
index 6ac7db5..817ada7 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlattenedBucket.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DataDomainFlattenedBucket.java
@@ -19,14 +19,6 @@
 
 package org.apache.cayenne.access;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -35,6 +27,14 @@ import org.apache.cayenne.query.DeleteBatchQuery;
 import org.apache.cayenne.query.InsertBatchQuery;
 import org.apache.cayenne.query.Query;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * A sync bucket that holds flattened queries.
  * 
@@ -97,12 +97,22 @@ class DataDomainFlattenedBucket {
      * @param queries
      */
     void appendInserts(Collection<Query> queries) {
+
+        // TODO: see "O(N) lookups" TODO's below. The first is relatively benign, as N is
the number of DbEntities in the
+        // preceeding DataDomainInsertBucket processing. The second nested one is potentially
much worse, as it may
+        // result in a linear scan of thousands of objects. E.g. it will affect cases with
vertical inheritance with
+        // relationships in subclasses...
+
+        // The fix to the above is to merge this code into DataDomainInsertBucket, so that
we can combine regular and
+        // flattened snapshots at the point of InsertBatchQuery creation.
+
         for (Map.Entry<DbEntity, List<FlattenedArcKey>> entry : insertArcKeys.entrySet())
{
             DbEntity dbEntity = entry.getKey();
             List<FlattenedArcKey> flattenedArcKeys = entry.getValue();
 
             DataNode node = parent.getDomain().lookupDataNode(dbEntity.getDataMap());
 
+            // TODO: O(N) lookup
             InsertBatchQuery existingQuery = findInsertBatchQuery(queries, dbEntity);
             InsertBatchQuery newQuery = new InsertBatchQuery(dbEntity, 50);
 
@@ -110,6 +120,8 @@ class DataDomainFlattenedBucket {
                 Map<String, Object> snapshot = flattenedArcKey.buildJoinSnapshotForInsert(node);
 
                 if (existingQuery != null) {
+
+                    // TODO: O(N) lookup
                     BatchQueryRow existingRow = findRowForObjectId(existingQuery.getRows(),
flattenedArcKey.id1.getSourceId());
                     // todo: do we need to worry about flattenedArcKey.id2 ?
 


Mime
View raw message