Class QueryOptimizer
java.lang.Object
net.ontopia.topicmaps.query.impl.utils.QueryOptimizer
INTERNAL: An optimizer class that knows how to rewrite queries to
equivalent, but more efficient queries. Used by the different query
processor implementations to improve performance. Note that the
only optimizations this class should perform are those which are
independent of the tolog implementation used and which only rely
on the semantics of tolog.
The only optimizations performed at the moment are:
- Reordering of query clauses for better performance by limiting the number of intermediate results.
- Inlining rules which are simple aliases for a single predicate.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classINTERNAL:static classReplaces simple recursive rules with a more efficient custom implementation that just wraps the recursive step.static classINTERNAL: Optimizes queries that look for the next or the previous value in a sequence from a given start value to not load all values and then do it the hard way, but instead to use a sorted index.static classstatic classstatic classThis optimizer adds RemoveDuplicatesPredicate on both sides of recursive calls within predicate rules.static classINTERNAL: Optimizes the query by reordering the clauses into the optimal order for evaluation.static classINTERNAL: Optimizes the query by inlining all rules which are simple aliases for a single predicate.static classINTERNAL: Optimizes queries that do lookup of occurrences by string value, then filter the string value by a prefix.static classFinds cases of conflicting variables and resolves them by replacing predicates which can never succeed with DynamicFailurePredicate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOptimizer(QueryOptimizerIF optimizer) static QueryOptimizergetOptimizer(TologQuery query) INTERNAL: Get hold of an query optimizer instance.optimize(List clauses, QueryContext context) optimize(ParsedRule rule) optimize(TologQuery query) static ListINTERNAL: Optimizes the order of the query clauses in a context where the given variables are bound.
-
Constructor Details
-
QueryOptimizer
public QueryOptimizer()
-
-
Method Details
-
getOptimizer
INTERNAL: Get hold of an query optimizer instance.- Parameters:
query- The parsed query.
-
addOptimizer
-
optimize
- Throws:
InvalidQueryException
-
optimize
- Throws:
InvalidQueryException
-
optimize
- Throws:
InvalidQueryException
-
reorder
public static List reorder(List qclauses, Set boundvars, Set literalvars, String rulename, CostEstimator estimator) INTERNAL: Optimizes the order of the query clauses in a context where the given variables are bound. Done as a static method so we can use it from within RulePredicate.- Parameters:
qclauses- The list of clauses to be reordered.boundvars- Contains the variables bound when we get hereliteralvars- Contains the variables representing literals. Only an issue in rules.rulename- The name of the current rule (so we can delay recursive evaluation).
-