use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class NodeTypeIndexTest method createFilter.
private static FilterImpl createFilter(NodeState root, String nodeTypeName) {
NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(root);
NodeTypeInfo type = nodeTypes.getNodeTypeInfo(nodeTypeName);
SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", new QueryEngineSettings());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexUpdateTest method find.
private Set<String> find(PropertyIndexLookup lookup, String name, String value) {
NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(root);
NodeTypeInfo type = nodeTypes.getNodeTypeInfo(NT_BASE);
SelectorImpl selector = new SelectorImpl(type, NT_BASE);
Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]", new QueryEngineSettings());
return Sets.newHashSet(lookup.query(filter, name, PropertyValues.newString(value)));
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class DiffCollectorTest method testUUIDInner.
@Test
public void testUUIDInner() throws Exception {
NodeState root = EMPTY_NODE;
NodeBuilder builder = root.builder();
builder.child("a").setProperty("jcr:uuid", "abc");
NodeState before = builder.getNodeState();
builder = before.builder();
builder.child("a").child("b").setProperty("jcr:uuid", "xyz");
NodeState after = builder.getNodeState();
UUIDDiffCollector collector = new UUIDDiffCollector(before, after);
FilterImpl f = FilterImpl.newTestInstance();
f.restrictProperty("jcr:uuid", Operator.EQUAL, PropertyValues.newString("xyz"));
Set<String> result = collector.getResults(f);
Iterator<String> iterator = result.iterator();
assertTrue(iterator.hasNext());
assertEquals("a/b", iterator.next());
assertFalse(iterator.hasNext());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class DiffCollectorTest method testUUID.
@Test
public void testUUID() throws Exception {
NodeState root = EMPTY_NODE;
NodeBuilder builder = root.builder();
builder.child("a").setProperty("jcr:uuid", "abc");
builder.child("b").setProperty("jcr:uuid", "xyz");
NodeState after = builder.getNodeState();
UUIDDiffCollector collector = new UUIDDiffCollector(root, after);
FilterImpl f = FilterImpl.newTestInstance();
f.restrictProperty("jcr:uuid", Operator.EQUAL, PropertyValues.newString("abc"));
Set<String> result = collector.getResults(f);
Iterator<String> iterator = result.iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next());
assertFalse(iterator.hasNext());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class PropertyIndexTest method valuePattern.
@Test
public void valuePattern() throws Exception {
NodeState root = EMPTY_NODE;
// Add index definitions
NodeBuilder builder = root.builder();
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
NodeBuilder indexDef = createIndexDefinition(index, "fooIndex", true, false, ImmutableSet.of("foo"), null);
indexDef.setProperty(IndexConstants.VALUE_PATTERN, "(a.*|b)");
NodeState before = builder.getNodeState();
// Add some content and process it through the property index hook
builder.child("a").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME).setProperty("foo", "a");
builder.child("a1").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME).setProperty("foo", "a1");
builder.child("b").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME).setProperty("foo", "b");
builder.child("c").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME).setProperty("foo", "c");
NodeState after = builder.getNodeState();
// Add an index
NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
FilterImpl f = createFilter(after, NT_UNSTRUCTURED);
// Query the index
PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
PropertyIndex pIndex = new PropertyIndex(Mounts.defaultMountInfoProvider());
assertEquals(ImmutableSet.of("a"), find(lookup, "foo", "a", f));
assertEquals(ImmutableSet.of("a1"), find(lookup, "foo", "a1", f));
assertEquals(ImmutableSet.of("b"), find(lookup, "foo", "b", f));
// expected: no index for "is not null"
assertTrue(pIndex.getCost(f, indexed) == Double.POSITIVE_INFINITY);
ArrayList<PropertyValue> list = new ArrayList<PropertyValue>();
list.add(PropertyValues.newString("c"));
f.restrictPropertyAsList("foo", list);
// expected: no index for value c
assertTrue(pIndex.getCost(f, indexed) == Double.POSITIVE_INFINITY);
f = createFilter(after, NT_UNSTRUCTURED);
list = new ArrayList<PropertyValue>();
list.add(PropertyValues.newString("a"));
f.restrictPropertyAsList("foo", list);
// expected: no index for value a
assertTrue(pIndex.getCost(f, indexed) < Double.POSITIVE_INFINITY);
}
Aggregations