use of org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan in project jackrabbit-oak by apache.
the class AdvancedIndexTest method builder.
@Test
public void builder() {
IndexPlan.Builder b = new IndexPlan.Builder();
IndexPlan plan = b.setEstimatedEntryCount(10).build();
assertEquals(10, plan.getEstimatedEntryCount());
b.setEstimatedEntryCount(20);
assertEquals(10, plan.getEstimatedEntryCount());
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan in project jackrabbit-oak by apache.
the class AdvancedIndexTest method attribute.
@Test
public void attribute() throws Exception {
IndexPlan plan = new IndexPlan.Builder().setAttribute("foo", "bar").build();
assertEquals("bar", plan.getAttribute("foo"));
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan in project jackrabbit-oak by apache.
the class AdvancedIndexTest method copy.
@Test
public void copy() throws Exception {
Filter f = new FilterImpl(null, "SELECT * FROM [nt:file]", new QueryEngineSettings());
IndexPlan.Builder b = new IndexPlan.Builder();
IndexPlan plan1 = b.setEstimatedEntryCount(10).setFilter(f).setDelayed(true).build();
IndexPlan plan2 = plan1.copy();
plan2.setFilter(new FilterImpl(null, "SELECT * FROM [oak:Unstructured]", new QueryEngineSettings()));
assertEquals(plan1.getEstimatedEntryCount(), 10);
assertEquals(plan2.getEstimatedEntryCount(), 10);
assertTrue(plan1.isDelayed());
assertTrue(plan2.isDelayed());
assertEquals(plan1.getFilter().getQueryStatement(), "SELECT * FROM [nt:file]");
assertEquals(plan2.getFilter().getQueryStatement(), "SELECT * FROM [oak:Unstructured]");
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan in project jackrabbit-oak by apache.
the class AggregateIndexPlan method getPlanName.
@Override
public String getPlanName() {
StringBuilder name = new StringBuilder();
boolean first = true;
for (IndexPlan p : basePlans.values()) {
if (!first) {
name.append(",");
} else {
first = false;
}
name.append(p.getPlanName());
}
return name.toString();
}
use of org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan in project jackrabbit-oak by apache.
the class QueryImpl method canSortByIndex.
private boolean canSortByIndex() {
boolean canSortByIndex = false;
// TODO add issue about order by optimization for multiple selectors
if (orderings != null && selectors.size() == 1) {
IndexPlan plan = selectors.get(0).getExecutionPlan().getIndexPlan();
if (plan != null) {
List<OrderEntry> list = plan.getSortOrder();
if (list != null && list.size() == orderings.length) {
canSortByIndex = true;
for (int i = 0; i < list.size(); i++) {
OrderEntry e = list.get(i);
OrderingImpl o = orderings[i];
DynamicOperandImpl op = o.getOperand();
if (!(op instanceof PropertyValueImpl)) {
// ordered by a function: currently not supported
canSortByIndex = false;
break;
}
// we only have one selector, so no need to check that
// TODO support joins
String pn = ((PropertyValueImpl) op).getPropertyName();
if (!pn.equals(e.getPropertyName())) {
// ordered by another property
canSortByIndex = false;
break;
}
if (o.isDescending() != (e.getOrder() == Order.DESCENDING)) {
// ordered ascending versus descending
canSortByIndex = false;
break;
}
}
}
}
}
return canSortByIndex;
}
Aggregations