You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2013/12/17 17:37:46 UTC

svn commit: r1551610 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java

Author: jukka
Date: Tue Dec 17 16:37:46 2013
New Revision: 1551610

URL: http://svn.apache.org/r1551610
Log:
OAK-1273: Reduce overhead when handling many parallel property indices

Simplify EditorDiff stack traces by removing an extra stack frame at the expense of some duplication of code

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java?rev=1551610&r1=1551609&r2=1551610&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorDiff.java Tue Dec 17 16:37:46 2013
@@ -112,9 +112,24 @@ public class EditorDiff implements NodeS
     @Override
     public boolean childNodeAdded(String name, NodeState after) {
         try {
-            Editor e = editor.childNodeAdded(name, after);
-            exception = process(e, MISSING_NODE, after);
-            return exception == null;
+            NodeState before = MISSING_NODE;
+            Editor childEditor = editor.childNodeAdded(name, after);
+            // NOTE: This piece of code is duplicated across this and the
+            // other child node diff methods. The reason for the duplication
+            // is to simplify the frequently occurring long stack traces
+            // in diff processing.
+            if (childEditor != null) {
+                childEditor.enter(before, after);
+
+                EditorDiff diff = new EditorDiff(childEditor);
+                if (!after.compareAgainstBaseState(before, diff)) {
+                    exception = diff.exception;
+                    return false;
+                }
+
+                childEditor.leave(before, after);
+            }
+            return true;
         } catch (CommitFailedException e) {
             exception = e;
             return false;
@@ -125,9 +140,19 @@ public class EditorDiff implements NodeS
     public boolean childNodeChanged(
             String name, NodeState before, NodeState after) {
         try {
-            Editor e = editor.childNodeChanged(name, before, after);
-            exception = process(e, before, after);
-            return exception == null;
+            Editor childEditor = editor.childNodeChanged(name, before, after);
+            if (childEditor != null) {
+                childEditor.enter(before, after);
+
+                EditorDiff diff = new EditorDiff(childEditor);
+                if (!after.compareAgainstBaseState(before, diff)) {
+                    exception = diff.exception;
+                    return false;
+                }
+
+                childEditor.leave(before, after);
+            }
+            return true;
         } catch (CommitFailedException e) {
             exception = e;
             return false;
@@ -137,9 +162,20 @@ public class EditorDiff implements NodeS
     @Override
     public boolean childNodeDeleted(String name, NodeState before) {
         try {
-            Editor e = editor.childNodeDeleted(name, before);
-            exception = process(e, before, MISSING_NODE);
-            return exception == null;
+            NodeState after = MISSING_NODE;
+            Editor childEditor = editor.childNodeDeleted(name, before);
+            if (childEditor != null) {
+                childEditor.enter(before, after);
+
+                EditorDiff diff = new EditorDiff(childEditor);
+                if (!after.compareAgainstBaseState(before, diff)) {
+                    exception = diff.exception;
+                    return false;
+                }
+
+                childEditor.leave(before, after);
+            }
+            return true;
         } catch (CommitFailedException e) {
             exception = e;
             return false;