jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1464605 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version: InternalVersionHistoryImpl.java InternalVersionManagerBase.java NodeStateEx.java
Date Thu, 04 Apr 2013 15:51:34 GMT
Author: mreutegg
Date: Thu Apr  4 15:51:34 2013
New Revision: 1464605

URL: http://svn.apache.org/r1464605
Log:
JCR-3537: Large number of SQL queries when adding nodes with version history
(patch provided by Todd Pagni)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=1464605&r1=1464604&r2=1464605&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Thu Apr  4 15:51:34 2013
@@ -665,7 +665,8 @@ class InternalVersionHistoryImpl extends
             node.setPropertyValues(NameConstants.JCR_FROZENMIXINTYPES, PropertyType.NAME,
ivalues);
         }
 
-        parent.store();
+        parent.store(false);
+        pNode.store(true);
         return pNode;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=1464605&r1=1464604&r2=1464605&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Thu Apr  4 15:51:34 2013
@@ -576,7 +576,8 @@ abstract class InternalVersionManagerBas
                 n = childn;
             } else if (interNT != null) {
                 childn = n.addNode(name, interNT, null, false);
-                n.store();
+                n.store(false);
+                childn.store(true);
                 n = childn;
             } else {
                 return null;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=1464605&r1=1464604&r2=1464605&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
Thu Apr  4 15:51:34 2013
@@ -710,8 +710,21 @@ public class NodeStateEx {
      * @throws RepositoryException if an error occurs
      */
     public void store() throws RepositoryException {
+        store(true);
+    }
+
+    /**
+     * Stores the persistent state and depending on the <code>recursively</code>
+     * flag also stores the modified child nodes recursively.
+     *
+     *
+     * @param recursively whether to store the nodes recursively or just this
+     *                    single node.
+     * @throws RepositoryException if an error occurs
+     */
+    public void store(boolean recursively) throws RepositoryException {
         try {
-            store(nodeState);
+            store(nodeState, recursively);
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
@@ -723,7 +736,7 @@ public class NodeStateEx {
      * @param state node state to store
      * @throws ItemStateException if an error occurs
      */
-    private void store(NodeState state)
+    private void store(NodeState state, boolean recursively)
             throws ItemStateException {
 
         if (state.getStatus() != ItemState.STATUS_EXISTING) {
@@ -735,10 +748,12 @@ public class NodeStateEx {
                     stateMgr.store(pstate);
                 }
             }
-            // now store all child node entries
-            for (ChildNodeEntry entry : state.getChildNodeEntries()) {
-                NodeState nstate = (NodeState) stateMgr.getItemState(entry.getId());
-                store(nstate);
+            if (recursively) {
+                // now store all child node entries
+                for (ChildNodeEntry entry : state.getChildNodeEntries()) {
+                    NodeState nstate = (NodeState) stateMgr.getItemState(entry.getId());
+                    store(nstate, true);
+                }
             }
             // and store itself
             stateMgr.store(state);



Mime
View raw message