--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.compile.AggregateDefinition\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.compile;\r
+\r
+import java.sql.SQLException;\r
+\r
+import org.apache.derby.iapi.types.DataTypeDescriptor;\r
+\r
+/**\r
+ * An AggregateDefinition defines an aggregate.\r
+ * \r
+ * It is used by Derby during query compilation to determine what \r
+ * Aggregator is used to aggregate a particular data type \r
+ * and what datatype the Aggregator will emit. A single \r
+ * AggregateDefinition may map to one or more Aggregators \r
+ * depending on the input type. For example, a user defined\r
+ * STDEV aggregate may use one aggregator implementation for the\r
+ * INTEGER type and another for a user defined type that implements \r
+ * a point. In this case, both the aggregators would have a \r
+ * single AggregateDefinition that would chose the appropriate\r
+ * aggregator based on the input type. On the other hand, if\r
+ * only a single aggregator is needed to aggregate over all\r
+ * of the input types (e.g. COUNT()), then it may be convenient\r
+ * to implement both the AggregateDefinition and the Aggregator\r
+ * interfaces by the same class.\r
+ *\r
+ * @see org.apache.derby.catalog.TypeDescriptor\r
+ */\r
+interface AggregateDefinition\r
+{\r
+ /**\r
+ * Get the aggregator that performs the aggregation on the\r
+ * input datatype at execution time. If the input type can be handled, \r
+ * return a type descriptor with the resultant type information and\r
+ * fill in the string buffer with the name of the class that\r
+ * is used to perform the aggregation over the input type.\r
+ * If the aggregate cannot be performed on this type, then\r
+ * a null should be returned.\r
+ * <p>\r
+ * The aggregator class must implement a zero argument \r
+ * constructor. The aggregator class can be the same class\r
+ * as the AggregateDefinition if it implements both interfaces.\r
+ * <p>\r
+ * The result datatype may be the same as the input datatype \r
+ * or a different datatype. To create your own type descriptor\r
+ * to return to this method, see <i>com.ibm.db2j.types.TypeFactory</i>.\r
+ *\r
+ * @param inputType the input type descriptor\r
+ * @param aggregatorClassName output parameter, filled in\r
+ * with the class name that implements <i>com.ibm.db2j.aggregates.Aggregator</i>\r
+ *\r
+ * @return the output type descriptor (which may or may not\r
+ * be the same as the input type -- it is ok to simply\r
+ * return the input type). Null is returned\r
+ * if the aggregate cannot process the input type.\r
+ * Note that the output type may be a type that maps\r
+ * directly to a standard SQL (e.g. <i>java.lang.Integer</i>)\r
+ * or any other java type (e.g. <i>java.sql.ResultSet</i>,\r
+ * <i>java.util.Vector</i>, <i>java.util.TimeZone</i> or whatever).\r
+ * To construct a type descriptor see <i>com.ibm.db2j.types.TypeFactory</i>.\r
+ *\r
+ * @see org.apache.derby.catalog.TypeDescriptor\r
+ *\r
+ */\r
+ public DataTypeDescriptor getAggregator(DataTypeDescriptor inputType,\r
+ StringBuffer aggregatorClassName);\r
+}\r