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 3E888E4FB for ; Wed, 13 Mar 2013 16:34:25 +0000 (UTC) Received: (qmail 82861 invoked by uid 500); 13 Mar 2013 16:34:25 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 82835 invoked by uid 500); 13 Mar 2013 16:34:25 -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-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 82825 invoked by uid 99); 13 Mar 2013 16:34:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Mar 2013 16:34:25 +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; Wed, 13 Mar 2013 16:34:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C46382388ADA; Wed, 13 Mar 2013 16:33:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1456040 [1/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/jav... Date: Wed, 13 Mar 2013 16:33:35 -0000 To: oak-commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130313163337.C46382388ADA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Wed Mar 13 16:33:34 2013 New Revision: 1456040 URL: http://svn.apache.org/r1456040 Log: OAK-698: Optimize handling of empty node states Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java 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/index/IndexHookManagerDiff.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diffindex/BaseDiffCollector.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexDiff.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeState.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionHook.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorHook.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidatorTest.java jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDiff.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiff.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiffIT.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookIT.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java Wed Mar 13 16:33:34 2013 @@ -38,7 +38,6 @@ import org.apache.jackrabbit.oak.api.Tre import org.apache.jackrabbit.oak.api.TreeLocation; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.index.diffindex.UUIDDiffIndexProviderWrapper; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.query.QueryEngineImpl; import org.apache.jackrabbit.oak.security.authentication.SystemSubject; import org.apache.jackrabbit.oak.spi.commit.CommitHook; @@ -65,6 +64,7 @@ import static com.google.common.base.Pre import static com.google.common.base.Preconditions.checkNotNull; import static org.apache.jackrabbit.oak.commons.PathUtils.getName; import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; public class RootImpl implements Root { @@ -252,7 +252,7 @@ public class RootImpl implements Root { // Disconnect all children -> access to now invalid trees fails fast if (OAK_690) { - rootTree.getNodeBuilder().reset(MemoryNodeState.EMPTY_NODE); + rootTree.getNodeBuilder().reset(EMPTY_NODE); } rootTree = new TreeImpl(this, lastMove); modCount = 0; Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java Wed Mar 13 16:33:34 2013 @@ -48,6 +48,7 @@ import org.apache.jackrabbit.oak.api.Typ import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState; import org.apache.jackrabbit.oak.plugins.memory.BooleanPropertyState; +import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState; import org.apache.jackrabbit.oak.plugins.value.Conversions; @@ -59,6 +60,7 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; import static com.google.common.base.Preconditions.checkNotNull; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; /** @@ -311,6 +313,8 @@ public final class KernelNodeState exten public void compareAgainstBaseState(NodeState base, NodeStateDiff diff) { if (this == base) { return; // no differences + } else if (base == EMPTY_NODE) { + EmptyNodeState.compareAgainstEmptyState(this, diff); // special case } else if (base instanceof KernelNodeState) { KernelNodeState kbase = (KernelNodeState) base; if (kernel.equals(kbase.kernel)) { 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=1456040&r1=1456039&r2=1456040&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 Wed Mar 13 16:33:34 2013 @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.kernel import org.apache.jackrabbit.mk.api.MicroKernel; import org.apache.jackrabbit.mk.api.MicroKernelException; import org.apache.jackrabbit.oak.api.CommitFailedException; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; import org.apache.jackrabbit.oak.spi.commit.CommitHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -188,7 +187,7 @@ class KernelNodeStoreBranch implements N } else if (headRevision == null) { // Nothing written to persistent branch yet // perform rebase in memory - NodeBuilder builder = new MemoryNodeBuilder(root); + NodeBuilder builder = root.builder(); getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder)); head = builder.getNodeState(); base = root; Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiff.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiff.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiff.java Wed Mar 13 16:33:34 2013 @@ -30,7 +30,6 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; @@ -45,6 +44,7 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_UNKNOWN; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * Acts as a composite NodeStateDiff, it delegates all the diff's events to the @@ -297,7 +297,7 @@ class IndexHookManagerDiff implements No @Override public void childNodeAdded(String nodeName, NodeState after) { - childNodeChanged(nodeName, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(nodeName, EMPTY_NODE, after); } @Override @@ -318,6 +318,6 @@ class IndexHookManagerDiff implements No @Override public void childNodeDeleted(String nodeName, NodeState before) { - childNodeChanged(nodeName, before, MemoryNodeState.EMPTY_NODE); + childNodeChanged(nodeName, before, EMPTY_NODE); } } \ No newline at end of file Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diffindex/BaseDiffCollector.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diffindex/BaseDiffCollector.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diffindex/BaseDiffCollector.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diffindex/BaseDiffCollector.java Wed Mar 13 16:33:34 2013 @@ -17,11 +17,11 @@ package org.apache.jackrabbit.oak.plugins.index.diffindex; import static org.apache.jackrabbit.oak.commons.PathUtils.concat; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import java.util.HashSet; import java.util.Set; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.query.Filter; import org.apache.jackrabbit.oak.spi.state.EmptyNodeStateDiff; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -123,7 +123,7 @@ public abstract class BaseDiffCollector @Override public void childNodeAdded(String name, NodeState after) { - childNodeChanged(name, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(name, EMPTY_NODE, after); } @Override Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexDiff.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexDiff.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexDiff.java Wed Mar 13 16:33:34 2013 @@ -30,7 +30,6 @@ import org.apache.jackrabbit.oak.api.Typ import org.apache.jackrabbit.oak.plugins.index.IndexHook; import org.apache.jackrabbit.oak.plugins.index.p2.strategy.ContentMirrorStoreStrategy; import org.apache.jackrabbit.oak.plugins.index.p2.strategy.IndexStoreStrategy; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; @@ -42,6 +41,7 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.p2.Property2Index.TYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * {@link IndexHook} implementation that is responsible for keeping the @@ -247,7 +247,7 @@ class Property2IndexDiff implements Inde @Override public void childNodeAdded(String name, NodeState after) { - childNodeChanged(name, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(name, EMPTY_NODE, after); } @Override @@ -260,7 +260,7 @@ class Property2IndexDiff implements Inde @Override public void childNodeDeleted(String name, NodeState before) { - childNodeChanged(name, before, MemoryNodeState.EMPTY_NODE); + childNodeChanged(name, before, EMPTY_NODE); } // -----------------------------------------------------< IndexHook >-- @@ -286,7 +286,7 @@ class Property2IndexDiff implements Inde } if (reindex) { state.getNodeState().compareAgainstBaseState( - MemoryNodeState.EMPTY_NODE, + EMPTY_NODE, new Property2IndexDiff(null, state, null, "/", indexMap)); } } Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexDiff.java Wed Mar 13 16:33:34 2013 @@ -22,6 +22,7 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.property.PropertyIndex.TYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import java.io.IOException; import java.util.HashMap; @@ -34,7 +35,6 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; @@ -204,7 +204,7 @@ class PropertyIndexDiff implements Index @Override public void childNodeAdded(String name, NodeState after) { - childNodeChanged(name, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(name, EMPTY_NODE, after); } @Override @@ -217,7 +217,7 @@ class PropertyIndexDiff implements Index @Override public void childNodeDeleted(String name, NodeState before) { - childNodeChanged(name, before, MemoryNodeState.EMPTY_NODE); + childNodeChanged(name, before, EMPTY_NODE); } // -----------------------------------------------------< IndexHook >-- @@ -243,7 +243,7 @@ class PropertyIndexDiff implements Index } if (reindex) { state.getNodeState().compareAgainstBaseState( - MemoryNodeState.EMPTY_NODE, + EMPTY_NODE, new PropertyIndexDiff(null, state, null, "/", updates)); } } Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java?rev=1456040&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java (added) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java Wed Mar 13 16:33:34 2013 @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.plugins.memory; + +import java.util.Collections; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; + +/** + * Singleton instance of an empty node state, i.e. one with neither + * properties nor child nodes. + */ +public final class EmptyNodeState implements NodeState { + + public static final NodeState EMPTY_NODE = new EmptyNodeState(); + + private EmptyNodeState() { + } + + @Override + public long getPropertyCount() { + return 0; + } + + @Override @CheckForNull + public PropertyState getProperty(String name) { + return null; + } + + @Override @Nonnull + public Iterable getProperties() { + return Collections.emptyList(); + } + + @Override + public long getChildNodeCount() { + return 0; + } + + @Override + public boolean hasChildNode(@Nonnull String name) { + return false; + } + + @Override @CheckForNull + public NodeState getChildNode(@Nonnull String name) { + return null; + } + + @Override + public Iterable getChildNodeNames() { + return Collections.emptyList(); + } + + @Override @Nonnull + public Iterable getChildNodeEntries() { + return Collections.emptyList(); + } + + @Override @Nonnull + public NodeBuilder builder() { + return new MemoryNodeBuilder(this); + } + + @Override + public void compareAgainstBaseState(NodeState base, NodeStateDiff diff) { + if (base != EMPTY_NODE) { + for (PropertyState before : base.getProperties()) { + diff.propertyDeleted(before); + } + for (ChildNodeEntry before : base.getChildNodeEntries()) { + diff.childNodeDeleted(before.getName(), before.getNodeState()); + } + } + } + + public static void compareAgainstEmptyState( + NodeState state, NodeStateDiff diff) { + if (state != EMPTY_NODE) { + for (PropertyState after : state.getProperties()) { + diff.propertyAdded(after); + } + for (ChildNodeEntry after : state.getChildNodeEntries()) { + diff.childNodeAdded(after.getName(), after.getNodeState()); + } + } + } + + //------------------------------------------------------------< Object >-- + + public String toString() { + return "{ }"; + } + + public boolean equals(Object object) { + if (object == EMPTY_NODE) { + return true; + } else if (object instanceof NodeState) { + NodeState that = (NodeState) object; + return that.getPropertyCount() == 0 + && that.getChildNodeCount() == 0; + } else { + return false; + } + } + + public int hashCode() { + return 0; + } +} Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java Wed Mar 13 16:33:34 2013 @@ -33,6 +33,7 @@ import org.apache.jackrabbit.oak.spi.sta import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.with; import static org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.withNodes; import static org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState.withProperties; @@ -517,7 +518,7 @@ public class MemoryNodeBuilder implement if (base != null) { this.base = base; } else { - this.base = MemoryNodeState.EMPTY_NODE; + this.base = EMPTY_NODE; } } Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeState.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeState.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeState.java Wed Mar 13 16:33:34 2013 @@ -29,18 +29,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; + /** * Basic in-memory node state implementation. */ public class MemoryNodeState extends AbstractNodeState { - /** - * Singleton instance of an empty node state, i.e. one with neither - * properties nor child nodes. - */ - public static final NodeState EMPTY_NODE = new MemoryNodeState( - Collections.emptyMap(), - Collections.emptyMap()); + public static final NodeState EMPTY_NODE = EmptyNodeState.EMPTY_NODE; private final Map properties; Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java Wed Mar 13 16:33:34 2013 @@ -29,6 +29,7 @@ import org.apache.jackrabbit.oak.spi.sta import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * Basic in-memory node store implementation. Useful as a base class for @@ -37,7 +38,7 @@ import static com.google.common.base.Pre public class MemoryNodeStore implements NodeStore { private final AtomicReference root = - new AtomicReference(MemoryNodeState.EMPTY_NODE); + new AtomicReference(EMPTY_NODE); @Override public NodeState getRoot() { Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ReadOnlyNodeTypeManager.java Wed Mar 13 16:33:34 2013 @@ -59,7 +59,6 @@ import org.apache.jackrabbit.oak.core.Re import org.apache.jackrabbit.oak.namepath.NameMapper; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeState; import static com.google.common.base.Preconditions.checkNotNull; @@ -68,6 +67,7 @@ import static org.apache.jackrabbit.JcrC import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.api.Type.STRING; import static org.apache.jackrabbit.oak.api.Type.STRINGS; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH; /** @@ -161,7 +161,7 @@ public abstract class ReadOnlyNodeTypeMa .getChild(NODE_TYPES_PATH.substring(1)).getTree(); final Tree types = tree == null - ? new ReadOnlyTree(MemoryNodeState.EMPTY_NODE) // No node types in content, use an empty node + ? new ReadOnlyTree(EMPTY_NODE) // No node types in content, use an empty node : tree; return new ReadOnlyNodeTypeManager() { Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java Wed Mar 13 16:33:34 2013 @@ -16,6 +16,8 @@ */ package org.apache.jackrabbit.oak.plugins.segment; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import java.util.Arrays; import javax.jcr.Node; @@ -24,8 +26,6 @@ import javax.jcr.Property; import javax.jcr.PropertyIterator; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -39,8 +39,7 @@ public class JcrImporter { } public NodeState writeNode(Node node) throws RepositoryException { - NodeBuilder builder = - new MemoryNodeBuilder(MemoryNodeState.EMPTY_NODE); + NodeBuilder builder = EMPTY_NODE.builder(); buildNode(builder, node); return writer.writeNode(builder.getNodeState()); } Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java Wed Mar 13 16:33:34 2013 @@ -17,12 +17,13 @@ package org.apache.jackrabbit.oak.plugins.segment; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import java.util.Collections; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentMap; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeState; import com.google.common.collect.Maps; @@ -39,7 +40,7 @@ public class MemoryStore implements Segm } public MemoryStore() { - this(MemoryNodeState.EMPTY_NODE); + this(EMPTY_NODE); } @Override Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java Wed Mar 13 16:33:34 2013 @@ -20,7 +20,7 @@ import static com.google.common.base.Pre import static com.google.common.collect.ImmutableMap.of; import static com.mongodb.ReadPreference.nearest; import static com.mongodb.ReadPreference.primary; -import static org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.EMPTY_NODE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import java.util.List; import java.util.Map; Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java Wed Mar 13 16:33:34 2013 @@ -17,11 +17,13 @@ package org.apache.jackrabbit.oak.plugins.segment; import static com.google.common.base.Preconditions.checkNotNull; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; import org.apache.jackrabbit.oak.spi.state.AbstractNodeState; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -114,7 +116,11 @@ class SegmentNodeState extends AbstractN @Override public void compareAgainstBaseState(NodeState base, NodeStateDiff diff) { - if (base instanceof SegmentNodeState) { + if (base == this) { + return; // no changes + } else if (base == EMPTY_NODE) { + EmptyNodeState.compareAgainstEmptyState(this, diff); // special case + } else if (base instanceof SegmentNodeState) { SegmentNodeState that = (SegmentNodeState) base; if (!recordId.equals(that.recordId)) { getTemplate().compareAgainstBaseState( Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java Wed Mar 13 16:33:34 2013 @@ -22,7 +22,6 @@ import javax.annotation.Nonnull; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; import org.apache.jackrabbit.oak.spi.commit.CommitHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -72,7 +71,7 @@ class SegmentNodeStoreBranch implements RecordId newBaseId = journal.getHead(); if (!baseId.equals(newBaseId)) { NodeBuilder builder = - new MemoryNodeBuilder(new SegmentNodeState(store, newBaseId)); + new SegmentNodeState(store, newBaseId).builder(); getHead().compareAgainstBaseState(getBase(), new RebaseDiff(builder)); this.baseId = newBaseId; this.rootId = writer.writeNode(builder.getNodeState()).getRecordId(); Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionHook.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionHook.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionHook.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionHook.java Wed Mar 13 16:33:34 2013 @@ -30,7 +30,6 @@ import org.apache.jackrabbit.oak.api.Pro import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.core.ReadOnlyTree; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.commit.CommitHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -39,6 +38,7 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; import static com.google.common.base.Preconditions.checkNotNull; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * TODO document @@ -135,7 +135,7 @@ public class VersionHook implements Comm @Override public void childNodeAdded(String name, NodeState after) { - childNodeChanged(name, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(name, EMPTY_NODE, after); } @Override @@ -154,7 +154,7 @@ public class VersionHook implements Comm if (NodeStateUtils.isHidden(name)) { return; } - NodeState after = MemoryNodeState.EMPTY_NODE; + NodeState after = EMPTY_NODE; after.compareAgainstBaseState(before, new VersionDiff(this, vMgr, after.builder())); } Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java Wed Mar 13 16:33:34 2013 @@ -16,6 +16,8 @@ */ package org.apache.jackrabbit.oak.plugins.version; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import javax.annotation.Nonnull; import org.apache.jackrabbit.JcrConstants; @@ -25,7 +27,6 @@ import org.apache.jackrabbit.oak.api.Tre import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.core.ImmutableTree; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.commit.CommitHook; import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff; @@ -88,7 +89,7 @@ public class VersionablePathHook impleme @Override public void childNodeAdded(String name, NodeState after) { - childNodeChanged(name, MemoryNodeState.EMPTY_NODE, after); + childNodeChanged(name, EMPTY_NODE, after); } @Override Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java Wed Mar 13 16:33:34 2013 @@ -31,7 +31,6 @@ import org.apache.jackrabbit.oak.commons import org.apache.jackrabbit.oak.core.ImmutableRoot; import org.apache.jackrabbit.oak.core.ImmutableTree; import org.apache.jackrabbit.oak.core.TreeImpl; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager; import org.apache.jackrabbit.oak.security.authorization.AccessControlConstants; @@ -50,6 +49,7 @@ import org.slf4j.LoggerFactory; import static com.google.common.base.Preconditions.checkNotNull; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * {@code CommitHook} implementation that processes any modification made to @@ -160,7 +160,7 @@ public class PermissionHook implements P if (isACE(name, after)) { addEntry(name, after); } else { - BeforeNode before = new BeforeNode(parentBefore.getPath(), name, MemoryNodeState.EMPTY_NODE); + BeforeNode before = new BeforeNode(parentBefore.getPath(), name, EMPTY_NODE); Node node = new Node(parentAfter, name); after.compareAgainstBaseState(before.getNodeState(), new Diff(before, node)); } @@ -185,7 +185,7 @@ public class PermissionHook implements P removeEntry(name, before); } else { BeforeNode nodeBefore = new BeforeNode(parentBefore.getPath(), name, before); - Node after = new Node(parentAfter.getPath(), name, MemoryNodeState.EMPTY_NODE); + Node after = new Node(parentAfter.getPath(), name, EMPTY_NODE); after.getNodeState().compareAgainstBaseState(before, new Diff(nodeBefore, after)); } } Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorHook.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorHook.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorHook.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/EditorHook.java Wed Mar 13 16:33:34 2013 @@ -26,7 +26,7 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; import static com.google.common.base.Preconditions.checkNotNull; -import static org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.EMPTY_NODE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * This commit hook implementation processes changes to be committed Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/JsopDiffTest.java Wed Mar 13 16:33:34 2013 @@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.spi.sta import org.junit.Test; import static junit.framework.Assert.assertEquals; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; public class JsopDiffTest { @@ -59,12 +60,11 @@ public class JsopDiffTest { @Test public void testNodeChanges() { JsopDiff diff; - NodeState before = MemoryNodeState.EMPTY_NODE; + NodeState before = EMPTY_NODE; NodeState after = new MemoryNodeState( ImmutableMap.of( "a", LongPropertyState.createLongProperty("a", 1L)), - ImmutableMap.of( - "x", MemoryNodeState.EMPTY_NODE)); + ImmutableMap.of("x", EMPTY_NODE)); diff = new JsopDiff(null); Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java Wed Mar 13 16:33:34 2013 @@ -20,6 +20,7 @@ import static com.google.common.collect. import static com.google.common.collect.Sets.newHashSet; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -30,7 +31,6 @@ import java.util.Set; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexHookProvider; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; @@ -40,7 +40,7 @@ public class IndexHookManagerDiffTest { @Test public void testIndexDefinitions() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); // this index is on the current update branch, it should be seen by the Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java Wed Mar 13 16:33:34 2013 @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -30,7 +31,6 @@ import org.apache.jackrabbit.oak.api.Pro import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexHookProvider; import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexLookup; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.query.PropertyValues; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -52,7 +52,7 @@ public class IndexHookManagerTest { */ @Test public void test() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); @@ -113,7 +113,7 @@ public class IndexHookManagerTest { */ @Test public void testReindex() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); @@ -155,7 +155,7 @@ public class IndexHookManagerTest { */ @Test public void testReindex2() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); @@ -196,7 +196,7 @@ public class IndexHookManagerTest { */ @Test public void testReindex3() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diffindex/DiffCollectorTest.java Wed Mar 13 16:33:34 2013 @@ -1,5 +1,6 @@ package org.apache.jackrabbit.oak.plugins.index.diffindex; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -7,7 +8,6 @@ import static org.junit.Assert.assertTru import java.util.Iterator; import java.util.Set; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.query.ast.Operator; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.spi.query.PropertyValues; @@ -19,7 +19,7 @@ public class DiffCollectorTest { @Test public void testUUID() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("a").setProperty("jcr:uuid", "abc"); @@ -43,7 +43,7 @@ public class DiffCollectorTest { @Test public void testUUIDInner() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("a").setProperty("jcr:uuid", "abc"); @@ -68,7 +68,7 @@ public class DiffCollectorTest { @Test public void testDeepChange() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); NodeBuilder b1 = builder.child("rep:security").child( Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java Wed Mar 13 16:33:34 2013 @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.plugins.index.p2; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -26,7 +27,6 @@ import java.util.Set; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.spi.query.Filter; import org.apache.jackrabbit.oak.spi.query.PropertyValues; @@ -46,7 +46,7 @@ public class Property2IndexTest { @Test public void testPropertyLookup() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -97,7 +97,7 @@ public class Property2IndexTest { @Test public void testCustomConfigPropertyLookup() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -146,7 +146,7 @@ public class Property2IndexTest { */ @Test public void testCustomConfigNodeType() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definitions NodeBuilder builder = root.builder(); @@ -209,7 +209,7 @@ public class Property2IndexTest { */ @Test public void testCustomConfigNodeTypeFallback() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definitions NodeBuilder builder = root.builder(); @@ -265,8 +265,7 @@ public class Property2IndexTest { @Test public void testUnique() throws Exception { - - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -300,8 +299,7 @@ public class Property2IndexTest { @Test public void testUniqueByTypeOK() throws Exception { - - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -329,8 +327,7 @@ public class Property2IndexTest { @Test public void testUniqueByTypeKO() throws Exception { - - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -364,8 +361,7 @@ public class Property2IndexTest { @Test public void testUniqueByTypeDelete() throws Exception { - - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java Wed Mar 13 16:33:34 2013 @@ -16,8 +16,9 @@ */ package org.apache.jackrabbit.oak.plugins.index.p2.strategy; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Assert; @@ -45,7 +46,7 @@ public class ContentMirrorStoreStrategyT public void testIndexPruning() throws Exception { IndexStoreStrategy store = new ContentMirrorStoreStrategy(); - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder index = root.builder(); store.insert(index, "key", false, Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java Wed Mar 13 16:33:34 2013 @@ -21,11 +21,11 @@ import java.util.Arrays; import com.google.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.junit.Assert.assertEquals; @Deprecated @@ -35,7 +35,7 @@ public class PropertyIndexTest { @Test public void testPropertyLookup() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); @@ -84,7 +84,7 @@ public class PropertyIndexTest { @Test public void testCustomConfigPropertyLookup() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; // Add index definition NodeBuilder builder = root.builder(); Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java Wed Mar 13 16:33:34 2013 @@ -16,12 +16,9 @@ */ package org.apache.jackrabbit.oak.plugins.memory; -import java.util.Collections; - -import com.google.common.collect.ImmutableMap; -import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.assertEquals; @@ -31,24 +28,27 @@ import static junit.framework.Assert.ass import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; import static org.apache.jackrabbit.oak.api.Type.STRING; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; public class MemoryNodeBuilderTest { - private static final NodeState BASE = new MemoryNodeState( - ImmutableMap.of( - "a", LongPropertyState.createLongProperty("a", 1L), - "b", LongPropertyState.createLongProperty("b", 2L), - "c", LongPropertyState.createLongProperty("c", 3L)), - ImmutableMap.of( - "x", new MemoryNodeState( - Collections.emptyMap(), - Collections.singletonMap("q", MemoryNodeState.EMPTY_NODE)), - "y", MemoryNodeState.EMPTY_NODE, - "z", MemoryNodeState.EMPTY_NODE)); + private NodeState base; + + @Before + public void setUp() { + NodeBuilder builder = EMPTY_NODE.builder(); + builder.setProperty("a", 1L); + builder.setProperty("b", 2L); + builder.setProperty("c", 3L); + builder.child("x").child("q"); + builder.child("y"); + builder.child("z"); + base = builder.getNodeState(); + } @Test public void testConnectOnAddProperty() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder childA = root.child("x"); NodeBuilder childB = root.child("x"); @@ -59,7 +59,7 @@ public class MemoryNodeBuilderTest { @Test public void testConnectOnUpdateProperty() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder childA = root.child("x"); NodeBuilder childB = root.child("x"); @@ -72,7 +72,7 @@ public class MemoryNodeBuilderTest { @Test public void testConnectOnRemoveProperty() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder childA = root.child("x"); NodeBuilder childB = root.child("x"); @@ -89,7 +89,7 @@ public class MemoryNodeBuilderTest { @Test public void testConnectOnAddNode() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder childA = root.child("x"); NodeBuilder childB = root.child("x"); @@ -104,7 +104,7 @@ public class MemoryNodeBuilderTest { @Test public void testReadOnRemoveNode() { for (String name : new String[] {"x", "new"}) { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder child = root.child(name); root.removeNode(name); @@ -123,7 +123,7 @@ public class MemoryNodeBuilderTest { @Test public void testWriteOnRemoveNode() { for (String name : new String[] {"x", "new"}) { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder child = root.child(name); root.removeNode(name); @@ -141,7 +141,7 @@ public class MemoryNodeBuilderTest { @Test public void testAddRemovedNodeAgain() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); root.removeNode("x"); NodeBuilder x = root.child("x"); @@ -152,39 +152,39 @@ public class MemoryNodeBuilderTest { @Test public void testReset() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder child = root.child("x"); child.child("new"); assertTrue(child.hasChildNode("new")); assertTrue(root.child("x").hasChildNode("new")); - root.reset(BASE); + root.reset(base); assertFalse(child.hasChildNode("new")); assertFalse(root.child("x").hasChildNode("new")); } @Test public void testReset2() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder x = root.child("x"); x.child("y"); - root.reset(BASE); + root.reset(base); assertTrue(root.hasChildNode("x")); assertFalse(x.hasChildNode("y")); } @Test public void testUnmodifiedEqualsBase() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder x = root.child("x"); assertEquals(x.getBaseState(), x.getNodeState()); } @Test(expected = IllegalStateException.class) public void testReadOnRemovedNode() { - NodeBuilder root = new MemoryNodeBuilder(BASE); + NodeBuilder root = base.builder(); NodeBuilder m = root.child("m"); NodeBuilder n = m.child("n"); Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java Wed Mar 13 16:33:34 2013 @@ -16,10 +16,11 @@ */ package org.apache.jackrabbit.oak.plugins.name; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import java.util.Collections; import org.apache.jackrabbit.oak.api.CommitFailedException; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.commit.Validator; import org.junit.Test; @@ -30,51 +31,51 @@ public class NameValidatorTest { @Test(expected = CommitFailedException.class) public void testCurrentPath() throws CommitFailedException { - validator.childNodeAdded(".", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded(".", EMPTY_NODE); } @Test(expected = CommitFailedException.class) public void testParentPath() throws CommitFailedException { - validator.childNodeAdded("..", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("..", EMPTY_NODE); } @Test // valid as of OAK-182 public void testEmptyPrefix() throws CommitFailedException { - validator.childNodeAdded(":name", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded(":name", EMPTY_NODE); } @Test(expected = CommitFailedException.class) public void testInvalidPrefix() throws CommitFailedException { - validator.childNodeAdded("invalid:name", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("invalid:name", EMPTY_NODE); } @Test public void testValidPrefix() throws CommitFailedException { - validator.childNodeAdded("valid:name", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("valid:name", EMPTY_NODE); } @Test(expected = CommitFailedException.class) public void testSlashName() throws CommitFailedException { - validator.childNodeAdded("invalid/name", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("invalid/name", EMPTY_NODE); } @Test(expected = CommitFailedException.class) public void testIndexInName() throws CommitFailedException { - validator.childNodeAdded("name[1]", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("name[1]", EMPTY_NODE); } @Test public void testValidName() throws CommitFailedException { - validator.childNodeAdded("name", MemoryNodeState.EMPTY_NODE); + validator.childNodeAdded("name", EMPTY_NODE); } @Test public void testDeleted() throws CommitFailedException { - validator.childNodeDeleted(".", MemoryNodeState.EMPTY_NODE); - validator.childNodeDeleted("..", MemoryNodeState.EMPTY_NODE); - validator.childNodeDeleted("valid:name", MemoryNodeState.EMPTY_NODE); - validator.childNodeDeleted("invalid:name", MemoryNodeState.EMPTY_NODE); - validator.childNodeDeleted("invalid/name", MemoryNodeState.EMPTY_NODE); + validator.childNodeDeleted(".", EMPTY_NODE); + validator.childNodeDeleted("..", EMPTY_NODE); + validator.childNodeDeleted("valid:name", EMPTY_NODE); + validator.childNodeDeleted("invalid:name", EMPTY_NODE); + validator.childNodeDeleted("invalid/name", EMPTY_NODE); } } Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java Wed Mar 13 16:33:34 2013 @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.plugins.segment; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; @@ -35,7 +36,7 @@ public class CompareAgainstBaseStateTest private final NodeStateDiff diff = EasyMock.createMock(NodeStateDiff.class); - private final NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + private final NodeBuilder builder = EMPTY_NODE.builder(); @Before public void setUp() { Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/RecordTest.java Wed Mar 13 16:33:34 2013 @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.plugins.segment; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.apache.jackrabbit.oak.plugins.segment.ListRecord.LEVEL_SIZE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -32,7 +33,6 @@ import java.util.List; import java.util.Map; import java.util.Random; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; @@ -263,7 +263,7 @@ public class RecordTest { @Test public void testEmptyNode() { - NodeState before = MemoryNodeState.EMPTY_NODE; + NodeState before = EMPTY_NODE; NodeState after = writer.writeNode(before); writer.flush(); assertEquals(before, after); @@ -271,7 +271,7 @@ public class RecordTest { @Test public void testSimpleNode() { - NodeState before = MemoryNodeState.EMPTY_NODE.builder() + NodeState before = EMPTY_NODE.builder() .setProperty("foo", "abc") .setProperty("bar", 123) .setProperty("baz", Math.PI) @@ -283,7 +283,7 @@ public class RecordTest { @Test public void testDeepNode() { - NodeBuilder root = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder root = EMPTY_NODE.builder(); NodeBuilder builder = root; for (int i = 0; i < 1000; i++) { builder = builder.child("test"); @@ -296,7 +296,7 @@ public class RecordTest { @Test public void testManyMapDeletes() { - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); for (int i = 0; i < 1000; i++) { builder.child("test" + i); } Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentSizeTest.java Wed Mar 13 16:33:34 2013 @@ -17,12 +17,12 @@ package org.apache.jackrabbit.oak.plugins.segment; import static junit.framework.Assert.assertEquals; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import java.util.Calendar; import java.util.Collections; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -38,27 +38,27 @@ public class SegmentSizeTest { @Test public void testNodeSize() { - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); assertEquals(8, getSize(builder)); assertEquals(4, getAmortizedSize(builder)); - builder = MemoryNodeState.EMPTY_NODE.builder(); + builder = EMPTY_NODE.builder(); builder.setProperty("foo", "bar"); assertEquals(24, getSize(builder)); assertEquals(8, getAmortizedSize(builder)); - builder = MemoryNodeState.EMPTY_NODE.builder(); + builder = EMPTY_NODE.builder(); builder.setProperty("foo", "bar"); builder.setProperty("baz", 123); assertEquals(40, getSize(builder)); assertEquals(12, getAmortizedSize(builder)); - builder = MemoryNodeState.EMPTY_NODE.builder(); + builder = EMPTY_NODE.builder(); builder.child("foo"); assertEquals(28, getSize(builder)); assertEquals(12, getAmortizedSize(builder)); - builder = MemoryNodeState.EMPTY_NODE.builder(); + builder = EMPTY_NODE.builder(); builder.child("foo"); builder.child("bar"); assertEquals(56, getSize(builder)); @@ -69,7 +69,7 @@ public class SegmentSizeTest { public void testDuplicateStrings() { String string = "More than just a few bytes of example content."; - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); builder.setProperty(PropertyStates.createProperty( "test", Collections.nCopies(1, string), Type.STRINGS)); int base = getSize(builder); @@ -87,7 +87,7 @@ public class SegmentSizeTest { public void testDuplicateDates() { String now = ISO8601.format(Calendar.getInstance()); - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); builder.setProperty(PropertyStates.createProperty( "test", Collections.nCopies(1, now), Type.DATES)); int base = getSize(builder); @@ -103,7 +103,7 @@ public class SegmentSizeTest { @Test public void testAccessControlNodes() { - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); builder.setProperty("jcr:primaryType", "rep:ACL", Type.NAME); assertEquals(20, getSize(builder)); assertEquals(4, getAmortizedSize(builder)); @@ -147,7 +147,7 @@ public class SegmentSizeTest { SegmentStore store = new MemoryStore(); SegmentWriter writer = new SegmentWriter(store); - NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder(); + NodeBuilder builder = EMPTY_NODE.builder(); for (int i = 0; i < 1000; i++) { builder.child("child" + i); } Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidatorTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidatorTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidatorTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidatorTest.java Wed Mar 13 16:33:34 2013 @@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.spi.co import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; -import static org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.EMPTY_NODE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.junit.Test; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDiff.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDiff.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDiff.java Wed Mar 13 16:33:34 2013 @@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.commons.PathUtils.concat; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import java.io.IOException; import java.util.HashMap; @@ -27,7 +28,6 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; @@ -151,7 +151,7 @@ public class LuceneIndexDiff implements for (LuceneIndexUpdate update : updates.values()) { update.insert(concat(getPath(), name), new ReadOnlyBuilder(after)); } - after.compareAgainstBaseState(MemoryNodeState.EMPTY_NODE, child(name)); + after.compareAgainstBaseState(EMPTY_NODE, child(name)); } @Override @@ -191,7 +191,7 @@ public class LuceneIndexDiff implements } if (reindex) { state.getNodeState().compareAgainstBaseState( - MemoryNodeState.EMPTY_NODE, + EMPTY_NODE, new LuceneIndexDiff(null, state, null, "/", updates)); } } Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java Wed Mar 13 16:33:34 2013 @@ -20,11 +20,11 @@ import static junit.framework.Assert.ass import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import org.apache.jackrabbit.oak.plugins.index.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.IndexDefinitionImpl; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.query.ast.Operator; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.spi.query.Cursor; @@ -39,7 +39,7 @@ public class LuceneIndexTest implements @Test public void testLucene() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("lucene") @@ -70,7 +70,7 @@ public class LuceneIndexTest implements @Test public void testLucene2() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("lucene") Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiff.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiff.java (original) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiff.java Wed Mar 13 16:33:34 2013 @@ -24,7 +24,6 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexHook; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration; import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -35,6 +34,7 @@ import org.apache.solr.client.solrj.Solr import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.commons.PathUtils.concat; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; /** * {@link IndexHook} implementation that is responsible for keeping the @@ -159,7 +159,7 @@ public class SolrIndexDiff implements In for (SolrIndexUpdate update : updates.values()) { update.insert(concat(getPath(), name), new ReadOnlyBuilder(after)); } - after.compareAgainstBaseState(MemoryNodeState.EMPTY_NODE, child(name)); + after.compareAgainstBaseState(EMPTY_NODE, child(name)); } @Override @@ -199,7 +199,7 @@ public class SolrIndexDiff implements In } if (reindex) { state.getNodeState().compareAgainstBaseState( - MemoryNodeState.EMPTY_NODE, + EMPTY_NODE, new SolrIndexDiff(null, state, solrServer, null, "/", updates, configuration)); } } Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiffIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiffIT.java?rev=1456040&r1=1456039&r2=1456040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiffIT.java (original) +++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexDiffIT.java Wed Mar 13 16:33:34 2013 @@ -20,7 +20,6 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.IndexDefinitionImpl; import org.apache.jackrabbit.oak.plugins.index.IndexHook; import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexDiff; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState; import org.apache.jackrabbit.oak.query.ast.Operator; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.plugins.index.solr.SolrBaseTest; @@ -39,12 +38,13 @@ import static junit.framework.Assert.ass import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; public class SolrIndexDiffIT extends SolrBaseTest { @Test public void testSingleNodeCreation() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("solr") @@ -78,7 +78,7 @@ public class SolrIndexDiffIT extends Sol @Test public void testPropertyAddition() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("solr") @@ -113,7 +113,7 @@ public class SolrIndexDiffIT extends Sol @Test public void testSomeNodesCreationWithFullText() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("solr") @@ -152,7 +152,7 @@ public class SolrIndexDiffIT extends Sol @Test public void testSomeNodesCreationWithDescendant() throws Exception { - NodeState root = MemoryNodeState.EMPTY_NODE; + NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); builder.child("oak:index").child("solr")