Examples of QueryIndex


Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictPath("newnode", Filter.PathRestriction.EXACT);
        filter.restrictProperty("prop", Operator.EQUAL,
                PropertyValues.newString("val"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("newnode", next.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/", next.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        filter.restrictFulltextCondition("bar");
        Cursor cursor = queryIndex.query(filter, indexed);

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

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictPath("/newnode", Filter.PathRestriction.EXACT);
        filter.restrictProperty("prop", Operator.EQUAL,
                PropertyValues.newString("val"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/newnode", next.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/", next.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        filter.restrictFulltextCondition("bar");
        Cursor cursor = queryIndex.query(filter, indexed);

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

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        EditorHook hook = new EditorHook(provider);
        NodeState indexed = hook.processCommit(before, after);

        IndexDefinition testDef = new IndexDefinitionImpl("solr",
                "solr", "/oak:index/solr");
        QueryIndex queryIndex = new SolrQueryIndex(testDef, server, configuration);
        FilterImpl filter = new FilterImpl(null, null);
        filter.restrictPath("/a", Filter.PathRestriction.ALL_CHILDREN);
        Cursor cursor = queryIndex.query(filter, indexed);

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

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

    }

    private SelectorExecutionPlan getBestSelectorExecutionPlan(
            NodeState rootState, FilterImpl filter,
            QueryIndexProvider indexProvider, boolean traversalEnabled) {
        QueryIndex bestIndex = null;
        if (LOG.isDebugEnabled()) {
            LOG.debug("cost using filter " + filter);
        }

        double bestCost = Double.POSITIVE_INFINITY;
        IndexPlan bestPlan = null;
        for (QueryIndex index : indexProvider.getQueryIndexes(rootState)) {
            double cost;
            IndexPlan indexPlan = null;
            if (index instanceof AdvancedQueryIndex) {
                AdvancedQueryIndex advIndex = (AdvancedQueryIndex) index;
                List<OrderEntry> sortOrder = null;
                if (orderings != null) {
                    sortOrder = new ArrayList<OrderEntry>();
                    for (OrderingImpl o : orderings) {
                        DynamicOperandImpl op = o.getOperand();
                        if (!(op instanceof PropertyValueImpl)) {
                            // ordered by a function: currently not supported
                            break;
                        }
                        PropertyValueImpl p = (PropertyValueImpl) op;
                        SelectorImpl s = p.getSelectors().iterator().next();
                        if (!s.equals(filter.getSelector())) {
                            // ordered by a different selector
                            continue;
                        }
                        OrderEntry e = new OrderEntry(
                                p.getPropertyName(),
                                Type.UNDEFINED,
                                o.isDescending() ?
                                OrderEntry.Order.DESCENDING : OrderEntry.Order.ASCENDING);
                        sortOrder.add(e);
                    }
                    if (sortOrder.size() == 0) {
                        sortOrder = null;
                    }
                }
                long maxEntryCount = limit;
                if (offset > 0) {
                    if (offset + limit < 0) {
                        // long overflow
                        maxEntryCount = Long.MAX_VALUE;
                    } else {
                        maxEntryCount = offset + limit;
                    }
                }
                List<IndexPlan> ipList = advIndex.getPlans(
                        filter, sortOrder, rootState);
                cost = Double.POSITIVE_INFINITY;
                for (IndexPlan p : ipList) {
                    long entryCount = Math.min(maxEntryCount, p.getEstimatedEntryCount());
                    double c = p.getCostPerExecution() + entryCount * p.getCostPerEntry();
                    if (c < cost) {
                        cost = c;
                        indexPlan = p;
                    }
                }
            } else {
                cost = index.getCost(filter, rootState);
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("cost for " + index.getIndexName() + " is " + cost);
            }
            if (cost < 0) {
                LOG.error("cost below 0 for " + index.getIndexName() + " is " + cost);
            }
            if (cost < bestCost) {
                bestCost = cost;
                bestIndex = index;
                bestPlan = indexPlan;
            }
        }

        if (traversalEnabled) {
            QueryIndex traversal = new TraversingIndex();
            double cost = traversal.getCost(filter, rootState);
            if (LOG.isDebugEnabled()) {
                LOG.debug("cost for " + traversal.getIndexName() + " is " + cost);
            }
            if (cost < bestCost || bestCost == Double.POSITIVE_INFINITY) {
                bestCost = cost;
                bestIndex = traversal;
            }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        builder.child("newnode").setProperty("prop", "val");
        NodeState after = builder.getNodeState();

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

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "", new QueryEngineSettings());
        filter.restrictPath("/newnode", Filter.PathRestriction.EXACT);
        filter.restrictProperty("prop", Operator.EQUAL,
                PropertyValues.newString("val"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/newnode", next.getPath());
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.query.QueryIndex

        builder.setProperty("foo", "bar");
        NodeState after = builder.getNodeState();

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

        QueryIndex queryIndex = new SolrQueryIndex("solr", server, configuration);
        FilterImpl filter = new FilterImpl(mock(SelectorImpl.class), "", new QueryEngineSettings());
        filter.restrictProperty("foo", Operator.EQUAL,
                PropertyValues.newString("bar"));
        Cursor cursor = queryIndex.query(filter, indexed);
        assertNotNull(cursor);
        assertTrue("no results found", cursor.hasNext());
        IndexRow next = cursor.next();
        assertNotNull("first returned item should not be null", next);
        assertEquals("/", next.getPath());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.