.setEstimatedEntryCount(defn.getFulltextEntryCount(node.getIndexStatistics().numDocs())) .setCostPerExecution(defn.getCostPerExecution()) .setCostPerEntry(defn.getCostPerEntry()) .setDeprecated(defn.isDeprecated()) .setAttribute(ATTR_INDEX_PATH, indexPath)
.setEstimatedEntryCount(defn.getFulltextEntryCount(stats.numDocs())) .setCostPerExecution(defn.getCostPerExecution()) .setCostPerEntry(defn.getCostPerEntry()) .setDeprecated(defn.isDeprecated()) .setAttribute(ATTR_INDEX_PATH, indexPath)
return plan.setCostPerEntry(definition.getCostPerEntry() / costPerEntryFactor);
@Test public void costPerEntry() throws Exception{ builder.setProperty(FulltextIndexConstants.COMPAT_MODE, 2); IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo"); assertEquals(1.0, defn.getCostPerEntry(), 0.0); }
@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); }
@Test public void costConfig() throws Exception { NodeBuilder defnb = newFTPropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", "lucene", of("foo"), "async"); IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo"); assertEquals(1.0, defn.getCostPerEntry(), 0); assertEquals(1.0, defn.getCostPerExecution(), 0); assertEquals(IndexDefinition.DEFAULT_ENTRY_COUNT, defn.getEntryCount()); assertFalse(defn.isEntryCountDefined()); defnb.setProperty(FulltextIndexConstants.COST_PER_ENTRY, 2.0); defnb.setProperty(FulltextIndexConstants.COST_PER_EXECUTION, 3.0); defnb.setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, 500); IndexDefinition defn2 = new IndexDefinition(root, defnb.getNodeState(), "/foo"); assertEquals(2.0, defn2.getCostPerEntry(), 0); assertEquals(3.0, defn2.getCostPerExecution(), 0); assertEquals(500, defn2.getEntryCount()); }