| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.functions; |
| 9 | |
| 10 | /** |
| 11 | * This abstract class provides functionality common to the sum(), avg(), count(), |
| 12 | * exists(), and empty() functions. These all take a sequence as input and produce a singleton |
| 13 | * as output; and they are all independent of the ordering of the items in the input. |
| 14 | */ |
| 15 | |
| 16 | public abstract class Aggregate extends SystemFunction { |
| 17 | |
| 18 | /** |
| 19 | * Static analysis: prevent sorting of the argument |
| 20 | */ |
| 21 | |
| 22 | // public void checkArguments(/*@NotNull*/ ExpressionVisitor visitor) throws XPathException { |
| 23 | // super.checkArguments(visitor); |
| 24 | // Optimizer opt = getConfiguration().obtainOptimizer(); |
| 25 | // argument[0] = argument[0].unordered(true, false); |
| 26 | // // we don't care about the order of the results, but we do care about how many nodes there are |
| 27 | // } |
| 28 | |
| 29 | /** |
| 30 | * Perform optimisation of an expression and its subexpressions. |
| 31 | * <p>This method is called after all references to functions and variables have been resolved |
| 32 | * to the declaration of the function or variable, and after all type checking has been done.</p> |
| 33 | * |
| 34 | * @param visitor an expression visitor |
| 35 | * @param contextInfo the static type of "." at the point where this expression is invoked. |
| 36 | * The parameter is set to null if it is known statically that the context item will be undefined. |
| 37 | * If the type of the context item is not known statically, the argument is set to |
| 38 | * {@link net.sf.saxon.type.Type#ITEM_TYPE} |
| 39 | * @return the original expression, rewritten if appropriate to optimize execution |
| 40 | * @throws net.sf.saxon.trans.XPathException |
| 41 | * if an error is discovered during this phase |
| 42 | * (typically a type error) |
| 43 | */ |
| 44 | // @Override |
| 45 | // public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { |
| 46 | // optimizeChildren(visitor, contextInfo); |
| 47 | // setArg(0, getArg(0).unordered(true, visitor.isOptimizeForStreaming())); |
| 48 | // return this; |
| 49 | // } |
| 50 | |
| 51 | |
| 52 | } |
| 53 |