jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1401643 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/index/ main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ main/java/org/apache/jackrabbit/oak/plugins/index/old/ test/java/org/apache/jackr...
Date Wed, 24 Oct 2012 12:18:30 GMT
Author: alexparvulescu
Date: Wed Oct 24 12:18:29 2012
New Revision: 1401643

URL: http://svn.apache.org/viewvc?rev=1401643&view=rev
Log:
OAK-178 Query: index definition documentation and tooling

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinitionImpl.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/index/lucene/LuceneEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneReindexHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
Wed Oct 24 12:18:29 2012
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.plugin
 
 public interface IndexConstants {
 
+    String INDEX_DEFINITIONS_NODE_TYPE = "oak:queryIndexDefinition";
+
     String INDEX_DEFINITIONS_NAME = "oak:index";
 
     String TYPE_PROPERTY_NAME = "type";
@@ -28,6 +30,7 @@ public interface IndexConstants {
 
     String INDEX_DATA_CHILD_NAME = ":data";
 
+    //TODO remove this property as soon as the index manager is in
     String DEFAULT_INDEX_HOME = "/";
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinition.java
Wed Oct 24 12:18:29 2012
@@ -18,8 +18,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import javax.annotation.Nonnull;
 
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-
 /**
  * Defines an index definition
  * 
@@ -46,15 +44,4 @@ public interface IndexDefinition {
     @Nonnull
     String getType();
 
-    /**
-     * @return flag marking if reindexing is required on this index
-     */
-    boolean isReindex();
-
-    /**
-     * @return the state that this definition is built on
-     */
-    @Nonnull
-    NodeState getState();
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinitionImpl.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinitionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexDefinitionImpl.java
Wed Oct 24 12:18:29 2012
@@ -16,23 +16,16 @@
  */
 package org.apache.jackrabbit.oak.plugins.index;
 
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-
 public class IndexDefinitionImpl implements IndexDefinition, IndexConstants {
 
     private final String name;
     private final String type;
     private final String path;
-    private final NodeState state;
 
-    public IndexDefinitionImpl(String name, String type, String path,
-            NodeState state) {
+    public IndexDefinitionImpl(String name, String type, String path) {
         this.name = name;
         this.type = type;
         this.path = path;
-        this.state = state;
     }
 
     @Override
@@ -51,28 +44,18 @@ public class IndexDefinitionImpl impleme
     }
 
     @Override
-    public boolean isReindex() {
-        PropertyState ps = state.getProperty(REINDEX_PROPERTY_NAME);
-        return ps != null && ps.getValue(Type.BOOLEAN);
-    }
-
-    @Override
-    public NodeState getState() {
-        return state;
-    }
-
-    @Override
     public String toString() {
         return "IndexDefinitionImpl [name=" + name + ", type=" + type
-                + ", path=" + path + ", reindex=" + isReindex() + ", state="
-                + state + "]";
+                + ", path=" + path + "]";
     }
 
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((path == null) ? 0 : path.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
         return result;
     }
 
@@ -85,12 +68,21 @@ public class IndexDefinitionImpl impleme
         if (getClass() != obj.getClass())
             return false;
         IndexDefinitionImpl other = (IndexDefinitionImpl) obj;
-        if (state == null) {
-            if (other.state != null)
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (path == null) {
+            if (other.path != null)
                 return false;
-        } else if (!state.equals(other.state))
+        } else if (!path.equals(other.path))
+            return false;
+        if (type == null) {
+            if (other.type != null)
+                return false;
+        } else if (!type.equals(other.type))
             return false;
         return true;
     }
-
 }

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=1401643&r1=1401642&r2=1401643&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
Wed Oct 24 12:18:29 2012
@@ -72,7 +72,7 @@ public class IndexUtils implements Index
         if (typeFilter != null && !typeFilter.equals(type)) {
             return null;
         }
-        return new IndexDefinitionImpl(name, type, concat(path, name), ns);
+        return new IndexDefinitionImpl(name, type, concat(path, name));
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneEditor.java
Wed Oct 24 12:18:29 2012
@@ -30,7 +30,6 @@ import org.apache.jackrabbit.oak.api.Blo
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -72,10 +71,10 @@ class LuceneEditor implements CommitHook
         }
     }
 
-    private final IndexDefinition index;
+    private final String path;
 
