Package org.apache.jackrabbit.oak.query.index

Examples of org.apache.jackrabbit.oak.query.index.FilterImpl


    private FilterImpl createFilter(String nodeTypeName) {
        NodeState system = root.getChildNode(JCR_SYSTEM);
        NodeState types = system.getChildNode(JCR_NODE_TYPES);
        NodeState type = types.getChildNode(nodeTypeName);
        SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", new QueryEngineSettings());
    }
View Full Code Here


        assertQuery(tracker, indexed, "foo2", "bar2");
    }

    private void assertQuery(IndexTracker tracker, NodeState indexed, String key, String value){
        QueryIndex queryIndex = new LuceneIndex(tracker, analyzer, null);
        FilterImpl filter = createFilter(NT_BASE);
        filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty(key, Operator.EQUAL,
                PropertyValues.newString(value));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertTrue(cursor.hasNext());
        assertEquals("/", cursor.next().getPath());
        assertFalse(cursor.hasNext());
View Full Code Here

     * @param preparing whether a filter for the prepare phase should be made
     * @return the filter
     */
    @Override
    public FilterImpl createFilter(boolean preparing) {
        FilterImpl f = new FilterImpl(this, query.getStatement(), query.getSettings());
        f.setPreparing(preparing);
        if (joinCondition != null) {
            joinCondition.restrict(f);
        }
        // rep:excerpt handling: create a (fake) restriction
        // "rep:excerpt is not null" to let the index know that
        // we will need the excerpt
        for (ColumnImpl c : query.getColumns()) {
            if (c.getSelector().equals(this)) {
                if (c.getColumnName().equals("rep:excerpt")) {
                    f.restrictProperty("rep:excerpt", Operator.NOT_EQUAL, null);
                }
            }
        }
       
        // all conditions can be pushed to the selectors -
        // except in some cases to "outer joined" selectors,
        // but the exceptions are handled in the condition
        // itself.
        // An example where it *is* a problem:
        //  "select * from a left outer join b on a.x = b.y
        // where b.y is null" - in this case the selector b
        // must not use an index condition on "y is null"
        // (".. is null" must be written as "not .. is not null").
        if (queryConstraint != null) {
            queryConstraint.restrict(f);
            FullTextExpression ft = queryConstraint.getFullTextConstraint(this);
            f.setFullTextConstraint(ft);
        }
        if (selectorCondition != null) {
            selectorCondition.restrict(f);
        }

View Full Code Here

    // TODO test index config deletes

    private static Set<String> find(PropertyIndexLookup lookup, String name,
            String value) {
        return Sets.newHashSet(lookup.query(new FilterImpl(), name,
                PropertyValues.newString(value)));
    }
View Full Code Here

        NodeState after = builder.getNodeState();

        NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);

        QueryIndex queryIndex = new LuceneIndex(analyzer, null);
        FilterImpl filter = createFilter(NT_BASE);
        filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertTrue(cursor.hasNext());
        assertEquals("/", cursor.next().getPath());
        assertFalse(cursor.hasNext());
View Full Code Here

        NodeState after = builder.getNodeState();

        NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);

        QueryIndex queryIndex = new LuceneIndex(analyzer, null);
        FilterImpl filter = createFilter(NT_BASE);
        // filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);

        assertTrue(cursor.hasNext());
        assertEquals("/a/b/c", cursor.next().getPath());
View Full Code Here

        NodeState after = builder.getNodeState();

        NodeState indexed = HOOK.processCommit(before, after,CommitInfo.EMPTY);

        QueryIndex queryIndex = new LuceneIndex(analyzer, null);
        FilterImpl filter = createFilter(NT_BASE);
        // filter.restrictPath("/", Filter.PathRestriction.EXACT);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);

        assertTrue(cursor.hasNext());
        assertEquals("/a", cursor.next().getPath());
View Full Code Here

    private FilterImpl createFilter(String nodeTypeName) {
        NodeState system = root.getChildNode(JCR_SYSTEM);
        NodeState types = system.getChildNode(JCR_NODE_TYPES);
        NodeState type = types.getChildNode(nodeTypeName);
        SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", new QueryEngineSettings());
    }
View Full Code Here

    public String getPlan() {
        return  nodeTypeName + " AS " + getSelectorName() + " /* " + index.getPlan(createFilter()) + " */";
    }

    private FilterImpl createFilter() {
        FilterImpl f = new FilterImpl(this);
        if (joinCondition != null) {
            joinCondition.apply(f);
        }
        if (!outerJoin) {
            // for outer joins, query constraints can't be applied to the
View Full Code Here

        NodeState after = builder.getNodeState();

        UUIDDiffCollector collector = new UUIDDiffCollector(root, after);

        FilterImpl f = new FilterImpl(null, null);
        f.restrictProperty("jcr:uuid", Operator.EQUAL,
                PropertyValues.newString("abc"));

        Set<String> result = collector.getResults(f);
        Iterator<String> iterator = result.iterator();
        assertTrue(iterator.hasNext());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.query.index.FilterImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.