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.
    `int` | `computeCardinality()` | Get the static cardinality of this expression
    `int` | `computeDependencies()` | Determine which aspects of the context the expression depends on.
    `int` | `computeHashCode()` | get HashCode for comparing two expressions
    `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 expression
    `AtomicComparer` | `getComparer()` | Get the comparer used for the comparisons
    `java.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 returned
    `Expression` | `getSearchExpression()` | Get the expression whose value we will be searching for
    `Expression` | `getUseExpression()` | Get the expression to be indexed
    `boolean` | `isConvertUntypedToOther()` | Ask whether untyped atomic values need to be converted to the type of the other operand
    `SequenceIterator` | `iterate​(XPathContext context)` | Iterate over the results, returning them in the correct order
    `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.
    `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 messages
    `Expression` | `typeCheck​(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 predicate
        `indexFirstOperand` - 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 class `Expression`
      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 class `Expression`
      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 class `Expression`
      Parameters:
        `visitor` - an expression visitor
        `contextInfo` - 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 class `Expression`
      Parameters:
        `visitor` - an expression visitor
        `contextItemType` - 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 to `Type.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 class `Expression`
      Returns:
        the implementation method, for example `Expression.ITERATE_METHOD` or `Expression.EVALUATE_METHOD` or `Expression.PROCESS_METHOD`

    - #### copy

          public Expression copy​(RebindingMap rebindings)

      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      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:
        `computeCardinality` in class `Expression`
      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:
        `computeSpecialProperties` in class `Expression`
      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 class `Expression`
      Parameters:
        `pathMap` - the PathMap to which the expression should be added
        `pathMapNodeSet` - 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 class `Expression`
      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:
        `computeHashCode` in class `Expression`
      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 class `Expression`
      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 class `Expression`
      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 class `Expression`
      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 interface `ExportAgent`
      Specified by:
        `export` in class `Expression`
      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 class `Expression`
      Returns:
        a short string, sufficient to identify the expression