-    public LuceneEditor(IndexDefinition indexDefinition) {
-        this.index = indexDefinition;
+    public LuceneEditor(String path) {
+        this.path = path;
     }
 
     @Override
@@ -83,7 +82,7 @@ class LuceneEditor implements CommitHook
             throws CommitFailedException {
         NodeBuilder rootBuilder = after.builder();
         NodeBuilder builder = rootBuilder;
-        for (String name : elements(index.getPath())) {
+        for (String name : elements(path)) {
             builder = builder.child(name);
         }
         builder = builder.child(INDEX_DATA_CHILD_NAME);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneHook.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneHook.java
Wed Oct 24 12:18:29 2012
@@ -42,7 +42,7 @@ public class LuceneHook implements Commi
         List<IndexDefinition> indexDefinitions = buildIndexDefinitions(after,
                 indexConfigPath, TYPE_LUCENE);
         for (IndexDefinition def : indexDefinitions) {
-            hooks.add(new LuceneEditor(def));
+            hooks.add(new LuceneEditor(def.getPath()));
         }
         return CompositeHook.compose(hooks).processCommit(before, after);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneReindexHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneReindexHook.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneReindexHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneReindexHook.java
Wed Oct 24 12:18:29 2012
@@ -64,10 +64,6 @@ public class LuceneReindexHook implement
             if (!defsBefore.contains(def)) {
                 defsChanged.add(def);
             }
-            // verify reindex flag
-            if (def.isReindex()) {
-                defsChanged.add(def);
-            }
         }
         if (defsChanged.isEmpty()) {
             return after;
@@ -79,7 +75,7 @@ public class LuceneReindexHook implement
         // TODO buffer content reindex
         List<CommitHook> hooks = new ArrayList<CommitHook>();
         for (IndexDefinition def : defsChanged) {
-            hooks.add(new LuceneEditor(def));
+            hooks.add(new LuceneEditor(def.getPath()));
         }
         NodeState done = CompositeHook.compose(hooks).processCommit(
                 MemoryNodeState.EMPTY_NODE, after);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexConstants.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexConstants.java
Wed Oct 24 12:18:29 2012
@@ -26,7 +26,7 @@ public interface PropertyIndexConstants 
      * The root node of the index definition (configuration) nodes.
      */
     // TODO OAK-178 discuss where to store index config data
-    String INDEX_CONFIG_PATH = IndexUtils.DEFAULT_INDEX_HOME + IndexUtils.INDEX_DEFINITIONS_NAME
+ "/indexes";
+    String INDEX_CONFIG_PATH = "/" + IndexUtils.INDEX_DEFINITIONS_NAME + "/indexes";
     // "/jcr:system/indexes";
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/old/PropertyIndexer.java
Wed Oct 24 12:18:29 2012
@@ -35,7 +35,7 @@ import org.apache.jackrabbit.oak.spi.sta
 public class PropertyIndexer implements QueryIndexProvider, CommitHook,
         PropertyIndexConstants {
 
-    private final String indexConfigPath = IndexUtils.DEFAULT_INDEX_HOME;
+    private final String indexConfigPath = "/";
 
     private final Indexer indexer;
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Wed Oct 24 12:18:29 2012
@@ -41,15 +41,17 @@ import org.junit.Test;
 
 public class LuceneIndexTest implements LuceneIndexConstants {
 
+    private static String DEFAULT_INDEX_NAME = "default-lucene";
+
     @Test
     public void testLucene() throws Exception {
         KernelNodeStore store = new KernelNodeStore(new MicroKernelImpl());
 
         IndexDefinition testID = new IndexDefinitionImpl(DEFAULT_INDEX_NAME,
-                TYPE_LUCENE, DEFAULT_INDEX_HOME + INDEX_DEFINITIONS_NAME + "/"
-                        + DEFAULT_INDEX_NAME, store.getRoot());
+                TYPE_LUCENE, "/" + INDEX_DEFINITIONS_NAME + "/"
+                        + DEFAULT_INDEX_NAME);
 
-        store.setHook(new LuceneEditor(testID));
+        store.setHook(new LuceneEditor(testID.getPath()));
         Root root = new RootImpl(store, null, new Subject(),
                 new AccessControlProviderImpl(),
                 new CompositeQueryIndexProvider());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1401643&r1=1401642&r2=1401643&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Wed Oct 24 12:18:29 2012
@@ -47,8 +47,8 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.DEFAULT_INDEX_HOME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+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.index.IndexConstants.TYPE_PROPERTY_NAME;
 import static org.junit.Assert.assertEquals;
@@ -60,9 +60,8 @@ import static org.junit.Assert.fail;
  */
 public abstract class AbstractQueryTest {
 
+    public static final String TEST_INDEX_HOME = "/";
     protected static final String TEST_INDEX_NAME = "test-index";
-    protected static final String TEST_INDEX_HOME = DEFAULT_INDEX_HOME;
-    protected static final String INDEX_DEFINITION_NODE_TYPE = "nam:oak:queryIndexDefinition";
 
     protected SessionQueryEngine qe;
     protected ContentSession session;
@@ -102,7 +101,7 @@ public abstract class AbstractQueryTest 
         indexDef = indexDef.addChild(INDEX_DEFINITIONS_NAME).addChild(
                 TEST_INDEX_NAME);
         indexDef.setProperty(JcrConstants.JCR_PRIMARYTYPE,
-                INDEX_DEFINITION_NODE_TYPE);
+                INDEX_DEFINITIONS_NODE_TYPE, Type.NAME);
         indexDef.setProperty(TYPE_PROPERTY_NAME, type);
         indexDef.setProperty(REINDEX_PROPERTY_NAME, true);
         return indexDef;



Mime
View raw message