@NotThreadSafe public interface IndexCostCalculator
IndexPlanner.applyIndexes(org.modeshape.jcr.query.QueryContext, org.modeshape.jcr.spi.index.IndexCostCalculator)
method so that the
IndexPlanner
can add indexes to the query plan.
The cardinality estimate is an estimate 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.
The cost estimate is a measure of the expense of this 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.
Modifier and Type | Interface and Description |
---|---|
static class |
IndexCostCalculator.Costs |
Modifier and Type | Field and Description |
---|---|
static Float |
MAX_SELECTIVITY
A value representing the maximum selectivity of an index
|
Modifier and Type | Method and Description |
---|---|
void |
addIndex(String name,
String workspaceName,
String providerName,
Collection<Constraint> constraints,
int costEstimate,
long cardinalityEstimate,
Float selectivityEstimate)
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 workspaceName,
String providerName,
Collection<Constraint> constraints,
int costEstimate,
long cardinalityEstimate,
Float selectivityEstimate,
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 workspaceName,
String providerName,
Collection<Constraint> constraints,
int costEstimate,
long cardinalityEstimate,
Float selectivityEstimate,
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 workspaceName,
String providerName,
Collection<Constraint> constraints,
int costEstimate,
long cardinalityEstimate,
Float selectivityEstimate,
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.
|
void |
addIndex(String name,
String workspaceName,
String providerName,
Collection<JoinCondition> joinConditions,
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.
|
Collection<Constraint> |
andedConstraints()
Get the ANDed constraints that apply to the index to which this filter is submitted.
|
Map<String,Object> |
getVariables()
Get the variables that are to be substituted into the
BindVariableName used in the query. |
Collection<JoinCondition> |
joinConditions()
Get the join conditions that might apply to the index to which this filter is submitted.
|
Set<String> |
selectedNodeTypes()
Get the name of the node type that the query is selecting, including aliases.
|
static final Float MAX_SELECTIVITY
Set<String> selectedNodeTypes()
Collection<Constraint> andedConstraints()
Collection<JoinCondition> joinConditions()
Map<String,Object> getVariables()
BindVariableName
used in the query.void addIndex(String name, String workspaceName, String providerName, Collection<JoinCondition> joinConditions, int costEstimate, long cardinalityEstimate)
name
- the name of the index; may not be nullworkspaceName
- the name of the workspace for which the index is used; may be null if the index is built-inproviderName
- the name of the provider; may be null if the index is built-injoinConditions
- the join conditions that should be applied to the index if/when it is usedcostEstimate
- an estimate of the cost of using the index for the query in question; must be non-negativecardinalityEstimate
- an estimate of the number of nodes that will be returned by this index, which for join
constraints is generally equal to the total number of nodes known to the index; must be non-negativevoid addIndex(String name, String workspaceName, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, Float selectivityEstimate)
name
- the name of the index; may not be nullworkspaceName
- the name of the workspace for which the index is used; may be null if the index is built-inproviderName
- the name of the provider; may be null if the index is built-inconstraints
- the constraints that should be applied to the index if/when it is usedcostEstimate
- an estimate of the cost of using the index for the query in question; must be non-negativecardinalityEstimate
- an estimate of the number of nodes that will be returned by this index given the constraints;
must be non-negativeselectivityEstimate
- an estimate of the number of rows that are selected by the constraints divided by the total
number rows; must be >= 0 and <= 1.0, or null if the total number of nodes is not knownvoid addIndex(String name, String workspaceName, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, Float selectivityEstimate, String parameterName, Object parameterValue)
name
- the name of the index; may not be nullworkspaceName
- the name of the workspace for which the index is used; may be null if the index is built-inproviderName
- the name of the provider; may be null if the index is built-inconstraints
- the constraints that should be applied to the index if/when it is usedcostEstimate
- an estimate of the cost of using the index for the query in question; must be non-negativecardinalityEstimate
- an estimate of the number of nodes that will be returned by this index given the constraints;
must be non-negativeselectivityEstimate
- an estimate of the number of rows that are selected by the constraints divided by the total
number rows; must be >= 0 and <= 1.0, or null if the total number of nodes is not knownparameterName
- the name of a parameter that is to be supplied back to the Index
if/when this index is
Filter.filter(org.modeshape.jcr.spi.index.IndexConstraints)
called; may not be nullparameterValue
- the value of a parameter that is to be supplied back to the Index
if/when this index is
Filter.filter(org.modeshape.jcr.spi.index.IndexConstraints)
called; may not be nullvoid addIndex(String name, String workspaceName, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, Float selectivityEstimate, String parameterName1, Object parameterValue1, String parameterName2, Object parameterValue2)
name
- the name of the index; may not be nullworkspaceName
- the name of the workspace for which the index is used; may be null if the index is built-inproviderName
- the name of the provider; may be null if the index is built-inconstraints
- the constraints that should be applied to the index if/when it is usedcostEstimate
- an estimate of the cost of using the index for the query in question; must be non-negativecardinalityEstimate
- an estimate of the number of nodes that will be returned by this index given the constraints;
must be non-negativeselectivityEstimate
- an estimate of the number of rows that are selected by the constraints divided by the total
number rows; must be >= 0 and <= 1.0, or null if the total number of nodes is not knownparameterName1
- the name of the first parameter; may not be nullparameterValue1
- the value of the first parameterparameterName2
- the name of the second parameter; may not be nullparameterValue2
- the value of the second parametervoid addIndex(String name, String workspaceName, String providerName, Collection<Constraint> constraints, int costEstimate, long cardinalityEstimate, Float selectivityEstimate, Map<String,Object> parameters)
name
- the name of the index; may not be nullworkspaceName
- the name of the workspace for which the index is used; may be null if the index is built-inproviderName
- the name of the provider; may be null if the index is built-inconstraints
- the constraints that should be applied to the index if/when it is usedcostEstimate
- an estimate of the cost of using the index for the query in question; must be non-negativecardinalityEstimate
- an estimate of the number of nodes that will be returned by this index given the constraints;
must be non-negativeselectivityEstimate
- an estimate of the number of rows that are selected by the constraints divided by the total
number rows; must be >= 0 and <= 1.0, or null if the total number of nodes is not knownparameters
- the parameter values by name; may be null or emptyCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.