Author: chetanm
Date: Thu Sep 15 07:14:43 2016
New Revision: 1760834

URL: http://svn.apache.org/viewvc?rev=1760834&view=rev
Log:
OAK-4412 - Lucene hybrid index

Refactor to use same logic to determine if current indexing is sync or not

Modified:
    
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
    
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorProvider.java

Modified: 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java?rev=1760834&r1=1760833&r2=1760834&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
 Thu Sep 15 07:14:43 2016
@@ -75,7 +75,6 @@ import static com.google.common.collect.
 import static com.google.common.collect.Sets.newHashSet;
 import static org.apache.jackrabbit.JcrConstants.JCR_SCORE;
 import static org.apache.jackrabbit.JcrConstants.NT_BASE;
-import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.DECLARING_NODE_TYPES;
@@ -305,7 +304,7 @@ public final class IndexDefinition imple
         this.secureFacets = defn.hasChildNode(FACETS) && 
getOptionalValue(defn.getChildNode(FACETS), PROP_SECURE_FACETS, true);
         this.suggestEnabled = evaluateSuggestionEnabled();
         this.spellcheckEnabled = evaluateSpellcheckEnabled();
-        this.sync = determineSync(defn);
+        this.sync = supportsSyncIndexing(defn);
     }
 
     public NodeState getDefinitionNodeState() {
@@ -1572,10 +1571,17 @@ public final class IndexDefinition imple
         return version == IndexFormatVersion.V1 ?  1.5 : 1.0;
     }
 
-    private static boolean determineSync(NodeState defn) {
-        Iterable<String> async = 
defn.getStrings(IndexConstants.ASYNC_PROPERTY_NAME);
+    private static boolean supportsSyncIndexing(NodeState defn) {
+        return supportsSyncIndexing(new ReadOnlyBuilder(defn));
+    }
+
+    public static boolean supportsSyncIndexing(NodeBuilder defn) {
+        PropertyState async = 
defn.getProperty(IndexConstants.ASYNC_PROPERTY_NAME);
+        if (async == null){
+            return false;
+        }
         //TODO [hybrid] make it a constant
-        return Iterables.contains(async, "sync");
+        return Iterables.contains(async.getValue(Type.STRINGS), "sync");
     }
 
 }

Modified: 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorProvider.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorProvider.java?rev=1760834&r1=1760833&r2=1760834&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorProvider.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorProvider.java
 Thu Sep 15 07:14:43 2016
@@ -19,12 +19,8 @@ package org.apache.jackrabbit.oak.plugin
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import com.google.common.collect.Iterables;
 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.ContextAwareCallback;
-import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
 import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
@@ -100,7 +96,7 @@ public class LuceneIndexEditorProvider i
             IndexingContext indexingContext = 
((ContextAwareCallback)callback).getIndexingContext();
             LuceneIndexWriterFactory writerFactory = indexWriterFactory;
             IndexDefinition indexDefinition = null;
-            if (!indexingContext.isAsync() && 
supportsSyncIndexing(definition)) {
+            if (!indexingContext.isAsync() && 
IndexDefinition.supportsSyncIndexing(definition)) {
 
                 //Would not participate in reindexing. Only interested in
                 //incremental indexing
@@ -132,13 +128,4 @@ public class LuceneIndexEditorProvider i
     ExtractedTextCache getExtractedTextCache() {
         return extractedTextCache;
     }
-
-    private boolean supportsSyncIndexing(NodeBuilder defn){
-        //TODO [hybrid] Similar logic exists in IndexDefinition. Should be 
unified
-        PropertyState async = 
defn.getProperty(IndexConstants.ASYNC_PROPERTY_NAME);
-        if (async == null){
-            return false;
-        }
-        return Iterables.contains(async.getValue(Type.STRINGS), "sync");
-    }
 }


Reply via email to