public class StreamingAdjunct
extends java.lang.Object
Expression
with methods used at compile-time
to support streaming, by generating a Watch
that allows the expression to be evaluated in push mode.
The default implementation is adequate only for expressions that take single items as their input. For other kinds of expression, either a WatchMaker or FeedMaker, or both, need to be supplied. If the input sequence is atomized (as with the sum() function), then only a FeedMaker is required; a TypedValueWatch will automatically be added to the Streaming Route to perform atomization of the supplied sequence. For expressions that do not perform atomization, both a WatchMaker (for use when the input is striding or consuming) and a FeedMaker (for use when it is climbing or grounded) need to be provided.
Neither method should be called in cases where streamability analysis has decided that the expression is not streamable. In such cases the methods may throw an exception.
There is a fallback implementation that allows any expression to be evaluated as a Feed, but it involves buffering the input in memory, and performing an implicit copy-of() to create a grounded copy, so it is only really suitable for the case where the input is a single atomic value.
Constructor and Description |
---|
StreamingAdjunct() |
Modifier and Type | Method and Description |
---|---|
PostureAndSweep |
computeStreamability(ContextItemStaticInfoEE contextInfo,
java.util.List<java.lang.String> reasons)
Compute the posture and sweep of this expression as defined in the W3C streamability specifications.
|
static int |
findConsumingArg(Expression expression,
int knownConsumingArg)
Find which operand of an expression is the consuming operand.
|
Configuration |
getConfiguration()
Get the Saxon Configuration
|
protected FeedMaker |
getDefaultFeedMaker(int arg)
Get a FeedMaker which will generate a feed to handle streamed input of operand "arg".
|
Expression |
getExpression()
Get the expression being processed by this StreamingAdjunct
|
FeedMaker |
getFeedMaker(int arg)
Get a FeedMaker, a factory class that creates a Feed to evaluate this expression
in streaming mode.
|
WatchMaker |
getWatchMaker(boolean forGrouping)
Get a WatchMaker, a factory class that creates a Watch to evaluate this expression
in streaming mode.
|
static StreamingAdjunct |
makeStreamingAdjunct(Configuration config,
Expression exp)
Make a streaming adjunct for a particular expression.
|
void |
setConfiguration(Configuration config)
Set the Saxon Configuration
|
void |
setExpression(Expression expression)
Set the expression being processed by this StreamingAdjunct
|
Pattern |
toStreamingPattern(Configuration config)
Convert this expression to a streaming pattern (a pattern used internally to match nodes during
push processing of an event stream)
|
public static StreamingAdjunct makeStreamingAdjunct(Configuration config, Expression exp)
config
- the Saxon Configurationexp
- the expression to be compiledpublic void setConfiguration(Configuration config)
config
- the Configurationpublic Configuration getConfiguration()
public void setExpression(Expression expression)
expression
- the expression being processedpublic Expression getExpression()
public PostureAndSweep computeStreamability(ContextItemStaticInfoEE contextInfo, java.util.List<java.lang.String> reasons)
contextInfo
- Information about the context item type and posturereasons
- the caller may supply a list, in which case the implementation may add to this; the
contents are human-readable messages explaining why the expression is not streamable.public static int findConsumingArg(Expression expression, int knownConsumingArg) throws XPathException
expression
- the expressionknownConsumingArg
- index of the consuming operand if known, otherwise -1XPathException
- if there is no consuming operandpublic Pattern toStreamingPattern(Configuration config)
config
- the Saxon configurationpublic WatchMaker getWatchMaker(boolean forGrouping) throws XPathException
Expression.WATCH_METHOD
forGrouping
- true if the selected items are being groupedXPathException
- in the event of a failurepublic FeedMaker getFeedMaker(int arg) throws XPathException
arg
- identifies the argument with respect to which the expression is to be inverted:
usually 0 to indicate the first argument is the value that is streamed. Argument numbering
is the same as the sequence of arguments/operands returned by the method Expression.operands()
XPathException
- in the event of a failureprotected FeedMaker getDefaultFeedMaker(int arg)
arg
- identifies which operand of the expression is the streamed (consuming) inputCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.