use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testUnion.
@Test
public void testUnion() throws Exception {
SelectorImpl selector = mock(SelectorImpl.class);
SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
String sqlQuery = "select [jcr:path], [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where" + " isdescendantnode(a, '/content') and contains([jcr:content/*], 'founded') union select [jcr:path]," + " [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:title], 'founded') union select [jcr:path], [jcr:score], [rep:excerpt]" + " from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:description], 'founded') order by [jcr:score] desc";
FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(0, plans.size());
}
use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.
the class IndexPathServiceImpl method createFilter.
private FilterImpl createFilter(String nodeTypeName) {
NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(nodeStore.getRoot());
NodeTypeInfo type = nodeTypes.getNodeTypeInfo(nodeTypeName);
SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", settings);
}
use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.
the class QueryImpl method getRows.
@Override
public Iterator<ResultRowImpl> getRows() {
prepare();
if (explain) {
String plan = getPlan();
if (measure) {
plan += " cost: { " + getIndexCostInfo() + " }";
}
columns = new ColumnImpl[] { new ColumnImpl("explain", "plan", "plan") };
ResultRowImpl r = new ResultRowImpl(this, Tree.EMPTY_ARRAY, new PropertyValue[] { PropertyValues.newString(plan) }, null, null);
return Arrays.asList(r).iterator();
}
if (LOG.isDebugEnabled()) {
logDebug("query execute " + statement);
logDebug("query plan " + getPlan());
}
final RowIterator rowIt = new RowIterator(context.getBaseState());
Comparator<ResultRowImpl> orderBy;
if (isSortedByIndex) {
orderBy = null;
} else {
orderBy = ResultRowImpl.getComparator(orderings);
}
Iterator<ResultRowImpl> it = FilterIterators.newCombinedFilter(rowIt, distinct, limit, offset, orderBy, settings);
if (orderBy != null) {
// this will force the rows to be read, so that the size is known
it.hasNext();
// we need the size, and there is no other way to get it right now
// but we also have to take limit and offset into account
long read = rowIt.getReadCount();
// we will ignore whatever is behind 'limit+offset'
read = Math.min(saturatedAdd(limit, offset), read);
// and we will skip 'offset' entries
read = Math.max(0, read - offset);
size = read;
}
if (measure) {
// return the measuring iterator delegating the readCounts to the rowIterator
it = new MeasuringIterator(this, it) {
@Override
protected void setColumns(ColumnImpl[] col) {
columns = col;
}
@Override
protected long getReadCount() {
return rowIt.getReadCount();
}
@Override
protected Map<String, Long> getSelectorScanCount() {
Map<String, Long> selectorReadCounts = Maps.newHashMap();
for (SelectorImpl selector : selectors) {
selectorReadCounts.put(selector.getSelectorName(), selector.getScanCount());
}
return selectorReadCounts;
}
};
}
return it;
}
use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.
the class ResultImpl method getColumnSelectorNames.
@Override
public String[] getColumnSelectorNames() {
ArrayList<String> list = new ArrayList<String>();
for (ColumnImpl c : query.getColumns()) {
SelectorImpl selector = c.getSelector();
String name = selector == null ? null : selector.getSelectorName();
if (!list.contains(name)) {
list.add(name);
}
}
return list.toArray(new String[list.size()]);
}
use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.
the class SQL2Parser method parseSource.
private SourceImpl parseSource() throws ParseException {
SelectorImpl selector = parseSelector();
selectors.put(selector.getSelectorName(), selector);
SourceImpl source = selector;
while (true) {
JoinType joinType;
if (readIf("RIGHT")) {
read("OUTER");
joinType = JoinType.RIGHT_OUTER;
} else if (readIf("LEFT")) {
read("OUTER");
joinType = JoinType.LEFT_OUTER;
} else if (readIf("INNER")) {
joinType = JoinType.INNER;
} else {
break;
}
read("JOIN");
selector = parseSelector();
selectors.put(selector.getSelectorName(), selector);
read("ON");
JoinConditionImpl on = parseJoinCondition();
source = factory.join(source, selector, joinType, on);
}
return source;
}
Aggregations