Search in sources :

Example 1 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class QueryImpl method currentRow.

ResultRowImpl currentRow() {
    int selectorCount = selectors.size();
    Tree[] trees = new Tree[selectorCount];
    for (int i = 0; i < selectorCount; i++) {
        SelectorImpl s = selectors.get(i);
        trees[i] = s.currentTree();
    }
    int columnCount = columns.length;
    PropertyValue[] values = new PropertyValue[columnCount];
    for (int i = 0; i < columnCount; i++) {
        ColumnImpl c = columns[i];
        values[i] = c.currentProperty();
    }
    PropertyValue[] orderValues;
    if (orderings == null) {
        orderValues = null;
    } else {
        int size = orderings.length;
        orderValues = new PropertyValue[size];
        for (int i = 0; i < size; i++) {
            orderValues[i] = orderings[i].getOperand().currentProperty();
        }
    }
    return new ResultRowImpl(this, trees, values, distinctColumns, orderValues);
}
Also used : SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Example 2 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class ReferenceIndexTest method createFilter.

@SuppressWarnings("Duplicates")
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());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeTypeInfo(org.apache.jackrabbit.oak.query.ast.NodeTypeInfo) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider) NodeTypeInfoProvider(org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)

Example 3 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled.

@Test
public void testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("primaryTypes", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
    filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPropertyNotListedInUsedProperties.

@Test
public void testNoPlanWithPropertyNotListedInUsedProperties() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS).setProperty("propertyRestrictions", true);
    nodeState = builder.getNodeState();
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where foo = 'bar')", new QueryEngineSettings());
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 5 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPrimaryTypeRestrictions.

@Test
public void testNoPlanWithPrimaryTypeRestrictions() throws Exception {
    SelectorImpl selector = newSelector(nodeState, "a");
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
    FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
    filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)36 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)30 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)29 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)17 Test (org.junit.Test)17 LinkedList (java.util.LinkedList)14 NodeStateNodeTypeInfoProvider (org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)14 NodeTypeInfo (org.apache.jackrabbit.oak.query.ast.NodeTypeInfo)14 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)14 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 ColumnImpl (org.apache.jackrabbit.oak.query.ast.ColumnImpl)4 DefaultSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration)3 OakSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration)3 OakSolrConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider)3 SolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)1