KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.daffodilwoods.daffodildb.server.sql99.dql.plan.table;
2
3 import com.daffodilwoods.daffodildb.client.*;
4 import com.daffodilwoods.daffodildb.server.serversystem.*;
5 import com.daffodilwoods.daffodildb.server.sql99.dql.common.*;
6 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.*;
7 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
8 import com.daffodilwoods.database.resource.*;
9
10 /**
11  *
12  * <p>Title: TwoTableJoinPlan</p>
13  * <p>Description:
14  * It represents the plan of inner join of two tables. It provides the
15  * functionality of obtaining resultset for inner join in optimal way.
16  * </p>
17  * <p>Copyright: Copyright (c) 2003</p>
18  * <p>Company: Daffodil S/W Ltd.</p>
19  * @author SelectTeam
20  * @version 1.0
21  */

22
23 public class TwoTableJoinPlan extends JoinPlanAbstract implements TableExpressionConstants, _TablePlan {
24
25    public TwoTableJoinPlan(_TablePlan tablePlanLeft0, _TablePlan tablePlanRight0, booleanvalueexpression joinCondition0) throws DException {
26       tablePlanLeft = tablePlanLeft0;
27       tablePlanRight = tablePlanRight0;
28       joinCondition = joinCondition0;
29       childPlans = new _TablePlan[] {tablePlanLeft0, tablePlanRight0};
30       initializeTableDetails();
31    }
32
33    /**
34     * This method is used to obtain the estimated rowCount for this plan. It is
35     * assumed that mostly join are of Foreign key and primary key. Thats why the
36     * minimum of both plans' row is returned.
37     * @param serverSession
38     * @return
39     * @throws DException
40     */

41
42    public long getRowCount(_ServerSession serverSession) throws DException {
43       return Math.min(tablePlanLeft.getRowCount(serverSession), tablePlanRight.getRowCount(serverSession));
44    }
45
46    /**
47     * Returns the type of the plan. It is used in merging of plan.
48     * @return
49     * @throws DException
50     */

51
52    public int getType() throws DException {
53       return TWOTABLEJOINPLAN;
54    }
55
56    public String JavaDoc toString() {
57       return super.toString("TWOTABLEJOINPLAN");
58    }
59
60    public String JavaDoc getVerifier() throws DException {
61       return super.getVerifier("TWO_TABLE_JOIN_PLAN");
62    }
63
64    /**
65     * Returns the plan for Inner Join.
66     * @return
67     * @throws DException
68     */

69
70    public _QueryPlan getQueryPlan() throws DException {
71       _QueryPlan[] cplans = new _QueryPlan[2];
72       cplans[0] = tablePlanLeft.getQueryPlan();
73       cplans[1] = tablePlanRight.getQueryPlan();
74       String JavaDoc cond = joinCondition == null ? null : ("" + joinCondition);
75       return new QueryPlan("TwoTableJoinPLAN", cplans, cond, null);
76    }
77
78    /**
79     * Returns the underlying plans.
80     * @return
81     * @throws DException
82     */

83
84    public _TablePlan[] getChildTablePlans() throws DException {
85       return new _TablePlan[] {this};
86    }
87
88 }
89
Popular Tags