Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 282B6DB49 for ; Fri, 6 Jul 2012 16:48:33 +0000 (UTC) Received: (qmail 30137 invoked by uid 500); 6 Jul 2012 16:48:33 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 30117 invoked by uid 500); 6 Jul 2012 16:48:33 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-commits@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 30108 invoked by uid 99); 6 Jul 2012 16:48:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2012 16:48:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2012 16:48:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4BF222388847; Fri, 6 Jul 2012 16:48:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120706164809.4BF222388847@eris.apache.org> 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;