KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > plan > _TablePlan


1 package com.daffodilwoods.daffodildb.server.sql99.dql.plan;
2
3 import com.daffodilwoods.daffodildb.client.*;
4 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record;
5 import com.daffodilwoods.daffodildb.server.serversystem.*;
6 import com.daffodilwoods.daffodildb.server.sql99.common.*;
7 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*;
8 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*;
9 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*;
10 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.order.*;
11 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.table.*;
12 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
13 import com.daffodilwoods.database.resource.*;
14 import com.daffodilwoods.database.sqlinitiator.*;
15 import java.util.*;
16
17 /**
18  * It represents the plan for tables present in select query. It is required in
19  * formation of query plan for optimal execution.
20  * <p>Title: </p>
21  * <p>Description: </p>
22  * <p>Copyright: Copyright (c) 2003</p>
23  * <p>Company: </p>
24  * @author unascribed
25  * @version 1.0
26  */

27
28 public interface _TablePlan {
29
30    /**
31     * Returns the type of the plan. It is needed in merging of different table
32     * plans.
33     * @return type of table plan. It can be SingleTable, Qualified, NestedLoop.
34     * @throws DException
35     */

36   public int getType() throws DException;
37
38   /**
39    * This method returns the estimated number of rows results after the execution
40    * of this plan.
41    * @param serverSession
42    * @return
43    * @throws DException
44    */

45
46   public long getRowCount(_ServerSession serverSession) throws DException;
47
48   /**
49    * The cost relateds methods return the cost of the plan based on the passed
50    * argument as well as the attributes of the plan itself. These attributes
51    * includes - Order and Condition. And getCostWithOutOrder methods don't take
52    * care of order while calculating cost. These are required to choose the best
53    * among different possible combination of plan execution like left plan seeks
54    * in right, right plan seeks in left, No seek etc. based on the join condition.
55    * @param session
56    * @return
57    * @throws DException
58    */

59
60   public double getCost(_ServerSession session) throws DException;
61   public double getCost(_ServerSession session, booleanvalueexpression condition, long estimatedRows) throws DException;
62   public double getCostWithoutOrder(_ServerSession session) throws DException ;
63   public double getCostWithoutOrder(_ServerSession session, booleanvalueexpression condition, long estimatedRowCount) throws DException ;
64
65   /**
66    * The execute methods executes the plan and return the appropriate resultset.
67    * The way to get the resultset is decided in getCost methods and that way is
68    * cached in the plan. Based on that way the plan get executed.
69    * It was done because, firstly we determine which path is best say LeftSeekRight,
70    * RightSeekLeft or NoSeek then we actually execute according to optimal decision.
71    * @param session
72    * @return
73    * @throws DException
74    */

75
76   public _Iterator execute(_ServerSession session) throws DException;
77   public _Iterator execute(_ServerSession session, booleanvalueexpression condition) throws DException ;
78   public _Iterator executeWithOutOrder(_ServerSession session, booleanvalueexpression condition) throws DException;
79   public _Iterator executeWithoutOrder(_ServerSession session) throws DException;
80
81   /**
82    * This method returns the plan of those tables on which condition or order is
83    * shifted.
84    * @return
85    * @throws DException
86    */

87
88   public _SingleTablePlan[] getSingleTablePlans() throws DException;
89
90   /**
91    * This method remove the cover of NonExecutable Plans like OrderSequencePlan
92    * and TemporaryMerge. And also returns a single Plan if there are array of
93    * Plans. This is required to give final plan to execute.
94    * @return
95    * @throws DException
96    */

97
98   public _TablePlan joinMissingLink() throws DException;
99
100   /**
101    * Returns the order which will be applied at the top level of resultset.
102    * @return
103    * @throws DException
104    */

105
106   public _Order getOrder() throws DException ;
107
108   /**
109    * This method returns estimated rows based on the passed join condition and
110    * estimated rows of other plan. It is needed to calculate the cost of join
111    * of other plan with this plan so as to choose optimal path of execution.
112    * @param conditionArg represents join condition.
113    * @param estimatedRowCount of other plan.
114    * @param serverSession
115    * @return
116    * @throws DException
117    */

118
119   public long getEstimatedRows(booleanvalueexpression conditionArg , long estimatedRowCount, _ServerSession serverSession) throws DException;
120
121   /**
122    * These methods returns the TableDetails involved in Plan. getTableDetails
123    * returns all the TableDetails including the View's underlying TableDetails
124    * while getViewTableDetails return the TableDetails of top query level, means
125    * if any view is specified only tableDetails of that view will be included.
126    * These methods are required in formation of final plan.
127    * @return
128    * @throws DException
129    */

130
131   public TableDetails[] getViewTableDetails() throws DException;
132   public TableDetails[] getTableDetails() throws DException;
133
134   /**
135    * These methods are required to check the whole tree of the plans.
136    * @return
137    * @throws DException
138    */

139
140   public String JavaDoc getVerifier() throws DException;
141   public _QueryPlan getQueryPlan() throws DException;
142
143   /**
144    * It is required when both tables of join condition belongs to same plan.
145    * This method merges the passed joinCondition at the appropriate place in
146    * the tree of Plan.
147    * @param joinRelation
148    * @throws DException
149    */

150
151   public void merge(_JoinRelation joinRelation) throws DException;
152
153   /**
154    * This method tells whether the passed tableDetails exist in this plan or not.
155    * It is required in merging of join condition among different plans.
156    * @param tableDetails0
157    * @return
158    * @throws DException
159    */

160   public boolean ifExists(TableDetails tableDetails0) throws DException;
161   public _TablePlan[] getChildTablePlans() throws DException ;
162
163   /**
164    * This method is required to check whether OrderSequencePlan is present in
165    * hierarchy of tree. It is needed while merging of join conditions among
166    * different table plans.
167    * @return
168    * @throws DException
169    */

170
171   public boolean containsOrderSequencePlan() throws DException;
172 }
173
Popular Tags