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.PathMapNodeSetaddToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)Add a representation of this expression to a PathMap.intcomputeCardinality()Get the static cardinality of this expressionintcomputeDependencies()Determine which aspects of the context the expression depends on.intcomputeHashCode()get HashCode for comparing two expressionsintcomputeSpecialProperties()Get the static properties of this expression (other than its type).Expressioncopy(RebindingMap rebindings)Copy an expression.booleanequals(java.lang.Object other)Is this expression the same as another expression?voidexport(ExpressionPresenter out)Diagnostic print of expression structure.ExpressiongetBaseExpression()Get the underlying expressionAtomicComparergetComparer()Get the comparer used for the comparisonsjava.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.intgetImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().ItemTypegetItemType()Get the data type of the items returnedExpressiongetSearchExpression()Get the expression whose value we will be searching forExpressiongetUseExpression()Get the expression to be indexedbooleanisConvertUntypedToOther()Ask whether untyped atomic values need to be converted to the type of the other operandSequenceIteratoriterate(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.Expressionoptimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)Perform optimisation of an expression and its subexpressions.java.lang.StringtoShortString()Produce a short string identifying the expression for use in error messagesExpressiontypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)Type-check the expression-
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, 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, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toString, typeCheckChildren, typeError, unordered, verifyParentPointers
-
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:
operandsin 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:
getItemTypein 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:
typeCheckin 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:
optimizein 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:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- variables that need to be re-bound- Returns:
- the copy of the original expression
-
computeCardinality
public int computeCardinality()
Get the static cardinality of this expression- Specified by:
computeCardinalityin 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
public 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:
computeSpecialPropertiesin 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:
addToPathMapin 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:
equalsin classExpression- Parameters:
other- the expression to be compared with this one- Returns:
- true if the two expressions are statically equivalent
-
computeHashCode
public int computeHashCode()
get HashCode for comparing two expressions- Overrides:
computeHashCodein classExpression- Returns:
- the hash code
-
iterate
public SequenceIterator iterate(XPathContext context) throws XPathException
Iterate over the results, returning them in the correct order- Overrides:
iteratein 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:
computeDependenciesin 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:
getExpressionNamein 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:
exportin interfaceExportAgent- Specified by:
exportin 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:ExpressionProduce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classExpression- Returns:
- a short string, sufficient to identify the expression
-
-