test_class.declarator: MANY = 100
test_class.modifier: private static final
test_class.original_string: private static final int MANY = 100;
test_class.type: int
test_class.var_name: MANY
test_class.declarator: HOOK = new EditorHook(
              new IndexUpdateProvider(new PropertyIndexEditorProvider()))
test_class.modifier: private static final
test_class.original_string: private static final EditorHook HOOK = new EditorHook(
              new IndexUpdateProvider(new PropertyIndexEditorProvider()));
test_class.type: EditorHook
test_class.var_name: HOOK
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
test_class.identifier: PropertyIndexTest
test_case.body: @Test
      public void costMaxEstimation() throws Exception {
          NodeState root = EmptyNodeState.EMPTY_NODE;
  
          // Add index definition
          NodeBuilder builder = root.builder();
          createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo",
                  true, false, ImmutableSet.of("foo"), null);
          NodeState before = builder.getNodeState();
  
          // 100 nodes in the index:
          // with a single level /content cost is 121
          // adding a second level /content/data cost is133
  
          // 101 nodes in the index:
          // with a single level /content cost is 121
          // adding a second level /content/data cost is 133
  
          // 100 nodes, 12 levels deep, cost is 345
          // 101 nodes, 12 levels deep, cost is 345
  
          // threshold for estimation (PropertyIndexLookup.MAX_COST) is at 100
          int nodes = 101;
          int levels = 12;
  
          NodeBuilder data = builder;
          for (int i = 0; i < levels; i++) {
              data = data.child("l" + i);
          }
          for (int i = 0; i < nodes; i++) {
              NodeBuilder c = data.child("c_" + i);
              c.setProperty("foo", "azerty");
          }
          // add more nodes (to make traversal more expensive)
          for (int i = 0; i < 10000; i++) {
              data.child("cx_" + i);
          }
          NodeState after = builder.getNodeState();
          NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
  
          FilterImpl f = createFilter(indexed, NT_BASE);
  
          PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
          double cost = lookup.getCost(f, "foo",
                  PropertyValues.newString("azerty"));
          double traversal = new TraversingIndex().getCost(f, indexed);
  
          assertTrue("Estimated cost for " + nodes
                  + " nodes should not be higher than traversal (" + cost + " < " + traversal + ")",
                  cost < traversal);
      }
