jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1547233 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/memory/ plugins/name/ plugins/segment/ spi/state/
Date Mon, 02 Dec 2013 22:51:15 GMT
Author: jukka
Date: Mon Dec  2 22:51:14 2013
New Revision: 1547233

URL: http://svn.apache.org/r1547233
Log:
OAK-924: Optimize namespace lookups

Optimize the access of prefix information in the name validator

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorProvider.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/spi/state/AbstractNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java

Modified: 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=1547233&r1=1547232&r2=1547233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
Mon Dec  2 22:51:14 2013
@@ -80,6 +80,11 @@ public final class EmptyNodeState implem
         return null;
     }
 
+    @Override
+    public Iterable<String> getStrings(String name) {
+        return emptyList();
+    }
+
     @Override @CheckForNull
     public String getName(@Nonnull String name) {
         return null;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java?rev=1547233&r1=1547232&r2=1547233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidator.java
Mon Dec  2 22:51:14 2013
@@ -20,7 +20,6 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.core.ImmutableTree;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -35,10 +34,6 @@ class NameValidator extends DefaultValid
 
     private final Set<String> prefixes;
 
-    public NameValidator(NodeState root) {
-        this.prefixes = Namespaces.getNamespacePrefixesAsSet(new ImmutableTree(root));
-    }
-
     NameValidator(Set<String> prefixes) {
         this.prefixes = prefixes;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorProvider.java?rev=1547233&r1=1547232&r2=1547233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorProvider.java
Mon Dec  2 22:51:14 2013
@@ -16,6 +16,12 @@
  */
 package org.apache.jackrabbit.oak.plugins.name;
 
+import static com.google.common.collect.Sets.newHashSet;
+import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.oak.plugins.name.NamespaceConstants.NSDATA;
+import static org.apache.jackrabbit.oak.plugins.name.NamespaceConstants.NSDATA_PREFIXES;
+import static org.apache.jackrabbit.oak.plugins.name.NamespaceConstants.REP_NAMESPACES;
+
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
@@ -34,7 +40,11 @@ public class NameValidatorProvider exten
 
     @Override
     public Validator getRootValidator(NodeState before, NodeState after) {
-        return new NameValidator(after);
+        return new NameValidator(newHashSet(after
+                .getChildNode(JCR_SYSTEM)
+                .getChildNode(REP_NAMESPACES)
+                .getChildNode(NSDATA)
+                .getString(NSDATA_PREFIXES)));
     }
 
 }

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=1547233&r1=1547232&r2=1547233&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
Mon Dec  2 22:51:14 2013
@@ -173,6 +173,11 @@ public class SegmentNodeState extends Re
     }
 
     @Override
+    public Iterable<String> getStrings(String name) {
+        return AbstractNodeState.getStrings(this, name);
+    }
+
+    @Override
     public String getName(String name) {
         return AbstractNodeState.getName(this, name);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java?rev=1547233&r1=1547232&r2=1547233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
Mon Dec  2 22:51:14 2013
@@ -22,6 +22,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -75,6 +76,15 @@ public abstract class AbstractNodeState 
         }
     }
 
+    public static Iterable<String> getStrings(NodeState state, String name) {
+        PropertyState property = state.getProperty(name);
+        if (property != null && property.getType() == STRINGS) {
+            return property.getValue(STRINGS);
+        } else {
+            return emptyList();
+        }
+    }
+
     public static String getName(NodeState state, String name) {
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == NAME) {
@@ -215,6 +225,11 @@ public abstract class AbstractNodeState 
         return getString(this, name);
     }
 
+    @Override
+    public Iterable<String> getStrings(String name) {
+        return getStrings(this, name);
+    }
+
     @Override @CheckForNull
     public String getName(@Nonnull String name) {
         return getName(this, name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java?rev=1547233&r1=1547232&r2=1547233&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
Mon Dec  2 22:51:14 2013
@@ -207,6 +207,24 @@ public interface NodeState {
     String getString(String name);
 
     /**
+     * Returns the string values of the named property. The implementation
+     * is equivalent to the following code, but may be optimized.
+     * <pre>
+     * PropertyState property = state.getProperty(name);
+     * if (property != null && property.getType() == Type.STRINGS) {
+     *     return property.getValue(Type.STRINGS);
+     * } else {
+     *     return Collections.emptyList();
+     * }
+     * </pre>
+     *
+     * @param name property name
+     * @return string values of the named property, or an empty collection
+     */
+    @Nonnull
+    Iterable<String> getStrings(@Nonnull String name);
+
+    /**
      * Returns the name value of the named property. The implementation
      * is equivalent to the following code, but may be optimized.
      * <pre>



Mime
View raw message