| Modifier and Type | Field and Description |
|---|---|
(package private) static java.lang.String |
CANDIDATES_ANNOTATION_KEY |
private java.lang.String |
contextEntryId |
private Store |
db
the database this optimizer operates on
|
| Constructor and Description |
|---|
DefaultOptimizer(Store db)
Creates an optimizer on a database.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Long |
annotate(org.apache.directory.api.ldap.model.filter.ExprNode node)
Annotates the expression tree to determine optimal evaluation order based
on the scan count for indices that exist for each expression node.
|
private long |
getConjunctionScan(org.apache.directory.api.ldap.model.filter.BranchNode node)
ANDs or Conjunctions take the count of the smallest child as their count.
|
private java.lang.String |
getContextEntryId() |
private long |
getDisjunctionScan(org.apache.directory.api.ldap.model.filter.BranchNode node)
Disjunctions (OR) are the union of candidates across all subexpressions
so we add all the counts of the child nodes.
|
private <V> long |
getEqualityScan(org.apache.directory.api.ldap.model.filter.SimpleNode<V> node)
Gets the worst case scan count for all entries that satisfy the equality
assertion in the SimpleNode argument.
|
private long |
getFullScan(org.apache.directory.api.ldap.model.filter.LeafNode node)
Gets the total number of entries within the database index if one is
available otherwise the count of all the entries within the database is
returned.
|
private <V> long |
getGreaterLessScan(org.apache.directory.api.ldap.model.filter.SimpleNode<V> node,
boolean isGreaterThan)
Gets a scan count of the nodes that satisfy the greater or less than test
specified by the node.
|
private long |
getPresenceScan(org.apache.directory.api.ldap.model.filter.PresenceNode node)
Gets the number of entries that would be returned by a presence node
assertion.
|
private long |
getScopeScan(org.apache.directory.api.ldap.model.filter.ScopeNode node)
Gets the scan count for the scope node attached to this filter.
|
private long |
getSubstringScan(org.apache.directory.api.ldap.model.filter.SubstringNode node)
Get a scan count based on a Substring node : we will count the entries that are greater
than ABC where the filter is (attr=ABC*).
|
static final java.lang.String CANDIDATES_ANNOTATION_KEY
private final Store db
private java.lang.String contextEntryId
public DefaultOptimizer(Store db) throws java.lang.Exception
db - the database this optimizer works for.java.lang.Exceptionprivate java.lang.String getContextEntryId()
throws java.lang.Exception
java.lang.Exceptionpublic java.lang.Long annotate(org.apache.directory.api.ldap.model.filter.ExprNode node)
throws java.lang.Exception
annotate in interface Optimizernode - the root of the expression node treejava.lang.Exception - if there are failures while optimizingOptimizer.annotate(ExprNode)private long getConjunctionScan(org.apache.directory.api.ldap.model.filter.BranchNode node)
throws java.lang.Exception
node - a AND (Conjunction) BranchNodejava.lang.Exception - if there is an errorprivate long getDisjunctionScan(org.apache.directory.api.ldap.model.filter.BranchNode node)
throws java.lang.Exception
node - the OR branch nodejava.lang.Exception - if there is an errorprivate <V> long getEqualityScan(org.apache.directory.api.ldap.model.filter.SimpleNode<V> node)
throws java.lang.Exception
node - the node to get a scan count forjava.lang.Exception - if there is an error accessing an indexprivate <V> long getGreaterLessScan(org.apache.directory.api.ldap.model.filter.SimpleNode<V> node,
boolean isGreaterThan)
throws java.lang.Exception
node - the greater or less than node to get a count forisGreaterThan - if true test is for >=, otherwise <=java.lang.Exception - if there is an error accessing an indexprivate long getSubstringScan(org.apache.directory.api.ldap.model.filter.SubstringNode node)
throws java.lang.Exception
node - The substring nodejava.lang.Exception - If there is an error accessing an indexprivate long getFullScan(org.apache.directory.api.ldap.model.filter.LeafNode node)
throws java.lang.Exception
node - the leaf node to get a full scan count forjava.lang.Exception - if there is an error access database indicesprivate long getPresenceScan(org.apache.directory.api.ldap.model.filter.PresenceNode node)
throws java.lang.Exception
node - the presence nodejava.lang.Exception - if errors resultprivate long getScopeScan(org.apache.directory.api.ldap.model.filter.ScopeNode node)
throws java.lang.Exception
node - the ScopeNodejava.lang.Exception - if any errors result