|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.expr.Optimizer
public class Optimizer
This class performs optimizations that vary between different versions of the Saxon product. The optimizer is obtained from the Saxon Configuration. This class is the version used in Saxon-B, which in most cases does no optimization at all: the methods are provided so that they can be overridden in Saxon-SA.
Constructor Summary | |
---|---|
Optimizer(Configuration config)
Create an Optimizer. |
Method Summary | |
---|---|
Expression |
convertPathExpressionToKey(PathExpression pathExp,
ExpressionVisitor visitor)
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(). |
FilterExpression |
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]. |
Expression |
extractGlobalVariables(Expression body,
ExpressionVisitor visitor)
Extract subexpressions from the body of a function that can be evaluated as global variables |
Configuration |
getConfiguration()
Get the Saxon configuration object |
int |
isIndexableFilter(Expression filter)
Test whether a filter predicate is indexable. |
Value |
makeClosure(Expression expression,
int ref,
XPathContext context)
Make a Closure, given the expected reference count |
Expression |
makeConditionalDocumentSorter(DocumentSorter sorter,
PathExpression path)
Make a conditional document sorter. |
BinaryExpression |
makeGeneralComparison(Expression p0,
int op,
Expression p1,
boolean backwardsCompatible)
Create a GeneralComparison expression |
ValueRepresentation |
makeIndexedValue(SequenceIterator iter)
Create an indexed value |
ValueRepresentation |
makeSequenceExtent(Expression expression,
int ref,
XPathContext context)
Make a SequenceExtent, given the expected reference count |
Expression |
optimizeCopy(Expression select)
Attempt to optimize a copy operation. |
Expression |
promoteExpressionsToGlobal(Expression body,
ExpressionVisitor visitor)
Identify expressions within a function or template body that can be promoted to be evaluated as global variables. |
void |
trace(String message)
Trace optimization actions |
void |
trace(String message,
Expression exp)
Trace optimization actions |
Expression |
tryIndexedFilter(FilterExpression f,
ExpressionVisitor visitor,
boolean indexFirstOperand)
Try converting a filter expression to a call on the key function. |
Expression |
tryInlineFunctionCall(UserFunctionCall functionCall,
ExpressionVisitor visitor,
ItemType contextItemType)
Replace a function call by the body of the function, assuming all conditions for inlining the function are satisfied |
Expression |
trySwitch(Choose choose,
StaticContext env)
Try to convert a Choose expression into a switch |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Optimizer(Configuration config)
config
- the Saxon configurationMethod Detail |
---|
public Configuration getConfiguration()
public BinaryExpression makeGeneralComparison(Expression p0, int op, Expression p1, boolean backwardsCompatible)
p0
- the first operandop
- the operatorp1
- the second operandbackwardsCompatible
- true if XPath 1.0 backwards compatibility is in force
public Expression optimizeCopy(Expression select) throws XPathException
select
- the expression that selects the items to be copied
XPathException
public Value makeClosure(Expression expression, int ref, XPathContext context) throws XPathException
expression
- the expression to be evaluatedref
- the (nominal) number of times the value of the expression is requiredcontext
- the XPath dynamic evaluation context
XPathException
public ValueRepresentation makeSequenceExtent(Expression expression, int ref, XPathContext context) throws XPathException
expression
- the expression to be evaluatedref
- the (nominal) number of times the value of the expression is requiredcontext
- the XPath dynamic evaluation context
XPathException
public Expression convertPathExpressionToKey(PathExpression pathExp, ExpressionVisitor visitor) throws XPathException
pathExp
- The path expression to be converted.visitor
- The expression visitor
XPathException
public Expression tryIndexedFilter(FilterExpression f, ExpressionVisitor visitor, boolean indexFirstOperand)
f
- the filter expression to be convertedvisitor
- the expression visitor, which must be currently visiting the filter expression findexFirstOperand
- true if the first operand of the filter comparison is to be indexed;
false if it is the second operand
public FilterExpression convertToFilterExpression(PathExpression pathExp, TypeHierarchy th) throws XPathException
pathExp
- the path expression to be convertedth
- the type hierarchy cache
XPathException
public int isIndexableFilter(Expression filter)
filter
- the predicate expression
public ValueRepresentation makeIndexedValue(SequenceIterator iter) throws XPathException
iter
- the iterator that delivers the sequence of values to be indexed
UnsupportedOperationException:
- this method should not be called in Saxon-B
XPathException
public Expression makeConditionalDocumentSorter(DocumentSorter sorter, PathExpression path)
sorter
- the document sorterpath
- the path expression
public Expression tryInlineFunctionCall(UserFunctionCall functionCall, ExpressionVisitor visitor, ItemType contextItemType)
functionCall
- the functionCall expressionvisitor
- the expression visitorcontextItemType
- the context item type
public Expression promoteExpressionsToGlobal(Expression body, ExpressionVisitor visitor) throws XPathException
body
- the body of the template or functionvisitor
- the expression visitor
XPathException
public Expression trySwitch(Choose choose, StaticContext env)
choose
- the Choose expressionenv
- the static context
public Expression extractGlobalVariables(Expression body, ExpressionVisitor visitor) throws XPathException
body
- the body of the function
XPathException
public void trace(String message, Expression exp)
message
- the message to be displayedexp
- the expression after being rewrittenpublic void trace(String message)
message
- the message to be displayed
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |