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
public final class IndexedFilterExpression extends Expression
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
Constructors Constructor Description IndexedFilterExpression(Expression base, Expression use, Expression search, AtomicComparer comparer, boolean convertUntypedToOther)
IndexedFilterExpression(VariableReference start, ComparisonExpression filter, boolean indexFirstOperand)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PathMap.PathMapNodeSet
addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.protected int
computeCardinality()
Get the static cardinality of this expressionint
computeDependencies()
Determine which aspects of the context the expression depends on.protected int
computeHashCode()
get HashCode for comparing two expressionsprotected int
computeSpecialProperties()
Get the static properties of this expression (other than its type).Expression
copy(RebindingMap rebindings)
Copy an expression.boolean
equals(java.lang.Object other)
Is this expression the same as another expression?void
export(ExpressionPresenter out)
Diagnostic print of expression structure.Expression
getBaseExpression()
Get the underlying expressionAtomicComparer
getComparer()
Get the comparer used for the comparisonsElaborator
getElaborator()
Make an elaborator for this expressionjava.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemType
getItemType()
Get the data type of the items returnedExpression
getSearchExpression()
Get the expression whose value we will be searching forExpression
getUseExpression()
Get the expression to be indexedboolean
isConvertUntypedToOther()
Ask whether untyped atomic values need to be converted to the type of the other operandSequenceIterator
iterate(XPathContext context)
Iterate over the results, returning them in the correct orderjava.lang.Iterable<Operand>
operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.Expression
optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.java.lang.String
toShortString()
Produce a short string identifying the expression for use in error messagesExpression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Type-check the expression-
Methods 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 Detail
-
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 Detail
-
operands
public java.lang.Iterable<Operand> 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
public ItemType getItemType()
Get the data type of the items returned- Specified by:
getItemType
in classExpression
- Returns:
- an integer representing the data type
-
getBaseExpression
public Expression getBaseExpression()
Get the underlying expression- Returns:
- the expression being filtered
-
getUseExpression
public Expression 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
public Expression 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
public AtomicComparer 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
public Expression copy(RebindingMap rebindings)
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
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
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
public boolean equals(java.lang.Object other)
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
public SequenceIterator iterate(XPathContext context) throws XPathException
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
public java.lang.String 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
public void export(ExpressionPresenter out) throws XPathException
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
public java.lang.String 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
public Elaborator getElaborator()
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-
-