Package net.sf.saxon.expr.flwor
Class GroupByClause
java.lang.Object
net.sf.saxon.expr.flwor.Clause
net.sf.saxon.expr.flwor.GroupByClause
This class represents an "group by" clause in a FLWOR expression
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Inner class representing the contents of a tuple from the pre-grouping tuple stream; a set of such objects consitutes a group.static class
Inner class representing a tuple comparison key: that is, an arbitrary object whose equals() and hashCode() methods can be used to test whether two tuples have equivalent grouping keysNested classes/interfaces inherited from class net.sf.saxon.expr.flwor.Clause
Clause.ClauseName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToPathMap
(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Collect information about the navigation paths followed by this clause, for document projection purposesboolean
Determine whether the clause contains a reference to a local variable binding that cannot be inlinedcopy
(FLWORExpression flwor, RebindingMap rebindings) Create a copy of this clausevoid
Diagnostic print of expression structure.Get a keyword identifying what kind of clause this isgetComparisonKey
(Tuple t, GenericAtomicComparer[] comparers) Callback to get the comparison key for a tuple.Get the tuple expression that evaluates all the grouping variables, returning the values these variables take in the input streamgetPullStream
(TuplePull base, XPathContext context) Get a tuple stream that implements the functionality of this clause, taking its input from another tuple stream which this clause modifiesgetPushStream
(TuplePush destination, Outputter output, XPathContext context) Get a push-mode tuple stream that implements the functionality of this clause, supplying its output to another tuple streamGet the variables bound by this clauseGet the tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input streamvoid
initGroupingTupleExpression
(FLWORExpression flwor, TupleExpression expr) Initialize a tuple expression that evaluates all the grouping variables, returning the values these variables take in the input streamvoid
initRetainedTupleExpression
(FLWORExpression flwor, TupleExpression expr) Initialize a tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input streamvoid
optimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Optimize any expressions contained within this clausevoid
processGroup
(List<GroupByClause.ObjectToBeGrouped> group, XPathContext context) Process a group of tuples from the input stream to generate a single tuple in the output stream.void
processOperands
(OperandProcessor processor) Process the subexpressions of this clausevoid
setComparers
(GenericAtomicComparer[] comparers) Set the comparers used for the grouping keys.void
Set a tuple expression that evaluates all the grouping variables, returning the values these variables take in the input streamvoid
Set a tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input streamvoid
setVariableBindings
(LocalVariableBinding[] bindings) Set the bindings of new variables created by the grouping clause, which constitute the variables appearing in the output (post-grouping) tuple stream.toString()
Methods inherited from class net.sf.saxon.expr.flwor.Clause
gatherVariableReferences, getConfiguration, getLocation, getPackageData, getTraceInfo, isRepeated, refineVariableType, setLocation, setPackageData, setRepeated, toShortString, typeCheck
-
Constructor Details
-
GroupByClause
Create a group-by clause- Parameters:
config
- the Saxon configuration
-
-
Method Details
-
getClauseKey
Description copied from class:Clause
Get a keyword identifying what kind of clause this is- Specified by:
getClauseKey
in classClause
- Returns:
- the kind of clause
-
containsNonInlineableVariableReference
Description copied from class:Clause
Determine whether the clause contains a reference to a local variable binding that cannot be inlined- Overrides:
containsNonInlineableVariableReference
in classClause
- Parameters:
binding
- the binding for the local variable in question- Returns:
- true if this clause uses the variable in a way that does not permit inlining
-
copy
Description copied from class:Clause
Create a copy of this clause -
initRetainedTupleExpression
Initialize a tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input stream- Parameters:
flwor
- the containing FLWORExpressionexpr
- the tuple expression
-
setRetainedTupleExpression
Set a tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input stream- Parameters:
expr
- the tuple expression
-
getRetainedTupleExpression
Get the tuple expression that evaluates all the non-grouping variables, returning the values these variables take in the grouping input stream- Returns:
- the tuple expression
-
optimize
public void optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Description copied from class:Clause
Optimize any expressions contained within this clause- Overrides:
optimize
in classClause
- Parameters:
visitor
- the ExpressionVisitor, providing access to static context informationcontextItemType
- the type of the context item- Throws:
XPathException
- if any error is detected
-
initGroupingTupleExpression
Initialize a tuple expression that evaluates all the grouping variables, returning the values these variables take in the input stream- Parameters:
flwor
- the containing FLWORExpressionexpr
- the tuple expression
-
setGroupingTupleExpression
Set a tuple expression that evaluates all the grouping variables, returning the values these variables take in the input stream- Parameters:
expr
- the tuple expression
-
getGroupingTupleExpression
Get the tuple expression that evaluates all the grouping variables, returning the values these variables take in the input stream- Returns:
- the tuple expression
-
setVariableBindings
Set the bindings of new variables created by the grouping clause, which constitute the variables appearing in the output (post-grouping) tuple stream. There will be one of these for each variable in the input (pre-grouping) stream; by convention the bindings for grouping variables precede the bindings for non-grouping (retained) variables, and the order is preserved.- Parameters:
bindings
- the bindings of the variables created in the output stream
-
getRangeVariables
Get the variables bound by this clause- Overrides:
getRangeVariables
in classClause
- Returns:
- the variable bindings
-
setComparers
Set the comparers used for the grouping keys. There is one comparer for each grouping variable- Parameters:
comparers
- the comparers for grouping keys.
-
getPullStream
Get a tuple stream that implements the functionality of this clause, taking its input from another tuple stream which this clause modifies- Specified by:
getPullStream
in classClause
- Parameters:
base
- the input tuple streamcontext
- the XPath dynamic evaluation context- Returns:
- the output tuple stream
-
getPushStream
Get a push-mode tuple stream that implements the functionality of this clause, supplying its output to another tuple stream- Specified by:
getPushStream
in classClause
- Parameters:
destination
- the output tuple streamoutput
- the destination for the resultcontext
- the dynamic evaluation context- Returns:
- the push tuple stream that implements the functionality of this clause of the FLWOR expression
-
processOperands
Process the subexpressions of this clause- Specified by:
processOperands
in classClause
- Parameters:
processor
- the expression processor used to process the subexpressions- Throws:
XPathException
- if any error is detected
-
explain
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination. -
toString
-
processGroup
public void processGroup(List<GroupByClause.ObjectToBeGrouped> group, XPathContext context) throws XPathException Process a group of tuples from the input stream to generate a single tuple in the output stream. This method takes a group of tuples as input, and sets all the required variables in the local stack frame as required to deliver this group as the current tuple in the post-grouping stream- Parameters:
group
- the group of input tuplescontext
- the XPath dynamic evaluation context- Throws:
XPathException
- if a dynamic error occurs
-
getComparisonKey
public GroupByClause.TupleComparisonKey getComparisonKey(Tuple t, GenericAtomicComparer[] comparers) Callback to get the comparison key for a tuple. Two tuples are equal if their comparison keys compare equal using the equals() method.- Parameters:
t
- the tuple whose comparison key is requiredcomparers
- array of comparers for comparing each component of the grouping key- Returns:
- a comparison key suitable for comparing with other tuples
-
addToPathMap
Description copied from class:Clause
Collect information about the navigation paths followed by this clause, for document projection purposes- Specified by:
addToPathMap
in classClause
- Parameters:
pathMap
- the path map in which the data is to be collectedpathMapNodeSet
- the path map node set representing the paths to the context item
-