KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > AggregateDefinition


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.AggregateDefinition
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.compile;
23
24 import java.lang.StringBuffer JavaDoc;
25 import org.apache.derby.catalog.TypeDescriptor;
26 import java.sql.SQLException JavaDoc;
27
28 /**
29  * An AggregateDefinition defines an aggregate.
30  *
31  * It is used
32  * by Cloudscape during query compilation to determine what
33  * Aggregator is used to aggregate a particular data type
34  * and what datatype the Aggregator will emit. A single
35  * AggregateDefinition may map to one or more Aggregators
36  * depending on the input type. For example, a user defined
37  * STDEV aggregate may use one aggregator implementation for the
38  * INTEGER type and another for a user defined type that implements
39  * a point. In this case, both the aggregators would have a
40  * single AggregateDefinition that would chose the appropriate
41  * aggregator based on the input type. On the other hand, if
42  * only a single aggregator is needed to aggregate over all
43  * of the input types (e.g. COUNT()), then it may be convenient
44  * to implement both the AggregateDefinition and the Aggregator
45  * interfaces by the same class.
46  *
47  * @see org.apache.derby.catalog.TypeDescriptor
48  */

49 interface AggregateDefinition
50 {
51     /**
52      * Get the aggregator that performs the aggregation on the
53      * input datatype at execution time. If the input type can be handled,
54      * return a type descriptor with the resultant type information and
55      * fill in the string buffer with the name of the class that
56      * is used to perform the aggregation over the input type.
57      * If the aggregate cannot be performed on this type, then
58      * a null should be returned.
59      * <p>
60      * The aggregator class must implement a zero argument
61      * constructor. The aggregator class can be the same class
62      * as the AggregateDefinition if it implements both interfaces.
63      * <p>
64      * The result datatype may be the same as the input datatype
65      * or a different datatype. To create your own type descriptor
66      * to return to this method, see <i>com.ibm.db2j.types.TypeFactory</i>.
67      *
68      * @param inputType the input type descriptor
69      * @param aggregatorClassName output parameter, filled in
70      * with the class name that implements <i>com.ibm.db2j.aggregates.Aggregator</i>
71      *
72      * @return the output type descriptor (which may or may not
73      * be the same as the input type -- it is ok to simply
74      * return the input type). Null is returned
75      * if the aggregate cannot process the input type.
76      * Note that the output type may be a type that maps
77      * directly to a standard SQL (e.g. <i>java.lang.Integer</i>)
78      * or any other java type (e.g. <i>java.sql.ResultSet</i>,
79      * <i>java.util.Vector</i>, <i>java.util.TimeZone</i> or whatever).
80      * To construct a type descriptor see <i>com.ibm.db2j.types.TypeFactory</i>.
81      *
82      * @see org.apache.derby.catalog.TypeDescriptor
83      *
84      * @exception SQLException Thrown on error.
85      */

86     public TypeDescriptor getAggregator(TypeDescriptor inputType,
87                             StringBuffer JavaDoc aggregatorClassName)
88                             throws SQLException JavaDoc;
89 }
90
Popular Tags