KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > expression > booleanvalueexpression > predicates > quantifiedcomparisonpredicate


1 package com.daffodilwoods.daffodildb.server.sql99.expression.
2     booleanvalueexpression.predicates;
3
4 import java.util.*;
5
6 import com.daffodilwoods.daffodildb.server.serversystem.*;
7 import com.daffodilwoods.daffodildb.server.sql99.common.*;
8 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*;
9 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*;
10 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*;
11 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.table.*;
12 import com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.fromclause.*;
13 import com.daffodilwoods.daffodildb.server.sql99.expression.
14     booleanvalueexpression.*;
15 import com.daffodilwoods.daffodildb.server.sql99.expression.expressionprimary.*;
16 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*;
17 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
18 import com.daffodilwoods.database.resource.*;
19 import com.daffodilwoods.database.utility.*;
20 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
21 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
22 import com.daffodilwoods.daffodildb.utils.comparator.
23
    ComparisionPredicateJoinComparator;
24 import com.daffodilwoods.daffodildb.utils.comparator.CJoDpnqbsbups;
25 import com.daffodilwoods.daffodildb.utils.comparator.CPckfduDpnqbsbups;
26
27 /**
28  * Class represents the Quantified Comparison Predicate.
29  * <p>Title: </p>
30  * <p>Description: </p>
31  * <p>Copyright: Copyright (c) 2003</p>
32  * <p>Company: </p>
33  * @author unascribed
34  * @version 1.0
35  */

