Class LearningEvaluator

java.lang.Object
net.sf.saxon.expr.elab.LearningEvaluator
All Implemented Interfaces:
SequenceEvaluator

public class LearningEvaluator extends Object implements SequenceEvaluator
A LearningEvaluator initially performs lazy incremental evaluation of an expression; but if this proves unproductive, it switches after a while to eager evaluation. Lazy evaluation is considered unproductive if the input sequence is read to completion. A MemoClosure reports back if the input sequence is read to completion, and if the number of sequences that are completely read is equal to the total number of evaluations, lazy evaluation is abandoned.
  • Constructor Details

    • LearningEvaluator

      public LearningEvaluator(Expression expr, SequenceEvaluator lazy)
      Construct a LearningEvaluator
      Parameters:
      expr - the expression to be evaluated
      lazy - a SequenceEvaluator that evaluates the expression. Although this is generally obtained by calling getElaborator().lazily(), it does not necessarily perform lazy evaluation; some expressions such as literals and variable references choose to evaluate themselves eagerly all the time.
  • Method Details

    • evaluate

      public Sequence evaluate(XPathContext context) throws XPathException
      Evaluate a construct to produce a value (which might be a lazily evaluated Sequence)
      Specified by:
      evaluate in interface SequenceEvaluator
      Parameters:
      context - the evaluation context
      Returns:
      a Sequence (not necessarily grounded)
      Throws:
      XPathException - if a dynamic error occurs during the evaluation.
    • reportCompletion

      public void reportCompletion(int serialNumber)
      Callback method called when a lazily-evaluated expression has been read to completion
      Parameters:
      serialNumber - identifies the evaluation