KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mediator > plan > OpBin


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mediator.plan ;
24
25
26 import org.xquark.mediator.runtime.MediatorException;
27 import org.xquark.xquery.parser.XQueryExpression;
28
29
30 /**
31  * This class is a binary node that is a component of the execution tree.
32  * Execution can be serialized or parallelized.
33  *
34  */

35 public abstract class OpBin extends OpMult {
36     // **********************************************************************
37
// * VERSIONING
38
// **********************************************************************
39
private static final String JavaDoc RCSRevision = "$Revision: 1.3 $";
40     private static final String JavaDoc RCSName = "$Name: $";
41     // **********************************************************************
42
// * CLASS VARIABLES
43
// **********************************************************************
44

45     // ***********************************************************************
46
// * INITIALIZATION
47
// ***********************************************************************
48
/**
49      * Construct an operator of the execution plan handling deux childs
50      * expressions. This method must be overrided by descendant, but a
51      * super (...) on this should always be called first by it's descendant
52      * constructor in order to avoid problems.
53      *
54      * @param plan a reference on the general execution plan.
55      * @param expression the expression handled by _this_ operator.
56      * @param leftexp a reference on the left child operator.
57      * @param rightexp a refrence on the right child operator.
58      *
59      * @param plan
60      * @param expression
61      * @param leftexp
62      * @param rightexp
63      * @return
64      */

65     public OpBin(ExecutionPlan plan, XQueryExpression expression, Operator left, Operator right) throws MediatorException {
66         super(plan, expression, left, right) ;
67     }
68     
69     public OpBin(ExecutionPlan plan, XQueryExpression expression, Operator[] operators) throws MediatorException {
70         super(plan, expression,operators) ;
71         if (operators.length != 2) throw new MediatorException("AlgBinOp must have two elements");
72     }
73     
74     // #############################################################################
75
// VISITOR STUFF
76
// #############################################################################
77

78     public void accept(OperatorVisitor visitor) throws MediatorException {
79         visitor.visit(this);
80     }
81
82     // ***********************************************************************
83
// * EXECUTE QUERY
84
// ***********************************************************************
85
/**
86      * Start the execution, as a binary node, it start the execution
87      * of the two children it refers. The execution is parallelized or
88      * serialized depending the value of 'ordertype' field that can be
89      * ORDER_SERIALIZATION or ORDER_PARALLELIZATION.
90      */

91     //public void executeQuery() throws MediatorException {
92

93     // ***********************************************************************
94
// * GET/SET METHODS
95
// ***********************************************************************
96
/**
97      * Return a reference on left child expression.
98      *
99      * @return a reference on left child expression.
100      */

101     public Operator getLeftAlgebra() { return childrenOperator[0]; }
102     
103     /**
104      * Return a reference on right child expression.
105      *
106      * @return a reference on right child expression.
107      */

108     public Operator getRightAlgebra() { return childrenOperator[1]; }
109     
110     // **********************************************************************
111
// * OPTIMIZE
112
// **********************************************************************
113
/**
114      * If the *exactly* same set of source is used for an operation,
115      * then the subtree can be passed entierely to the source.
116      * Beware of processing this from the leaf to the node.
117      *
118      * <p>Note: If this method is not overloaded or if it returns null,
119      * it means that _this_ node will not be optimized.</p>
120      * @return
121      */

122     //public Algebra optimizeSource() throws MediatorException {
123

124     /**
125      * Add projections on attributes the soonest as possible in order to
126      * manipulate the less data as possible. As soon an attribute isn't
127      * necessary, it must be unselected (by a projection on the complementary
128      * variables).
129      *
130      * <p>Note: If this method is not overloaded or if it returns null,
131      * it means that _this_ node will not be optimized.</p>
132      * @return
133      */

134     //public Algebra optimizeProjection() throws MediatorException {
135

136     /**
137      *
138      *
139      * <p>Note: If this method is not overloaded or if it returns null,
140      * it means that _this_ node will not be optimized.</p>
141      * @return
142      */

143     //public Algebra optimizeRestriction() throws MediatorException {
144

145     /**
146      * If the set of sources handled by this node are exactly the same (order
147      * not important) then return true.
148      * An AlgBinValue is true if both of its child are true and IF the
149      * set of sources handled by its children are exactly the same.
150      * @return
151      */

152     //protected boolean shareSameSources() {
153

154     /**
155      * Compare set of sources.
156      * @param algebra1
157      * @param algebra2
158      * @return
159      */

160     //private boolean compareSource(Algebra algebra1, Algebra algebra2) {
161

162     /**
163      * Return true if the node is of type source.
164      * AlgBinOp is not a source.
165      *
166      * @return false ;
167      */

168     //public boolean isSource() {
169

170     /**
171      * Return all the sources depending of this node.
172      * @return
173      */

174     //public ArrayList getSources() {
175

176 }
177
Popular Tags