jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1358299 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: kernel/KernelNodeStoreBranch.java plugins/lucene/LuceneEditor.java spi/commit/ValidatingEditor.java
Date Fri, 06 Jul 2012 16:48:09 GMT
Author: jukka
Date: Fri Jul  6 16:48:08 2012
New Revision: 1358299

URL: http://svn.apache.org/viewvc?rev=1358299&view=rev
Log:
OAK-171: Add NodeState.compareAgainstBaseState()

No need to keep track of the NodeStore in many diff implementations

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingEditor.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1358299&r1=1358298&r2=1358299&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Fri Jul  6 16:48:08 2012
@@ -175,8 +175,7 @@ class KernelNodeStoreBranch implements N
 
     private void diffToJsop(NodeState before, NodeState after, final String path,
             final StringBuilder jsop) {
-
-        store.compare(before, after, new NodeStateDiff() {
+        after.compareAgainstBaseState(before, new NodeStateDiff() {
             @Override
             public void propertyAdded(PropertyState after) {
                 jsop.append('^').append(buildPath(after.getName()))

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java?rev=1358299&r1=1358298&r2=1358299&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
Fri Jul  6 16:48:08 2012
@@ -65,8 +65,8 @@ public class LuceneEditor implements Com
             IndexWriter writer = new IndexWriter(
                     directory, new IndexWriterConfig(VERSION, ANALYZER));
             try {
-                LuceneDiff diff = new LuceneDiff(store, writer, "");
-                store.compare(before, after, diff);
+                LuceneDiff diff = new LuceneDiff(writer, "");
+                after.compareAgainstBaseState(before, diff);
                 diff.postProcess(after);
                 writer.commit();
             } finally {
@@ -82,8 +82,6 @@ public class LuceneEditor implements Com
 
     private static class LuceneDiff implements NodeStateDiff {
 
-        private final NodeStore store;
-
         private final IndexWriter writer;
 
         private final String path;
@@ -92,8 +90,7 @@ public class LuceneEditor implements Com
 
         private IOException exception = null;
 
-        public LuceneDiff(NodeStore store, IndexWriter writer, String path) {
-            this.store = store;
+        public LuceneDiff(IndexWriter writer, String path) {
             this.writer = writer;
             this.path = path;
         }
@@ -140,9 +137,8 @@ public class LuceneEditor implements Com
                 String name, NodeState before, NodeState after) {
             if (exception == null) {
                 try {
-                    LuceneDiff diff =
-                            new LuceneDiff(store, writer, path + "/" + name);
-                    store.compare(before, after, diff);
+                    LuceneDiff diff = new LuceneDiff(writer, path + "/" + name);
+                    after.compareAgainstBaseState(before, diff);
                     diff.postProcess(after);
                 } catch (IOException e) {
                     exception = e;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingEditor.java?rev=1358299&r1=1358298&r2=1358299&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingEditor.java
Fri Jul  6 16:48:08 2012
@@ -47,7 +47,7 @@ public class ValidatingEditor implements
             NodeStore store, NodeState before, NodeState after)
             throws CommitFailedException {
         Validator validator = validatorProvider.getRootValidator(before, after);
-        ValidatorDiff.validate(validator, store, before, after);
+        ValidatorDiff.validate(validator, before, after);
         return after;
     }
 
@@ -57,8 +57,6 @@ public class ValidatingEditor implements
 
         private final Validator validator;
 
-        private final NodeStore store;
-
         /**
          * Checked exceptions don't compose. So we need to hack around.
          * See http://markmail.org/message/ak67n5k7mr3vqylm and
@@ -75,19 +73,19 @@ public class ValidatingEditor implements
          * @param after state of the modified subtree
          * @throws CommitFailedException if validation failed
          */
-        public static void validate(Validator validator, NodeStore store,
-                NodeState before, NodeState after) throws CommitFailedException {
-            new ValidatorDiff(validator, store).validate(before, after);
+        public static void validate(
+                Validator validator, NodeState before, NodeState after)
+                throws CommitFailedException {
+            new ValidatorDiff(validator).validate(before, after);
         }
 
-        private ValidatorDiff(Validator validator, NodeStore store) {
+        private ValidatorDiff(Validator validator) {
             this.validator = validator;
-            this.store = store;
         }
 
         private void validate(NodeState before, NodeState after)
                 throws CommitFailedException {
-            store.compare(before, after, this);
+            after.compareAgainstBaseState(before, this);
             if (exception != null) {
                 throw exception;
             }
@@ -134,7 +132,7 @@ public class ValidatingEditor implements
                 try {
                     Validator v = validator.childNodeAdded(name, after);
                     if (v != null) {
-                        validate(v, store, EMPTY_NODE, after);
+                        validate(v, EMPTY_NODE, after);
                     }
                 } catch (CommitFailedException e) {
                     exception = e;
@@ -150,7 +148,7 @@ public class ValidatingEditor implements
                     Validator v =
                             validator.childNodeChanged(name, before, after);
                     if (v != null) {
-                        validate(v, store, before, after);
+                        validate(v, before, after);
                     }
                 } catch (CommitFailedException e) {
                     exception = e;
@@ -164,7 +162,7 @@ public class ValidatingEditor implements
                 try {
                     Validator v = validator.childNodeDeleted(name, before);
                     if (v != null) {
-                        validate(v, store, before, EMPTY_NODE);
+                        validate(v, before, EMPTY_NODE);
                     }
                 } catch (CommitFailedException e) {
                     exception = e;



Mime
View raw message