KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > execution > _Aggregate


1 package com.daffodilwoods.daffodildb.server.sql99.dql.execution;
2
3 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
4 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
5 import com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.groupbyclause.*;
6 import com.daffodilwoods.database.resource.DException;
7 import com.daffodilwoods.daffodildb.server.sql99.expression.valueexpression;
8
9 /**
10  * _Aggregate represents the aggregate functions like Sum, Count, Avg., max, min
11  * with two options DISTINCT and ALL. It helps in computing the result of
12  * Aggregate functions for each group. For each group, aggregates are initialized
13  * by its default value. Then aggregates are computed for all the values of
14  * group. And finally the computed result is returned.
15  * @usage GroupByIterator.
16  * <p>Title: </p>
17  * <p>Description: </p>
18  * <p>Copyright: Copyright (c) 2003</p>
19  * <p>Company: </p>
20  * @author unascribed
21  * @version 1.0
22  */

23
24 public interface _Aggregate {
25
26    /**
27     * Initializes the aggregate function to its default value. This method is called
28     * for each group before computing the aggregate function.
29     * @throws DException
30     */

31
32    public void initialize() throws DException;
33
34    /**
35     * uses the current valueexpression in computation of Aggregate functions.
36     * This method is called for each row of a group.
37     * @param iterator
38     * @throws DException
39     */

40
41    public void addRecord(Object JavaDoc obj) throws DException;
42
43    /**
44     * This method is called at the end of a group to return the computed value
45     * of Aggregate for the group.
46     * @return result of the aggregate function for a single group
47     * @throws DException
48     */

49
50    public Object JavaDoc getResult() throws DException;
51
52    /**
53     * This method is required when we want to share same iterator with different
54     * values of Parameters. Removes the initialization done for the previous
55     * values of parameters.
56     * @throws DException
57     */

58
59    public void releaseResource() throws DException;
60
61    /**
62     * This method is required in MultiThread environment where one thread deletes a row
63     * and 2nd one tries to read it
64     * returns ValueExpression
65     * @throws DException
66     */

67
68    public valueexpression getValueExpression() throws DException;
69 }
70
Popular Tags