You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2014/11/28 16:02:45 UTC
svn commit: r1642309 - in /jackrabbit/oak/branches/1.0: ./
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/
Author: davide
Date: Fri Nov 28 15:02:44 2014
New Revision: 1642309
URL: http://svn.apache.org/r1642309
Log:
OAK-2305 - Merge OAK-2202 into the 1.0 branch
manually resolved conflicts and avoided the dependecy of OAK-1977
Modified:
jackrabbit/oak/branches/1.0/ (props changed)
jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java
jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexQueryTest.java
Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
Merged /jackrabbit/oak/trunk:r1632258
Modified: jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java?rev=1642309&r1=1642308&r2=1642309&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/OrderedContentMirrorStoreStrategy.java Fri Nov 28 15:02:44 2014
@@ -18,6 +18,7 @@
package org.apache.jackrabbit.oak.plugins.index.property.strategy;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterators.singletonIterator;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.ENTRY_COUNT_PROPERTY_NAME;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME;
@@ -40,6 +41,7 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.index.property.OrderedIndex.OrderDirection;
import org.apache.jackrabbit.oak.plugins.index.property.OrderedIndex.Predicate;
import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction;
import org.apache.jackrabbit.oak.spi.state.AbstractChildNodeEntry;
@@ -396,6 +398,24 @@ public class OrderedContentMirrorStoreSt
}
}
return it;
+ } else if (firstEncoded != null && firstEncoded.equals(lastEncoded)) {
+ // property = $value case
+ LOG.debug("'property = $value' case");
+
+ final NodeState key = indexState.getChildNode(firstEncoded);
+ if (key.exists()) {
+ return new Iterable<String>() {
+ @Override
+ public Iterator<String> iterator() {
+ PathIterator pi = new PathIterator(filter, indexName);
+ pi.setPathContainsValue(true);
+ pi.enqueue(singletonIterator(new MemoryChildNodeEntry(firstEncoded, key)));
+ return pi;
+ }
+ };
+ } else {
+ return Collections.emptyList();
+ }
} else {
// property is not null. AKA "open query"
LOG.debug("property is not null. AKA 'open query'. FullIterable");
@@ -1063,7 +1083,7 @@ public class OrderedContentMirrorStoreSt
int len = next.length - 1;
for (; len >= 0; len--) {
if (next[len].length() != 0) {
- break;
+ break;
}
}
len++;
Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexQueryTest.java?rev=1642309&r1=1642308&r2=1642309&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexQueryTest.java (original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexQueryTest.java Fri Nov 28 15:02:44 2014
@@ -16,12 +16,14 @@
*/
package org.apache.jackrabbit.oak.plugins.index.property;
+import static com.google.common.collect.ImmutableList.of;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
+import static org.apache.jackrabbit.oak.spi.query.PropertyValues.newString;
import static org.junit.Assert.assertNotNull;
import java.text.ParseException;
@@ -145,6 +147,42 @@ public class OrderedPropertyIndexQueryTe
setTravesalEnabled(true);
}
+
+ /**
+ * checks the {@code OR} and {@code IN} conditions in queries.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void queryOrIn() throws Exception {
+ setTravesalEnabled(false);
+
+ // index automatically created by the framework:
+ // {@code createTestIndexNode()}
+
+ // generates:
+ // /test/n0, /test/n1, /test/n2
+ Tree rTree = root.getTree("/");
+ Tree test = rTree.addChild("test");
+ List<ValuePathTuple> nodes = addChildNodes(generateOrderedValues(3), test,
+ OrderDirection.ASC, Type.STRING);
+ root.commit();
+
+ String statementOr = "SELECT * FROM [nt:unstructured] " +
+ "WHERE " + ORDERED_PROPERTY + " = $or1 " +
+ "OR " + ORDERED_PROPERTY + " = $or2";
+ String statementIn = "SELECT * FROM [nt:unstructured] WHERE " + ORDERED_PROPERTY
+ + " IN($or1, $or2)";
+ List<ValuePathTuple> expected = of(nodes.get(0), nodes.get(1));
+ Map<String, PropertyValue> bindings = ImmutableMap.of(
+ "or1", newString(expected.get(0).getValue()),
+ "or2", newString(expected.get(1).getValue()));
+
+ assertRightOrder(expected, executeQuery(statementOr, SQL2, bindings).getRows().iterator());
+ assertRightOrder(expected, executeQuery(statementIn, SQL2, bindings).getRows().iterator());
+
+ setTravesalEnabled(true);
+ }
/**
* test the range query in case of '>' condition