test_case.class_method_signature: PropertyIndexTest.costMaxEstimation()
test_case.full_signature: @Test public void costMaxEstimation()
test_case.identifier: costMaxEstimation
test_case.invocations: builder createIndexDefinition child of getNodeState child child setProperty child getNodeState processCommit createFilter getCost newString getCost assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void costMaxEstimation()
focal_class.declarator: PROPERTY = "property"
focal_class.modifier: private static final
focal_class.original_string: private static final String PROPERTY = "property";
focal_class.type: String
focal_class.var_name: PROPERTY
focal_class.declarator: LOG = LoggerFactory.getLogger(PropertyIndex.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(PropertyIndex.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: mountInfoProvider
focal_class.modifier: private final
focal_class.original_string: private final MountInfoProvider mountInfoProvider;
focal_class.type: MountInfoProvider
focal_class.var_name: mountInfoProvider
focal_class.declarator: cachedPlan
focal_class.modifier: private
focal_class.original_string: private PropertyIndexPlan cachedPlan;
focal_class.type: PropertyIndexPlan
focal_class.var_name: cachedPlan
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
focal_class.identifier: PropertyIndex
focal_class.interfaces: implements QueryIndex
focal_class.class_method_signature: PropertyIndex.PropertyIndex(MountInfoProvider mountInfoProvider)
focal_class.full_signature:   PropertyIndex(MountInfoProvider mountInfoProvider)
focal_class.identifier: PropertyIndex
focal_class.parameters: (MountInfoProvider mountInfoProvider)
focal_class.signature:  PropertyIndex(MountInfoProvider mountInfoProvider)
focal_class.class_method_signature: PropertyIndex.getPlan(NodeState root, Filter filter)
focal_class.full_signature: private PropertyIndexPlan getPlan(NodeState root, Filter filter)
focal_class.identifier: getPlan
focal_class.modifiers: private
focal_class.parameters: (NodeState root, Filter filter)
focal_class.return: PropertyIndexPlan
focal_class.signature: PropertyIndexPlan getPlan(NodeState root, Filter filter)
focal_class.class_method_signature: PropertyIndex.createPlan(NodeState root, Filter filter,
                                                  MountInfoProvider mountInfoProvider)
focal_class.full_signature: private static PropertyIndexPlan createPlan(NodeState root, Filter filter,
                                                  MountInfoProvider mountInfoProvider)
focal_class.identifier: createPlan
focal_class.modifiers: private static
focal_class.parameters: (NodeState root, Filter filter,
                                                  MountInfoProvider mountInfoProvider)
focal_class.return: PropertyIndexPlan
focal_class.signature: PropertyIndexPlan createPlan(NodeState root, Filter filter,
                                                  MountInfoProvider mountInfoProvider)
focal_class.class_method_signature: PropertyIndex.wrongIndex(ChildNodeEntry entry, Filter filter, NodeState root)
focal_class.full_signature: private static boolean wrongIndex(ChildNodeEntry entry, Filter filter, NodeState root)
focal_class.identifier: wrongIndex
focal_class.modifiers: private static
focal_class.parameters: (ChildNodeEntry entry, Filter filter, NodeState root)
focal_class.return: boolean
focal_class.signature: boolean wrongIndex(ChildNodeEntry entry, Filter filter, NodeState root)
focal_class.class_method_signature: PropertyIndex.isEnabled(NodeState definition, NodeState root)
focal_class.full_signature: private static boolean isEnabled(NodeState definition, NodeState root)
focal_class.identifier: isEnabled
focal_class.modifiers: private static
focal_class.parameters: (NodeState definition, NodeState root)
focal_class.return: boolean
focal_class.signature: boolean isEnabled(NodeState definition, NodeState root)
focal_class.class_method_signature: PropertyIndex.getOptionalStrings(NodeState defn, String propertyName)
focal_class.full_signature: private static String[] getOptionalStrings(NodeState defn, String propertyName)
focal_class.identifier: getOptionalStrings
focal_class.modifiers: private static
focal_class.parameters: (NodeState defn, String propertyName)
focal_class.return: String[]
focal_class.signature: String[] getOptionalStrings(NodeState defn, String propertyName)
focal_class.class_method_signature: PropertyIndex.getMinimumCost()
focal_class.full_signature: @Override public double getMinimumCost()
focal_class.identifier: getMinimumCost
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getMinimumCost()
focal_class.class_method_signature: PropertyIndex.getIndexName()
focal_class.full_signature: @Override public String getIndexName()
focal_class.identifier: getIndexName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getIndexName()
focal_class.class_method_signature: PropertyIndex.getIndexName(Filter filter, NodeState root)
focal_class.full_signature: @Override public String getIndexName(Filter filter, NodeState root)
focal_class.identifier: getIndexName
focal_class.modifiers: @Override public
focal_class.parameters: (Filter filter, NodeState root)
focal_class.return: String
focal_class.signature: String getIndexName(Filter filter, NodeState root)
focal_class.class_method_signature: PropertyIndex.getCost(Filter filter, NodeState root)
focal_class.full_signature: @Override public double getCost(Filter filter, NodeState root)
focal_class.identifier: getCost
focal_class.modifiers: @Override public
focal_class.parameters: (Filter filter, NodeState root)
focal_class.return: double
focal_class.signature: double getCost(Filter filter, NodeState root)
focal_class.class_method_signature: PropertyIndex.query(Filter filter, NodeState root)
focal_class.full_signature: @Override public Cursor query(Filter filter, NodeState root)
focal_class.identifier: query
focal_class.modifiers: @Override public
focal_class.parameters: (Filter filter, NodeState root)
focal_class.return: Cursor
focal_class.signature: Cursor query(Filter filter, NodeState root)
focal_class.class_method_signature: PropertyIndex.getPlan(Filter filter, NodeState root)
focal_class.full_signature: @Override public String getPlan(Filter filter, NodeState root)
focal_class.identifier: getPlan
focal_class.modifiers: @Override public
focal_class.parameters: (Filter filter, NodeState root)
focal_class.return: String
focal_class.signature: String getPlan(Filter filter, NodeState root)
focal_method.body: @Override
      public double getCost(Filter filter, NodeState root) {
          if (filter.getFullTextConstraint() != null) {
              // not an appropriate index for full-text search
              return Double.POSITIVE_INFINITY;
          }
          if (filter.containsNativeConstraint()) {
              // not an appropriate index for native search
              return Double.POSITIVE_INFINITY;
          }
          if (filter.getPropertyRestrictions().isEmpty()) {
              // not an appropriate index for no property restrictions & selector constraints
              return Double.POSITIVE_INFINITY;
          }
          PropertyIndexPlan plan = getPlan(root, filter);
          if (plan != null) {
              return plan.getCost();
          } else {
              return Double.POSITIVE_INFINITY;
          }
      }
focal_method.class_method_signature: PropertyIndex.getCost(Filter filter, NodeState root)
focal_method.full_signature: @Override public double getCost(Filter filter, NodeState root)
focal_method.identifier: getCost
focal_method.invocations: getFullTextConstraint containsNativeConstraint isEmpty getPropertyRestrictions getPlan getCost
focal_method.modifiers: @Override public
focal_method.parameters: (Filter filter, NodeState root)
focal_method.return: double
focal_method.signature: double getCost(Filter filter, NodeState root)