org.modeshape.jcr.spi.index

## Interface IndexCollector

-     @NotThreadSafe
      public interface IndexCollector

  A collector implemented by ModeShape and supplied to the `IndexPlanner.applyIndexes(org.modeshape.jcr.query.QueryContext, org.modeshape.jcr.query.model.SelectorName, java.util.List<javax.jcr.query.qom.Constraint>, java.lang.Iterable<org.modeshape.jcr.spi.index.IndexDefinition>, org.modeshape.jcr.spi.index.IndexCollector)` method so that the `IndexPlanner` can add indexes to the query plan.

  The cardinality estimate is an esimate of the number of nodes that will be returned by this index given the constraints. For example, an index that will return one node should have a cardinality of 1. When possible, the actual cardinality should be used. However, since an accurate number is often expensive or impossible to determine in the planning phase, the cardinality can instead represent a rough order of magnitude.

  Return an estimate of the cost of using the index for the query in question. An index that is expensive to use will have a higher cost than another index that is less expensive to use. For example, if a `IndexProvider` that owns the index is in a remote process, then the cost estimate will need to take into account the cost of transmitting the request with the criteria and the response with all of the node that meet the criteria of the index.

  Indexes with lower costs and lower cardinalities will be favored over other indexes.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addIndex(String name, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate)` Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.
    `void` | `addIndex(String name, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, Map<String,Object> parameters)` Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.
    `void` | `addIndex(String name, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, String parameterName, Object parameterValue)` Add to the query plan the information necessary to signal that the supplied index can be used to answer the query
    `void` | `addIndex(String name, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, String parameterName1, Object parameterValue1, String parameterName2, Object parameterValue2)` Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.

- - ### Method Detail

    - #### addIndex

          void addIndex(String name,
                      String providerName,
                      Collection<Constraint> constraints,
                      int costEstimate,
                      long cardinalityEstimate)

      Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.
      Parameters:
        `name` - the name of the index; may not be null
        `providerName` - the name of the provider; may not be null
        `constraints` - the constraints that should be applied to the index if/when it is used
        `costEstimate` - an estimate of the cost of using the index for the query in question; must be non-negative
        `cardinalityEstimate` - an esimate of the number of nodes that will be returned by this index given the constraints; must be non-negative

    - #### addIndex

          void addIndex(String name,
                      String providerName,
                      Collection<Constraint> constraints,
                      int costEstimate,
                      long cardinalityEstimate,
                      String parameterName,
                      Object parameterValue)

      Add to the query plan the information necessary to signal that the supplied index can be used to answer the query
      Parameters:
        `name` - the name of the index; may not be null
        `providerName` - the name of the provider; may not be null
        `constraints` - the constraints that should be applied to the index if/when it is used
        `costEstimate` - an estimate of the cost of using the index for the query in question; must be non-negative
        `cardinalityEstimate` - an esimate of the number of nodes that will be returned by this index given the constraints; must be non-negative
        `parameterName` - the name of a parameter that is to be supplied back to the `Index` if/when this index is `Index.filter(org.modeshape.jcr.spi.index.provider.IndexFilter)` called; may not be null
        `parameterValue` - the value of a parameter that is to be supplied back to the `Index` if/when this index is `Index.filter(org.modeshape.jcr.spi.index.provider.IndexFilter)` called; may not be null

    - #### addIndex

          void addIndex(String name,
                      String providerName,
                      Collection<Constraint> constraints,
                      int costEstimate,
                      long cardinalityEstimate,
                      String parameterName1,
                      Object parameterValue1,
                      String parameterName2,
                      Object parameterValue2)

      Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.
      Parameters:
        `name` - the name of the index; may not be null
        `providerName` - the name of the provider; may not be null
        `constraints` - the constraints that should be applied to the index if/when it is used
        `costEstimate` - an estimate of the cost of using the index for the query in question; must be non-negative
        `cardinalityEstimate` - an esimate of the number of nodes that will be returned by this index given the constraints; must be non-negative
        `parameterName1` - the name of the first parameter; may not be null
        `parameterValue1` - the value of the first parameter
        `parameterName2` - the name of the second parameter; may not be null
        `parameterValue2` - the value of the second parameter

    - #### addIndex

          void addIndex(String name,
                      String providerName,
                      Collection<Constraint> constraints,
                      int costEstimate,
                      long cardinalityEstimate,
                      Map<String,Object> parameters)

      Add to the query plan the information necessary to signal that the supplied index can be used to answer the query.
      Parameters:
        `name` - the name of the index; may not be null
        `providerName` - the name of the provider; may not be null
        `constraints` - the constraints that should be applied to the index if/when it is used
        `costEstimate` - an estimate of the cost of using the index for the query in question; must be non-negative
        `cardinalityEstimate` - an esimate of the number of nodes that will be returned by this index given the constraints; must be non-negative
        `parameters` - the parameter values by name; may be null or empty

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.