Package net.sf.saxon.expr.elab
Class LearningEvaluator
java.lang.Object
net.sf.saxon.expr.elab.LearningEvaluator
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionLearningEvaluator
(Expression expr, SequenceEvaluator lazy) Construct aLearningEvaluator
-
Method Summary
Modifier and TypeMethodDescriptionevaluate
(XPathContext context) Evaluate a construct to produce a value (which might be a lazily evaluated Sequence)void
reportCompletion
(int serialNumber) Callback method called when a lazily-evaluated expression has been read to completion
-
Constructor Details
-
LearningEvaluator
Construct aLearningEvaluator
- Parameters:
expr
- the expression to be evaluatedlazy
- a SequenceEvaluator that evaluates the expression. Although this is generally obtained by callinggetElaborator().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
Evaluate a construct to produce a value (which might be a lazily evaluated Sequence)- Specified by:
evaluate
in interfaceSequenceEvaluator
- 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
-