public IndexPlan getPlan() { if (definition == null) { log.debug("Index {} not loaded", indexPath); return null; } IndexPlan.Builder builder = getPlanBuilder(); if (definition.isTestMode()){ if (builder == null) { if (notSupportedFeature()) { return null; } String msg = String.format("No plan found for filter [%s] " + "while using definition [%s] and testMode is found to be enabled", filter, definition); throw new IllegalStateException(msg); } else { builder.setEstimatedEntryCount(1) .setCostPerExecution(1e-3) .setCostPerEntry(1e-3); } } return builder != null ? builder.build() : null; }
return b.setEstimatedEntryCount(1);
int maxPossibleNumDocs = getMaxPossibleNumDocs(result.propDefns, filter); if (maxPossibleNumDocs >= 0) { plan.setEstimatedEntryCount(maxPossibleNumDocs); if (uniqueIndexFound) { plan.setEstimatedEntryCount(1);
if (stats != null) { return Collections.singletonList(planBuilder(filter) .setEstimatedEntryCount(defn.getFulltextEntryCount(stats.numDocs())) .setCostPerExecution(defn.getCostPerExecution()) .setCostPerEntry(defn.getCostPerEntry())
IndexDefinition defn = node.getDefinition(); return Collections.singletonList(planBuilder(filter) .setEstimatedEntryCount(defn.getFulltextEntryCount(node.getIndexStatistics().numDocs())) .setCostPerExecution(defn.getCostPerExecution()) .setCostPerEntry(defn.getCostPerEntry())
@Nullable private IndexPlan.Builder defaultPlan() { // With OAK-7947 lucene indexes return a non-null index node to delay reading index files // While IndexNode could have a status check method but for now we are using this work-around // to check null on {@code getIndexStatistics()} as proxy indicator // (this could be avoided by returning lazy statistics) if (indexNode.getIndexStatistics() == null) { return null; } return new IndexPlan.Builder() .setCostPerExecution(definition.getCostPerExecution()) .setCostPerEntry(definition.getCostPerEntry()) .setFulltextIndex(definition.isFullTextEnabled()) .setIncludesNodeData(false) // we should not include node data .setFilter(filter) .setPathPrefix(getPathPrefix()) .setSupportsPathRestriction(definition.evaluatePathRestrictions()) .setDelayed(true) //Lucene is always async .setDeprecated(definition.isDeprecated()) .setAttribute(FulltextIndex.ATTR_PLAN_RESULT, result) .setEstimatedEntryCount(estimatedEntryCount()) .setPlanName(indexPath); }
private IndexPlan getIndexPlan(Filter filter, OakSolrConfiguration configuration, LMSEstimator estimator, List<OrderEntry> sortOrder, String path) { if (getMatchingFilterRestrictions(filter, configuration) > 0) { IndexPlan indexPlan = planBuilder(filter) .setEstimatedEntryCount(estimator.estimate(filter)) .setSortOrder(sortOrder) .setPlanName(path) .setPathPrefix(getPathPrefix(path)) .build(); log.debug("index plan {}", indexPlan); return indexPlan; } else { return null; } }
private IndexPlan getIndexPlan(Filter filter, OakSolrConfiguration configuration, LMSEstimator estimator, List<OrderEntry> sortOrder, String path) { if (getMatchingFilterRestrictions(filter, configuration) > 0) { IndexPlan indexPlan = planBuilder(filter) .setEstimatedEntryCount(estimator.estimate(filter)) .setSortOrder(sortOrder) .setPlanName(path) .setPathPrefix(getPathPrefix(path)) .build(); log.debug("index plan {}", indexPlan); return indexPlan; } else { return null; } }
@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]"); }
@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()); }
void addPlan(String name, long cost, boolean supportsPathRestriction) { plans.add(new IndexPlan.Builder() .setCostPerEntry(1) .setCostPerExecution(1) .setEstimatedEntryCount(cost) .setSupportsPathRestriction(supportsPathRestriction) .setPlanName(name) .build()); }
protected static IndexPlan.Builder planBuilder(Filter filter){ return new IndexPlan.Builder() .setCostPerExecution(0) // we're local. Low-cost .setCostPerEntry(1) .setFilter(filter) .setFulltextIndex(true) .setEstimatedEntryCount(0) //TODO Fake it to provide constant cost for now .setIncludesNodeData(false) // we should not include node data .setDelayed(true); //Lucene is always async }
protected static IndexPlan.Builder planBuilder(Filter filter){ return new IndexPlan.Builder() .setCostPerExecution(0) // we're local. Low-cost .setCostPerEntry(1) .setFilter(filter) .setFulltextIndex(true) .setEstimatedEntryCount(0) //TODO Fake it to provide constant cost for now .setIncludesNodeData(false) // we should not include node data .setDelayed(true); //Lucene is always async }