36
37 public class quantifiedcomparisonpredicate
38     extends PredicateAbstract
39     implements predicate, OperatorConstants, IntegerPool,
40     ExecutionPlanConstants, SimpleConstants {
41   public tablesubquery _tablesubquery0;
42   public quantifier _quantifier1;
43   public compop _compop2;
44   public rowvalueexpressionwithoutboolean _rowvalueexpressionwithoutboolean3;
45
46   /**
47    * Integer depicting comparison Operator type i.e. <,>,= etc
48    */

49   private int Operator = -1;
50
51   /**
52    * Integer depicting Quantifier type ALL or ANY or SOME
53    */

54   private int quantifier = -1;
55
56   /**
57    * Boolean represents whether subquery is present in query or not.
58    */

59   private Boolean JavaDoc subQueryFlag = Boolean.FALSE;
60
61   /**
62    * Methods Calculates cost of solving this predicate on the rows passed.
63    * We computes rows reduced on solving of any comparison operator.
64    * @param rowCount, rows is the total no of rows on which predicate will be solved
65    * @param index, flag indicating Index is choosen or not.
66    * @return
67    * @throws DException
68    */

69   public double getCost(long rowCount, boolean index) throws DException {
70     switch (Operator) {
71       case EQUALTO:
72         rowCount *= CostFactorConstants.EQUALTO / 100;
73       case GREATERTHAN:
74       case LESSTHAN:
75         rowCount *= CostFactorConstants.GREATERTHAN / 100;
76       case GREATERTHANEQUALTO:
77       case LESSTHANEQUALTO:
78         rowCount *= CostFactorConstants.GREATERTHANEQUALTO / 100;
79     }
80     if (index) {
81       rowCount *= CostFactorConstants.INDEXPREDICATE / 100;
82     }
83     return rowCount;
84   }
85
86   /**
87    * Returns Qualified Condition in case of qualified join.
88    * TableDetails passed represents the tables involved on right side of LOJ and on left side of ROJ.
89    * Algo:
90    * 1) We extract unique tables involved in the predicate.
91    * 2) If tables involed does not match with the passed tables, then we make onCondition, otherwise.
92    * 3) We make BVESingleTablePlan for each passed tables.
93    * For Example:
94    * A LOJ B on A.a1 > all(query)
95    * In the above example, Table involved in predicate is one, i.e. A and it lies on the left side of LOJ,
96    * then we solve this condition above LOJ as onCondition
97    *
98    * A LOJ B on B.b1 > all(query)
99    * In the above example, Table involved in predicate is one, i.e. B and it lies on the right side of LOJ,
100    * then we solve shift this condition to single Table Level
101    *
102    * @param tableDetails
103    * @return
104    * @throws DException
105    */

106   public _QualifiedBVE getQualifiedBVE(TableDetails[] tableDetails0) throws
107       DException {
108     ArrayList uniqueTableList = getUniqueTableDetails(new ArrayList(),
109         columnDetails);
110     QualifiedBVE qualifiedBVE = getQualifiedBVEifBelongsToSingleTablePlan(
111         tableDetails0, uniqueTableList);
112     if (qualifiedBVE == null) {
113       TableDetails[] tableDetails = (TableDetails[]) uniqueTableList.toArray(new
114           TableDetails[uniqueTableList.size()]);
115       return new QualifiedBVE(makeBVESingleTablePlanArray(tableDetails,
116           BVEPlanMerger.getBooleanFactor(this)), null);
117     }
118     return qualifiedBVE;
119   }
120
121   /**
122    * Returns QualifiedBVE with onCondition initialised for anyone of the tables passed not belonging to condition.
123    * @param planTableDetails
124    * @param uniqueTableList
125    * @return
126    * @throws DException
127    */

128   private QualifiedBVE getQualifiedBVEifBelongsToSingleTablePlan(TableDetails[]
129       planTableDetails, ArrayList uniqueTableList) throws DException {
130     TableDetails[] conditionTableDetails = (TableDetails[]) uniqueTableList.
131         toArray(new TableDetails[uniqueTableList.size()]);
132     for (int i = 0, length2 = conditionTableDetails.length; i < length2; i++) {
133       for (int j = 0, length = planTableDetails.length; j < length; j++) {
134         if (! (planTableDetails[j] == conditionTableDetails[i])) {
135           return new QualifiedBVE(null, BVEPlanMerger.getBooleanFactor(this));
136         }
137       }
138     }
139     return null;
140   }
141
142   /**
143    * Returns Unique set of tables involved in the condition.
144    * @return
145    * @throws DException
146
147       private ArrayList getUniqueTableDetails() throws DException {
148      ArrayList uniqueTableDetails = new ArrayList();
149      for (int i = 0, length = columnDetails.length; i < length; i++) {
150         int type = columnDetails[i].getType();
151         if (type == REFERENCE) {
152            TableDetails tableDetail = columnDetails[i].getTableDetails();
153            if (!uniqueTableDetails.contains(tableDetail)) {
154               uniqueTableDetails.add(tableDetail);
155            }
156         }
157    if (type == SCALARFUNCTION || type == CASEEXPRESSION || type==FUNCTIONAL) {
158            uniqueTableDetails.clear();
159            return uniqueTableDetails;
160         }
161      }
162      return uniqueTableDetails;
163       }
164    */

165
166   /**
167    * Returns BveSingleTablePlans array for the tables passed with the condition bve passed
168    * @param tableDetails
169    * @param bve
170    * @return
171    * @throws DException
172    */

173   private BVESingleTablePlan[] makeBVESingleTablePlanArray(TableDetails[]
174       tableDetails, booleanvalueexpression bve) throws DException {
175     BVESingleTablePlan[] bveSingleTablePlans = new BVESingleTablePlan[
176         tableDetails.length];
177     for (int i = 0; i < tableDetails.length; i++) {
178       bveSingleTablePlans[i] = new BVESingleTablePlan(bve, tableDetails[i]);
179     }
180     return bveSingleTablePlans;
181   }
182
183   /**
184    * PredicateType QUANTIFIEDCOMPARISON is returned for the predicate.
185    * @return
186    * @throws DException
187    */

188   public int getPredicateType() throws DException {
189     return OperatorConstants.QUANTIFIEDCOMPARISON;
190   }
191
192   /**
193    * Solves this condition as Non Index Condition
194    * @param allColumnPredicates
195    * @throws DException
196    */

197   public void setColumnPredicates(_AllColumnPredicates allColumnPredicates) throws
198       DException {
199     allColumnPredicates.addToNonIndex(new booleanfactor(new booleantest(this)));
200   }
201
202   /**
203    * Returns a BVEConstants member telling the BVEPlanType of instance on which
204    * this method is invoked.<p>
205    * If this method finds any column of GROUPING type then it returns
206    * BVEConstants.BVEAGGREGATE.<p>
207    * If it is not an aggregate plan, then it check for ALLTABLEPLAN
208    * type by checking existence of CASE Expression OR SubQuery and
209    * ComplexInnerQuery. If founds any then returns BVEConstants.BVEALLTABLEPLAN.<p>
210    * If both cases fail it check for table count for this predicate,<p>
211    * If table count is One, returns BVEConstants.BVESINGLETABLEPLAN;<p>
212    * If Two, returns BVEConstants.BVEJOINRELATION;<p>
213    * Otherwise BVEConstants.BVEALLTABLEPLAN.<p>
214    * @param tableList An empty ArrayList which is filled in this method with
215    * table names used in this predicate.
216    * @return BVEConstants.MEMBER.
217    * @throws DException
218    */

219   private int getBVEPlanType(ArrayList tableList) throws DException {
220     for (int i = 0; i < columnDetails.length; i++) {
221       int type = columnDetails[i].getType();
222       if (type == GROUPING) {
223         return BVEConstants.BVEAGGREGATEPLAN;
224       }
225       if (type == SCALARFUNCTION || type == CASEEXPRESSION ||
226           type == FUNCTIONAL || type == USERFUNCTION) {
227         return BVEConstants.BVEALLTABLEPLAN;
228       }
229       if (type != CONSTANT) {
230         TableDetails tableDetail = columnDetails[i].getTableDetails();
231         if (tableDetail != null && !tableList.contains(tableDetail)) {
232           tableList.add(tableDetail);
233         }
234       }
235     }
236     if (checkForSubQuery() && checkForComplexInnerQuery()) {
237       return BVEConstants.BVEALLTABLEPLAN;
238     }
239     int size = tableList.size();
240     if (size == 1) {
241       return BVEConstants.BVESINGLETABLEPLAN;
242     }
243     else if (size == 2) {
244       return BVEConstants.BVEJOINRELATION;
245     }
246     else {
247       return BVEConstants.BVEALLTABLEPLAN;
248     }
249   }
250
251   /**
252    * Returns _BVEPlan based on the type of instance of this Object.<p>
253    * <pre>
254    * instance type returned plan
255    * -------------------------------------------------------------------------
256    * BVEConstants.BVEAGGREGATEPLAN BVEAggregatePlan
257    * BVEConstants.BVEALLTABLEPLAN BVEAllTablePlan
258    * BVEConstants.BVESINGLETABLEPLAN BVESingleTablePlan
259    * BVEConstants.BVEJOINRELATION BVEAllTablePlan
260    *
261    * <pre>
262    * In case of BVEJOINRELATION, a _JoinRelation is wrapped in
263    * AllTablesJoinRelation and AllTablesJoinRelation in BVEAllTablePlan.
264    * and returned.<p>
265    * @return
266    * @throws DException
267    */

268   public _BVEPlan getExecutionPlan() throws DException {
269     ArrayList tableList = new ArrayList();
270     int type = getBVEPlanType(tableList);
271     switch (type) {
272       case BVEConstants.BVEAGGREGATEPLAN:
273         return new BVEAggregatePlan(BVEPlanMerger.getBooleanFactor(this));
274       case BVEConstants.BVESINGLETABLEPLAN:
275         return new BVESingleTablePlan(BVEPlanMerger.getBooleanFactor(this),
276                                       (TableDetails) tableList.get(0));
277       case BVEConstants.BVEJOINRELATION:
278
279         _JoinRelation sr = new SimpleRelation( (TableDetails[]) tableList.
280                                               toArray(new TableDetails[0]),
281                                               BVEPlanMerger.getBooleanFactor(this));
282         AllTablesJoinRelation atjr = new AllTablesJoinRelation(new
283             _JoinRelation[] {sr});
284         return new BVEAllTablePlan(null, atjr, null);
285       case BVEConstants.BVEALLTABLEPLAN:
286         return new BVEAllTablePlan(null, null, BVEPlanMerger.getBooleanFactor(this));
287     }
288     throw new DException("DSE3547", new Object JavaDoc[] {this.toString()});
289   }
290
291   /**
292    * ComplexInnerQuery means that subQuery contains the column of outer query.
293    * In this case this condition is treated as remaining condition.
294    * @return
295    * @throws DException
296    */

297
298   private boolean checkForComplexInnerQuery() throws DException {
299     _Reference[] references = getReferences(null);
300     int length = references.length;
301     for (int i = 0; i < length; i++) {
302       if (references[i].getReferenceType() == SUBQUERY) {
303         if ( ( (subquery) references[i]).getUnderlyingReferences() != null) {
304           return true;
305         }
306       }
307     }
308     return false;
309   }
310
311   /**
312    * Run Method returns value 0,-1 or 1 on the basis whether predicate solves on the current record or not.
313    * Steps:
314    * 1) On Calling run we retrieves values for _rowvalueexpressionwithoutboolean3.
315    * 2) Thereafter, we call procedure handlingOfSubQuery for handling of query involved, return type of this method depends upon
316    * the quantifier involved in the predicate.
317    * @param object
318    * @return
319    * @throws com.daffodilwoods.database.resource.DException
320    */

321   public Object JavaDoc run(Object JavaDoc object) throws com.daffodilwoods.database.resource.
322
      DException {
323     Object JavaDoc fb1 = _rowvalueexpressionwithoutboolean3.run(object);
324     return handlingOfSubQuery(fb1, (_Iterator) _tablesubquery0.run(object), null,
325                               object);
326   }
327
328   /**
329    * Respective Quantifier ALL | SOME | ANY is returned for the quantifier string passed.
330    * @param str
331    * @return
332    * @throws DException
333    */

334
335   private int getQuantifier(String JavaDoc quantifierString) throws DException {
336     if (quantifierString.equalsIgnoreCase("ALL")) {
337       return ALL;
338     }
339     if (quantifierString.equalsIgnoreCase("SOME")) {
340       return SOME;
341     }
342     return ANY;
343   }
344
345   /**
346    * If subQuery Iterator does not contain any records then 1 is returned, otherwise
347    * Base upon the quantifier appropriate procedure is called.
348    * @param result1
349    * @param iterator
350    * @param serverSession
351    * @param object
352    * @return
353    * @throws DException
354    */

355   private Object JavaDoc handlingOfSubQuery(Object JavaDoc result1, _Iterator iterator,
356                                     _ServerSession serverSession, Object JavaDoc object) throws
357       DException {
358     if (!iterator.first()) {
359       return IntegerPool.Integer1;
360     }
361     if (quantifier == ALL) {
362       return handlingOfAll(result1, iterator, serverSession, object);
363     }
364     return handlingOfSomeAndAny(result1, iterator, serverSession, object);
365   }
366
367   /**
368    * Function to handle the quantifier All.
369    * If Left side value is greater than all of the query result then 0 is returned otherwise 1 is returned.
370    * @param result1
371    * @param iterator
372    * @param serverSession
373    * @param object
374    * @return
375    * @throws DException
376    */

377   private Object JavaDoc handlingOfAll(Object JavaDoc result1, _Iterator iterator,
378                                _ServerSession serverSession, Object JavaDoc object) throws
379       DException {
380     do {
381       int cmp = 0;
382       Object JavaDoc iteratorValue = null;
383       try {
384         iteratorValue = ( (_SelectIterator) iterator).getSelectColumnValues();
385         cmp = comparator.compare(result1, iteratorValue);
386       }
387       catch (NullPointerException JavaDoc ex) {
388         if (!_rowvalueexpressionwithoutboolean3.getByteComparison(object).
389             canUseByteComparison() ||
390             !_tablesubquery0.getByteComparison(object).canUseByteComparison()) {
391           comparator = getAppropriateObjectComparatorInCaseofSubQuery(result1,
392               iteratorValue, serverSession);
393         }
394         else {
395           comparator = getAppropriateSuperComparatorInCaseofSubQuery(result1,
396               iteratorValue, serverSession);
397         }
398         cmp = comparator.compare(result1, iteratorValue);
399       }
400       Object JavaDoc result = booleanResult[Operator - 1][cmp + 2];
401       if (result.hashCode() != 0) { // means current record value not equal to left side then false is returned
402
return result;
403       }
404     }
405     while (iterator.next());
406     return IntegerPool.Integer0; // means left side value is greater than all of the right iterator value, then 0 is returned
407
}
408
409   /**
410    * Function to handle the quantifier All.
411    * If Left side value is greater than all of the query result then 0 is returned otherwise 1 is returned.
412    * @param result1
413    * @param iterator
414    * @param serverSession
415    * @param object
416    * @return
417    * @throws DException
418    */

419   private Object JavaDoc handlingOfSomeAndAny(Object JavaDoc result1, _Iterator iterator,
420                                       _ServerSession serverSession,
421                                       Object JavaDoc object) throws DException {
422     /*Done by Sandeep to return the appropriate result if result1 is null*/
423     if (result1 instanceof Object JavaDoc[]) {
424       Object JavaDoc[] fbs = (Object JavaDoc[]) result1;
425       for (int i = 0; i < fbs.length; i++) {
426         if ( ( (FieldBase) fbs[i]).isNull())
427           return IntegerPool.Integer2;
428       }
429     }
430     else
431     if ( ( (FieldBase) result1).isNull())
432       return IntegerPool.Integer2;
433
434     /*dend*/
435     do {
436       int cmp = 0;
437       Object JavaDoc iteratorValue = null;
438       try {
439         iteratorValue = ( (_SelectIterator) iterator).getSelectColumnValues();
440         cmp = comparator.compare(result1, iteratorValue);
441       }
442       catch (NullPointerException JavaDoc ex) {
443         if (!_rowvalueexpressionwithoutboolean3.getByteComparison(object).
444             canUseByteComparison() ||
445             !_tablesubquery0.getByteComparison(object).canUseByteComparison()) {
446           comparator = getAppropriateObjectComparatorInCaseofSubQuery(result1,
447               iteratorValue, serverSession);
448         }
449         else {
450           comparator = getAppropriateSuperComparatorInCaseofSubQuery(result1,
451               iteratorValue, serverSession);
452         }
453         cmp = comparator.compare(result1, iteratorValue);
454       }
455       Object JavaDoc result = booleanResult[Operator - 1][cmp + 2];
456       if (result.hashCode() == 0) {
457         return IntegerPool.Integer0;
458       }
459     }
460     while (iterator.next());
461     /* Done by Kaushik on 23/08/2004 to return appropriate value in case of Null */
462     /*dst Done by Sandeep to solve bug-12420*/
463     return IntegerPool.Integer1;
464     /*dend*/
465   }
466
467   /**
468    * Respective Operator type is returned for the operator string passed.
469    * @param oper
470    * @return
471    * @throws DException
472    */

473   private int getRespectiveOperator(String JavaDoc oper) throws DException {
474     if (oper.equals(EQUALTOSTRING)) {
475       return EQUALTO;
476     }
477     else if (oper.equals(GREATERTHANSTRING)) {
478       return GREATERTHAN;
479     }
480     else if (oper.equals(GREATERTHANEQUALTOSTRING)) {
481       return GREATERTHANEQUALTO;
482     }
483     else if (oper.equals(LESSTHANSTRING)) {
484       return LESSTHAN;
485     }
486     else if (oper.equals(LESSTHANEQUALTOSTRING)) {
487       return LESSTHANEQUALTO;
488     }
489     else if (oper.equals(NOTEQUALTOSTRING) || oper.equals(NOTEQUALTOSTRING1)) {
490       return NOTEQUALTO;
491     }
492     throw new DException("DSE528", new Object JavaDoc[] {oper});
493   }
494
495   /**
496    * This method is called from Browser, when Parameterized query is fired from Browser.
497    * With the help of ParameterInfo Browser open ups daialog box(labelled by its corresponding name)
498    * for each question mark to put the values of question mark.
499    * All the ParameterInfo of subQuery are added into the list.
500    * @return
501    * @throws DException
502    */

503
504   public ParameterInfo[] getParameterInfo() throws DException {
505     ParameterInfo[] p1 = _rowvalueexpressionwithoutboolean3.getParameterInfo();
506     ParameterInfo[] p2 = _tablesubquery0.getParameterInfo()[0].
507         getParameterInfoArray();
508     if (p1 == null && p2 == null) {
509       return null;
510     }
511     if (p1 == null) {
512       return p2;
513     }
514     if (p2 == null) {
515       return p1;
516     }
517     ParameterInfo[] result = new ParameterInfo[p1.length + p2.length];
518     System.arraycopy(p1, 0, result, 0, p1.length);
519     System.arraycopy(p2, 0, result, p1.length, p2.length);
520     return result;
521   }
522
523   public AbstractRowValueExpression[] getChilds() {
524     AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {
525          (AbstractRowValueExpression) (_rowvalueexpressionwithoutboolean3),
526         (AbstractRowValueExpression) (_tablesubquery0)};
527     return childs;
528   }
529
530   public void setDefaultValues(_VariableValueOperations variableValueOperation) throws
531       DException {
532   }
533
534   /**
535    * Performs the semantic Checking of the predicate and the query involved in the predicate.
536    * @param parent
537    * @return
538    * @throws DException
539    */

540   public com.daffodilwoods.daffodildb.server.sql99.utils._Reference[]
541       checkSemantic(com.daffodilwoods.daffodildb.server.serversystem.
542
                    _ServerSession parent) throws DException {
543     getColumnDetails();
544     _Reference[] references = GeneralPurposeStaticClass.getJointReferences(
545         _rowvalueexpressionwithoutboolean3.checkSemantic(parent),
546         _tablesubquery0.checkSemantic(parent));
547     performingCardinalityChecking();
548     checkDataTypes(parent);
549     return references;
550   }
551
552   private void checkDataTypes(_ServerSession session) throws DException {
553     int[] dt1 = _rowvalueexpressionwithoutboolean3.getByteComparison(session).
554         getDataTypes();
555     int[] dt2 = _tablesubquery0.getByteComparison(session).getDataTypes();
556     Check.checkForDataTypes(dt1, dt2);
557   }
558
559   /**
560    * Performs cardinality checking, by cardinality checking we mean the columns involved on both sides of predicates are equal.
561    * @throws DException
562    */

563   private void performingCardinalityChecking() throws DException {
564     int cardinality1 = _rowvalueexpressionwithoutboolean3.getCardinality();
565     int card2 = _tablesubquery0.getCardinality();
566     if (cardinality1 != -1 && card2 != -1 && cardinality1 != card2) {
567       throw new DException("DSE214", null);
568     }
569     if (Operator != -1) {
570       Operator = getRespectiveOperator( (String JavaDoc) _compop2.run(null));
571     }
572   }
573
574   public String JavaDoc toString() {
575     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
576     sb.append(" ");
577     sb.append(_rowvalueexpressionwithoutboolean3);
578     sb.append(" ");
579     sb.append(_compop2);
580     sb.append(" ");
581     sb.append(_quantifier1);
582     sb.append(" ");
583     sb.append(_tablesubquery0);
584     return sb.toString();
585   }
586
587   /**
588    * Returns the estimated no of rows reduced upon solving the predicate.
589    * @param noOfRows
590    * @return
591    * @throws DException
592    */

593   public long getEstimatedRows(long noOfRows) throws DException {
594     if (Operator == -1) {
595       Operator = getRespectiveOperator( (String JavaDoc) _compop2.run(null));
596     }
597     switch (Operator) {
598       case EQUALTO:
599         return noOfRows * CostFactorConstants.EQUALTO / 100;
600       case GREATERTHAN:
601       case LESSTHAN:
602         return noOfRows * CostFactorConstants.GREATERTHAN / 100;
603       case GREATERTHANEQUALTO:
604       case LESSTHANEQUALTO:
605         return noOfRows * CostFactorConstants.GREATERTHANEQUALTO / 100;
606     }
607     return noOfRows;
608   }
609
610   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
611     quantifiedcomparisonpredicate tempClass = new quantifiedcomparisonpredicate();
612     tempClass._tablesubquery0 = (tablesubquery) _tablesubquery0.clone();
613     tempClass._quantifier1 = (quantifier) _quantifier1.clone();
614     tempClass._compop2 = (compop) _compop2.clone();
615     tempClass._rowvalueexpressionwithoutboolean3 = (
616         rowvalueexpressionwithoutboolean) _rowvalueexpressionwithoutboolean3.
617         clone();
618     try {
619       tempClass.getColumnDetails();
620     }
621     catch (DException ex) {
622       throw new RuntimeException JavaDoc(ex.getMessage());
623     }
624     return tempClass;
625   }
626
627   public ColumnDetails[] getColumnDetails() throws DException {
628     if (columnDetails == null) {
629       ColumnDetails[] columnDetails1 = _rowvalueexpressionwithoutboolean3.
630           getColumnDetails();
631       ColumnDetails[] columnDetails2 = _tablesubquery0.getColumnDetails();
632       columnDetails = new ColumnDetails[columnDetails1.length +
633           columnDetails2.length];
634       int i = 0;
635       for (; i < columnDetails1.length; ++i) {
636         columnDetails[i] = columnDetails1[i];
637       }
638       for (int j = 0; j < columnDetails2.length; ++i, ++j) {
639         columnDetails[i] = columnDetails2[j];
640       }
641     }
642     /* Initialize quantifier */
643     String JavaDoc qua = (String JavaDoc) _quantifier1.run(null);
644     quantifier = getQuantifier(qua);
645     Operator = getRespectiveOperator( (String JavaDoc) _compop2.run(null));
646     return columnDetails;
647   }
648
649   /*Method overwridden by Sandeep to solve bug --12577*/
650   protected SuperComparator getAppropriateSuperComparatorInCaseofSubQuery(
651       Object JavaDoc result1, Object JavaDoc iteratorValue, _ServerSession serverSession) throws
652       DException {
653     if (result1 instanceof Object JavaDoc[]) {
654       Object JavaDoc[] rr = (Object JavaDoc[]) result1;
655       Object JavaDoc[] values = (Object JavaDoc[]) iteratorValue;
656       SuperComparator[] comparators = new SuperComparator[rr.length];
657       for (int i = 0; i < rr.length; i++) {
658         comparators[i] = getComparator( (FieldBase) rr[i], (FieldBase) values[i],
659                                        serverSession);
660       }
661       return new ComparisionPredicateJoinComparator(comparators, Operator);
662     }
663     return new CJoDpnqbsbups(new SuperComparator[] {getComparator( (FieldBase)
664         result1, (FieldBase) ( (Object JavaDoc[]) iteratorValue)[0], serverSession)});
665   }
666
667   /*Method overwridden by Sandeep to solve bug --12577*/
668   protected SuperComparator getAppropriateObjectComparatorInCaseofSubQuery(
669       Object JavaDoc result1, Object JavaDoc iteratorValue, _ServerSession serverSession) throws
670       DException {
671     if (result1 instanceof Object JavaDoc[]) {
672       Object JavaDoc[] rr = (Object JavaDoc[]) result1;
673       Object JavaDoc[] values = (Object JavaDoc[]) iteratorValue;
674       SuperComparator[] comparators = new SuperComparator[rr.length];
675       for (int i = 0; i < rr.length; i++) {
676         comparators[i] = new CPckfduDpnqbsbups();
677       }
678       return new ComparisionPredicateJoinComparator(comparators, Operator);
679     }
680     return new CJoDpnqbsbups(new SuperComparator[] {new CPckfduDpnqbsbups()});
681   }
682
683 }
684
Popular Tags