Package com.saxonica.ee.optim
Class IndexedFilterExpression
java.lang.Object
net.sf.saxon.expr.Expression
com.saxonica.ee.optim.IndexedFilterExpression
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
An IndexedFilterExpression contains a base expression and a filter predicate. The base expression
will always be a local variable reference. The filter will always be a Comparison, and it will
have no positional dependencies
-
Field Summary
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
Constructor Summary
ConstructorsConstructorDescriptionIndexedFilterExpression
(Expression base, Expression use, Expression search, AtomicComparer comparer, boolean convertUntypedToOther) IndexedFilterExpression
(VariableReference start, ComparisonExpression filter, boolean indexFirstOperand) Constructor -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap
(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.protected int
Get the static cardinality of this expressionint
Determine which aspects of the context the expression depends on.protected int
get HashCode for comparing two expressionsprotected int
Get the static properties of this expression (other than its type).copy
(RebindingMap rebindings) Copy an expression.boolean
Is this expression the same as another expression?void
Diagnostic print of expression structure.Get the underlying expressionGet the comparer used for the comparisonsMake an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.int
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().Get the data type of the items returnedGet the expression whose value we will be searching forGet the expression to be indexedboolean
Ask whether untyped atomic values need to be converted to the type of the other operanditerate
(XPathContext context) Iterate over the results, returning them in the correct orderoperands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.optimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Perform optimisation of an expression and its subexpressions.Produce a short string identifying the expression for use in error messagestypeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Type-check the expressionMethods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
IndexedFilterExpression
public IndexedFilterExpression(VariableReference start, ComparisonExpression filter, boolean indexFirstOperand) Constructor- Parameters:
start
- Variable containing the sequence of items from which the selection will take place.filter
- An expression defining the filter predicateindexFirstOperand
- true if the first operand of the filter comparison is to be indexed, false if the second operand is to be indexed
-
IndexedFilterExpression
public IndexedFilterExpression(Expression base, Expression use, Expression search, AtomicComparer comparer, boolean convertUntypedToOther)
-
-
Method Details
-
operands
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Overrides:
operands
in classExpression
- Returns:
- an iterator containing the sub-expressions of this expression
-
getItemType
Get the data type of the items returned- Specified by:
getItemType
in classExpression
- Returns:
- an integer representing the data type
-
getBaseExpression
Get the underlying expression- Returns:
- the expression being filtered
-
getUseExpression
Get the expression to be indexed- Returns:
- the "use" expression, the expression that computes the index key for each item in the population
-
getSearchExpression
Get the expression whose value we will be searching for- Returns:
- the search expression
-
isConvertUntypedToOther
public boolean isConvertUntypedToOther()Ask whether untyped atomic values need to be converted to the type of the other operand- Returns:
- true if untyped atomic values are converted; false if they are compared as strings
-
getComparer
Get the comparer used for the comparisons- Returns:
- the comparer
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Type-check the expression- Overrides:
typeCheck
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- information about the static type of the context item- Returns:
- the expression after type-checking (potentially modified to add run-time checks and/or conversions)
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Perform optimisation of an expression and its subexpressions.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
- Overrides:
optimize
in classExpression
- Parameters:
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE
- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
getImplementationMethod
public int getImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.- Specified by:
getImplementationMethod
in classExpression
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variables that need to be re-bound- Returns:
- the copy of the original expression
-
computeCardinality
protected int computeCardinality()Get the static cardinality of this expression- Specified by:
computeCardinality
in classExpression
- Returns:
- the cardinality. The method attempts to determine the case where the filter predicate is guaranteed to select at most one item from the sequence being filtered
-
computeSpecialProperties
protected int computeSpecialProperties()Get the static properties of this expression (other than its type). The result is bit-significant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.- Overrides:
computeSpecialProperties
in classExpression
- Returns:
- the static properties of the expression, as a bit-significant value
-
addToPathMap
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.- Overrides:
addToPathMap
in classExpression
- Parameters:
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter expression
-
equals
Is this expression the same as another expression?- Overrides:
equals
in classExpression
- Parameters:
other
- the expression to be compared with this one- Returns:
- true if the two expressions are statically equivalent
-
computeHashCode
protected int computeHashCode()get HashCode for comparing two expressions- Overrides:
computeHashCode
in classExpression
- Returns:
- the hash code
-
iterate
Iterate over the results, returning them in the correct order- Overrides:
iterate
in classExpression
- Parameters:
context
- the dynamic context for the evaluation- Returns:
- an iterator over the expression results
- Throws:
XPathException
- if any dynamic error occurs
-
computeDependencies
public int computeDependencies()Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as XPathContext.VARIABLES and XPathContext.CURRENT_NODE- Overrides:
computeDependencies
in classExpression
- Returns:
- the dependencies
-
getExpressionName
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classExpression
- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- Parameters:
out
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
toShortString
Description copied from class:Expression
Produce a short string identifying the expression for use in error messages- Overrides:
toShortString
in classExpression
- Returns:
- a short string, sufficient to identify the expression
-
getElaborator
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-