jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1393639 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/lucene/ plugins/type/ spi/query/
Date Wed, 03 Oct 2012 18:02:38 GMT
Author: alexparvulescu
Date: Wed Oct  3 18:02:38 2012
New Revision: 1393639

URL: http://svn.apache.org/viewvc?rev=1393639&view=rev
Log:
OAK-340 Basic reindex support in the lucene index

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndexConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexDefinition.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditor.java
Wed Oct  3 18:02:38 2012
@@ -21,6 +21,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPathField;
 import static org.apache.jackrabbit.oak.plugins.lucene.FieldFactory.newPropertyField;
 import static org.apache.jackrabbit.oak.plugins.lucene.TermFactory.newPathTerm;
+import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.INDEX_DATA_CHILD_NAME;
 
 import java.io.IOException;
 
@@ -91,7 +92,8 @@ class LuceneEditor implements CommitHook
         for (String name : path) {
             builder = builder.getChildBuilder(name);
         }
-        Directory directory = new ReadWriteOakDirectory(builder.getChildBuilder(INDEX_DATA_CHILD_NAME));
+        builder = builder.getChildBuilder(INDEX_DATA_CHILD_NAME);
+        Directory directory = new ReadWriteOakDirectory(builder);
 
         try {
             IndexWriter writer = new IndexWriter(directory, config);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
Wed Oct  3 18:02:38 2012
@@ -21,6 +21,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.lucene.FieldNames.PATH_SELECTOR;
 import static org.apache.jackrabbit.oak.plugins.lucene.TermFactory.newPathTerm;
 import static org.apache.jackrabbit.oak.query.Query.JCR_PATH;
+import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.INDEX_DATA_CHILD_NAME;
 
 import java.io.IOException;
 import java.util.ArrayList;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndexConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndexConstants.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndexConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndexConstants.java
Wed Oct  3 18:02:38 2012
@@ -22,8 +22,6 @@ public interface LuceneIndexConstants {
 
     String DEFAULT_INDEX_NAME = "default-lucene";
 
-    String INDEX_DATA_CHILD_NAME = ":data";
-
     String INDEX_UPDATE = "indexUpdate";
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/type/InitialContent.java
Wed Oct  3 18:02:38 2012
@@ -71,6 +71,10 @@ public class InitialContent extends Defa
                     "\"rep:privileges\"     :{\"jcr:primaryType\":\"nam:rep:Privileges\"}}",
null, null);
         }
 
+        if (!root.hasChildNode("oak-index")) {
+            mk.commit("/", "+\"oak-index\":{ \"indexes\": { \"type\": \"lucene\" }}", null,
null);
+        }
+
         BuiltInNodeTypes.register(createRoot(mk));
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexDefinition.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexDefinition.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexDefinition.java
Wed Oct  3 18:02:38 2012
@@ -30,6 +30,8 @@ public interface IndexDefinition {
 
     String UNIQUE_PROPERTY_NAME = "unique";
 
+    String INDEX_DATA_CHILD_NAME = ":data";
+
     /**
      * Get the unique index name. This is also the name of the index node.
      * 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java?rev=1393639&r1=1393638&r2=1393639&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/query/IndexUtils.java
Wed Oct  3 18:02:38 2012
@@ -16,6 +16,10 @@
  */
 package org.apache.jackrabbit.oak.spi.query;
 
+import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.INDEX_DATA_CHILD_NAME;
+import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.TYPE_PROPERTY_NAME;
+import static org.apache.jackrabbit.oak.spi.query.IndexDefinition.UNIQUE_PROPERTY_NAME;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -25,6 +29,7 @@ import java.util.Map;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexConstants;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -45,27 +50,36 @@ public class IndexUtils {
      */
     public static IndexDefinition getDefinition(String path, ChildNodeEntry def) {
         String name = def.getName();
-        PropertyState typeProp = def.getNodeState().getProperty(
-                IndexDefinition.TYPE_PROPERTY_NAME);
+        NodeState ns = def.getNodeState();
+        PropertyState typeProp = ns.getProperty(TYPE_PROPERTY_NAME);
         String type = TYPE_UNKNOWN;
         if (typeProp != null && !typeProp.isArray()) {
             type = typeProp.getValue().getString();
         }
 
         boolean unique = false;
-        PropertyState uniqueProp = def.getNodeState().getProperty(
-                IndexDefinition.UNIQUE_PROPERTY_NAME);
+        PropertyState uniqueProp = ns.getProperty(UNIQUE_PROPERTY_NAME);
         if (uniqueProp != null && !uniqueProp.isArray()) {
             unique = uniqueProp.getValue().getBoolean();
         }
 
         Map<String, String> props = new HashMap<String, String>();
-        for (PropertyState ps : def.getNodeState().getProperties()) {
+        for (PropertyState ps : ns.getProperties()) {
             if (ps != null && !ps.isArray()) {
                 String v = ps.getValue().getString();
                 props.put(ps.getName(), v);
             }
         }
+        // TODO hack to circumvent observation events
+        if (ns.hasChildNode(INDEX_DATA_CHILD_NAME)) {
+            PropertyState ps = ns.getChildNode(INDEX_DATA_CHILD_NAME)
+                    .getProperty(LuceneIndexConstants.INDEX_UPDATE);
+            if (ps != null && ps.getValue() != null) {
+                props.put(LuceneIndexConstants.INDEX_UPDATE, ps.getValue()
+                        .getString());
+            }
+        }
+
         return new IndexDefinitionImpl(name, type,
                 PathUtils.concat(path, name), unique, props);
     }



Mime
View raw message