Package net.sf.saxon.expr
Class Optimizer
java.lang.Object
net.sf.saxon.expr.Optimizer
- All Implemented Interfaces:
Serializable
This class doesn't actually do any optimization itself, despite the name. Rather, it is
intended to act as a factory for implementation classes that perform optimization, so that
the appropriate level of optimization can be selected.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertPathExpressionToKey
(PathExpression pathExp, StaticContext env) Examine a path expression to see whether it can be replaced by a call on the key() function; if so, generate an appropriate key definition and return the call on key().convertToFilterExpression
(PathExpression pathExp, TypeHierarchy th) Convert a path expression such as a/b/c[predicate] into a filter expression of the form (a/b/c)[predicate].int
isIndexableFilter
(Expression filter) Test whether a filter predicate is indexable.makeClosure
(Expression expression, int ref) Make a Closure, given the expected reference countmakeGeneralComparison
(Expression p0, int op, Expression p1, boolean backwardsCompatible) Create a GeneralComparison expressionoptimizeCopy
(Expression select) Attempt to optimize a copy operation.tryIndexedFilter
(ValueRepresentation startValue, Expression filter, int isIndexable, XPathContext context) Try converting a filter expression to a call on the key function.
-
Field Details
-
config
-
-
Constructor Details
-
Optimizer
-
-
Method Details
-
getConfiguration
-
makeGeneralComparison
public BinaryExpression makeGeneralComparison(Expression p0, int op, Expression p1, boolean backwardsCompatible) Create a GeneralComparison expression -
optimizeCopy
Attempt to optimize a copy operation. Return null if no optimization is possible.- Parameters:
select
- the expression that selects the items to be copied- Returns:
- null if no optimization is possible, or an expression that does an optimized copy of these items otherwise
- Throws:
XPathException
-
makeClosure
Make a Closure, given the expected reference count -
convertPathExpressionToKey
public Expression convertPathExpressionToKey(PathExpression pathExp, StaticContext env) throws XPathException Examine a path expression to see whether it can be replaced by a call on the key() function; if so, generate an appropriate key definition and return the call on key(). If not, return null.- Parameters:
pathExp
- The path expression to be converted.- Throws:
XPathException
-
tryToConvertFilterExpressionToKey
public ComputedExpression tryToConvertFilterExpressionToKey(FilterExpression f, StaticContext env) throws XPathException Try converting a filter expression to a call on the key function. Return null if not possible- Throws:
XPathException
-
convertToFilterExpression
public FilterExpression convertToFilterExpression(PathExpression pathExp, TypeHierarchy th) throws StaticError Convert a path expression such as a/b/c[predicate] into a filter expression of the form (a/b/c)[predicate]. This is possible whenever the predicate is non-positional. The conversion is useful in the case where the path expression appears inside a loop, where the predicate depends on the loop variable but a/b/c does not.- Parameters:
pathExp
- the path expression to be converted- Returns:
- the resulting filterexpression if conversion is possible, or null if not
- Throws:
StaticError
-
tryIndexedFilter
public SequenceIterator tryIndexedFilter(ValueRepresentation startValue, Expression filter, int isIndexable, XPathContext context) throws XPathException - Throws:
XPathException
-
isIndexableFilter
Test whether a filter predicate is indexable.- Parameters:
filter
- the predicate expression- Returns:
- 0 if not indexable; +1 if the predicate is in the form expression=value; -1 if it is in the form value=expression
-