Author: chetanm
Date: Tue Oct 3 05:11:37 2017
New Revision: 1810653
URL: http://svn.apache.org/viewvc?rev=1810653&view=rev
Log:
OAK-6535 - Synchronous Lucene Property Indexes
- Handle relative property transformation
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java?rev=1810653&r1=1810652&r2=1810653&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
(original)
+++
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
Tue Oct 3 05:11:37 2017
@@ -34,7 +34,9 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
+import com.google.common.base.Predicates;
import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
@@ -125,6 +127,7 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.Lists.newArrayListWithCapacity;
import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
@@ -1553,6 +1556,7 @@ public class LucenePropertyIndex impleme
return NumericRangeQuery.newIntRange(FieldNames.PATH_DEPTH, depth,
depth, true, true);
}
+ @SuppressWarnings("Guava")
private static Iterator<LuceneResultRow>
mergePropertyIndexResult(IndexPlan plan, NodeState rootState,
Iterator<LuceneResultRow> itr) {
PlanResult pr = getPlanResult(plan);
@@ -1560,11 +1564,16 @@ public class LucenePropertyIndex impleme
NodeStateUtils.getNode(rootState, pr.indexPath));
PropertyIndexResult pir = pr.getPropertyIndexResult();
Iterable<String> paths = lookup.query(plan.getFilter(), pir.pd,
pir.propertyName, pir.pr);
- Iterator<LuceneResultRow> propIndexItr =
Iterators.transform(paths.iterator(),
- (path) -> new LuceneResultRow(path, 0, null, null, null));
+
+ //No need for path restriction evaluation as thats taken care by
PropertyIndex impl itself
+ //via content mirror strategy
+ FluentIterable<LuceneResultRow> propIndex = FluentIterable.from(paths)
+ .transform(path -> pr.isPathTransformed() ?
pr.transformPath(path) : path)
+ .filter(notNull())
+ .transform(path -> new LuceneResultRow(path, 0, null, null,
null));
//Property index itr should come first
- return Iterators.concat(propIndexItr, itr);
+ return Iterators.concat(propIndex.iterator(), itr);
}
static class LuceneResultRow {
Modified:
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java?rev=1810653&r1=1810652&r2=1810653&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java
(original)
+++
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java
Tue Oct 3 05:11:37 2017
@@ -272,6 +272,22 @@ public class SynchronousPropertyIndexTes
containsString("sync:(foo bar)"));
}
+
+ @Test
+ public void relativePropertyTransform() throws Exception{
+ defnb.async("async", "nrt");
+ defnb.indexRule("nt:base").property("foo").sync();
+
+ addIndex(indexPath, defnb);
+ root.commit();
+
+ createPath("/a/jcr:content").setProperty("foo", "bar");
+ createPath("/b").setProperty("foo", "bar");
+ root.commit();
+
+ assertQuery("select * from [nt:base] where [jcr:content/foo] = 'bar'",
singletonList("/a"));
+ }
+
private void runAsyncIndex() {
AsyncIndexUpdate async = (AsyncIndexUpdate)
WhiteboardUtils.getService(wb,
Runnable.class, input -> input instanceof AsyncIndexUpdate);