jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1549915 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/main/j...
Date Tue, 10 Dec 2013 18:20:55 GMT
Author: jukka
Date: Tue Dec 10 18:20:54 2013
New Revision: 1549915

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

Replace type-specific IndexUtils property getters with those in NodeState and NodeBuilder

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.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/spi/state/NodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
Tue Dec 10 18:20:54 2013
@@ -18,11 +18,13 @@ package org.apache.jackrabbit.oak.core;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import com.google.common.base.Predicate;
+
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
@@ -43,6 +45,7 @@ import static java.util.Collections.empt
 import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 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;
 
 class SecureNodeBuilder implements NodeBuilder, FastCopyMove {
 
@@ -228,6 +231,16 @@ class SecureNodeBuilder implements NodeB
     }
 
     @Override @CheckForNull
+    public String getString(@Nonnull String name) {
+        PropertyState property = getProperty(name);
+        if (property != null && property.getType() == STRING) {
+            return property.getValue(STRING);
+        } else {
+            return null;
+        }
+    }
+
+    @Override @CheckForNull
     public String getName(@Nonnull String name) {
         PropertyState property = getProperty(name);
         if (property != null && property.getType() == NAME) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdate.java
Tue Dec 10 18:20:54 2013
@@ -23,8 +23,6 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 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.IndexUtils.getBoolean;
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getString;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.MISSING_NODE;
 
 import java.util.List;
@@ -101,13 +99,13 @@ class IndexUpdate implements Editor {
             throws CommitFailedException {
         for (String name : definitions.getChildNodeNames()) {
             NodeBuilder definition = definitions.getChildNode(name);
-            if (Objects.equal(async, getString(definition, ASYNC_PROPERTY_NAME))) {
-                String type = getString(definition, TYPE_PROPERTY_NAME);
+            if (Objects.equal(async, definition.getString(ASYNC_PROPERTY_NAME))) {
+                String type = definition.getString(TYPE_PROPERTY_NAME);
                 Editor editor = provider.getIndexEditor(type, definition, root);
                 if (editor == null) {
                     // trigger reindexing when an indexer becomes available
                     definition.setProperty(REINDEX_PROPERTY_NAME, true);
-                } else if (getBoolean(definition, REINDEX_PROPERTY_NAME)) {
+                } else if (definition.getBoolean(REINDEX_PROPERTY_NAME)) {
                     definition.setProperty(REINDEX_PROPERTY_NAME, false);
                     // as we don't know the index content node name
                     // beforehand, we'll remove all child nodes

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
Tue Dec 10 18:20:54 2013
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
-import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 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;
@@ -141,46 +140,4 @@ public class IndexUtils {
                 && type.getValue(Type.STRING).equals(typeIn);
     }
 
-    public static String getString(NodeBuilder builder, String name) {
-        PropertyState property = builder.getProperty(name);
-        if (property != null && property.getType() == STRING) {
-            return property.getValue(STRING);
-        }
-        if (property != null && property.getType() == NAME) {
-            return property.getValue(NAME);
-        }
-        return null;
-    }
-
-    public static String getString(NodeState state, String name) {
-        PropertyState property = state.getProperty(name);
-        if (property != null && property.getType() == STRING) {
-            return property.getValue(STRING);
-        }
-        if (property != null && property.getType() == NAME) {
-            return property.getValue(NAME);
-        }
-        return null;
-    }
-
-    public static boolean getBoolean(NodeBuilder builder, String name) {
-        PropertyState property = builder.getProperty(name);
-        return property != null && property.getType() == BOOLEAN
-                && property.getValue(BOOLEAN);
-    }
-
-    public static boolean getBoolean(NodeState state, String name) {
-        PropertyState property = state.getProperty(name);
-        return property != null && property.getType() == BOOLEAN
-                && property.getValue(BOOLEAN);
-    }
-
-    public static NodeBuilder getChildOrNull(NodeBuilder node, String name) {
-        if (node != null && node.hasChildNode(name)) {
-            return node.child(name);
-        } else {
-            return null;
-        }
-    }
-
 }

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=1549915&r1=1549914&r2=1549915&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
Tue Dec 10 18:20:54 2013
@@ -23,11 +23,13 @@ import static java.util.Collections.empt
 import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 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.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import com.google.common.base.Objects;
@@ -421,7 +423,17 @@ public class MemoryNodeBuilder implement
                 && property.getValue(BOOLEAN);
     }
 
-    @Override
+    @Override @CheckForNull
+    public String getString(@Nonnull String name) {
+        PropertyState property = getProperty(name);
+        if (property != null && property.getType() == STRING) {
+            return property.getValue(STRING);
+        } else {
+            return null;
+        }
+    }
+
+    @Override @CheckForNull
     public String getName(@Nonnull String name) {
         PropertyState property = getProperty(name);
         if (property != null && property.getType() == NAME) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
Tue Dec 10 18:20:54 2013
@@ -320,6 +320,24 @@ public interface NodeBuilder {
      * is equivalent to the following code, but may be optimized.
      * <pre>
      * PropertyState property = builder.getProperty(name);
+     * if (property != null && property.getType() == Type.STRING) {
+     *     return property.getValue(Type.STRING);
+     * } else {
+     *     return null;
+     * }
+     * </pre>
+     *
+     * @param name property name
+     * @return string value of the named property, or {@code null}
+     */
+    @CheckForNull
+    String getString(String name);
+
+    /**
+     * Returns the name value of the named property. The implementation
+     * is equivalent to the following code, but may be optimized.
+     * <pre>
+     * PropertyState property = builder.getProperty(name);
      * if (property != null && property.getType() == Type.NAME) {
      *     return property.getValue(Type.NAME);
      * } else {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
Tue Dec 10 18:20:54 2013
@@ -146,6 +146,11 @@ public class ReadOnlyBuilder implements 
     }
 
     @Override @CheckForNull
+    public String getString(@Nonnull String name) {
+        return state.getString(name);
+    }
+
+    @Override @CheckForNull
     public String getName(@Nonnull String name) {
         return state.getName(name);
     }

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Tue Dec 10 18:20:54 2013
@@ -20,7 +20,6 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getString;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldNames.PATH;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldNames.PATH_SELECTOR;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_DATA_CHILD_NAME;
@@ -237,13 +236,13 @@ public class LuceneIndex implements Full
         if (def == null) {
             return false;
         }
-        String type = getString(def, PERSISTENCE_NAME);
+        String type = def.getString(PERSISTENCE_NAME);
         if (type == null || PERSISTENCE_OAK.equalsIgnoreCase(type)) {
             return getIndexDataNode(def) != null;
         }
 
         if (PERSISTENCE_FILE.equalsIgnoreCase(type)) {
-            return getString(def, PERSISTENCE_PATH) != null;
+            return def.getString(PERSISTENCE_PATH) != null;
         }
 
         return false;
@@ -255,7 +254,7 @@ public class LuceneIndex implements Full
             return null;
         }
 
-        String type = getString(def, PERSISTENCE_NAME);
+        String type = def.getString(PERSISTENCE_NAME);
         if (type == null || PERSISTENCE_OAK.equalsIgnoreCase(type)) {
             NodeState index = getIndexDataNode(def);
             if (index == null) {
@@ -265,7 +264,7 @@ public class LuceneIndex implements Full
         }
 
         if (PERSISTENCE_FILE.equalsIgnoreCase(type)) {
-            String fs = getString(def, PERSISTENCE_PATH);
+            String fs = def.getString(PERSISTENCE_PATH);
             if (fs == null) {
                 return null;
             }
@@ -288,7 +287,7 @@ public class LuceneIndex implements Full
         NodeState state = node.getChildNode(INDEX_DEFINITIONS_NAME);
         for (ChildNodeEntry entry : state.getChildNodeEntries()) {
             NodeState ns = entry.getNodeState();
-            if (TYPE_LUCENE.equals(getString(ns, TYPE_PROPERTY_NAME))) {
+            if (TYPE_LUCENE.equals(ns.getString(TYPE_PROPERTY_NAME))) {
                 return ns;
             }
         }

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
Tue Dec 10 18:20:54 2013
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugin
 import static org.apache.jackrabbit.JcrConstants.JCR_DATA;
 import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getString;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newFulltextField;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPathField;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPropertyField;
@@ -208,11 +207,11 @@ public class LuceneIndexEditor implement
             Document doc, PropertyState property, NodeState state) {
         Metadata metadata = new Metadata();
         if (JCR_DATA.equals(property.getName())) {
-            String type = getString(state, JcrConstants.JCR_MIMETYPE);
+            String type = state.getString(JcrConstants.JCR_MIMETYPE);
             if (type != null) { // not mandatory
                 metadata.set(Metadata.CONTENT_TYPE, type);
             }
-            String encoding = getString(state, JcrConstants.JCR_ENCODING);
+            String encoding = state.getString(JcrConstants.JCR_ENCODING);
             if (encoding != null) { // not mandatory
                 metadata.set(Metadata.CONTENT_ENCODING, encoding);
             }

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java?rev=1549915&r1=1549914&r2=1549915&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorContext.java
Tue Dec 10 18:20:54 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
-import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getString;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.EXCLUDE_PROPERTY_NAMES;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_TYPES;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_DATA_CHILD_NAME;
@@ -67,7 +66,7 @@ public class LuceneIndexEditorContext {
 
     private static Directory newIndexDirectory(NodeBuilder definition)
             throws IOException {
-        String path = getString(definition, PERSISTENCE_PATH);
+        String path = definition.getString(PERSISTENCE_PATH);
         if (path == null) {
             return new OakDirectory(definition.child(INDEX_DATA_CHILD_NAME));
         } else {



Mime
View raw message