KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > fulltext > dql > condition > OrFullTextpredicate


1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition;
2
3 import com.daffodilwoods.database.resource.DException;
4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
5 import com.daffodilwoods.database.sqlinitiator._Order;
6 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.set.
7
    UnionDistinctIterator;
8 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
9 import com.daffodilwoods.daffodildb.server.sql99.common.
10
    GeneralPurposeStaticClass;
11 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes;
12 import com.daffodilwoods.daffodildb.utils.GetByteComparator;
13 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
14 import com.daffodilwoods.daffodildb.utils.comparator.CKpjoDpnqbsbups;
15
16 /**
17  * This class represents plan which generated when search pattern is combination
18  * of two search pattern combined with logical OR operator.it provides functionality
19  * to get resultset on execution of plan.plan generated will not be optimized.
20  * optimized plan:-plan is optimized if it will provide resultset based on
21  * Rank iterator.so in this,Resultset gives union of underlying two
22  * resultset.
23  * <p>Title: </p>
24  * <p>Description: </p>
25  * <p>Copyright: Copyright (c) 2003</p>
26  * <p>Company: </p>
27  * @author not attributable
28  * @version 1.0
29  */

30
31  public class OrFullTextpredicate implements _FullTextPredicate {
32   /**
33    * This represents plan of first search pattern
34    */

35   _FullTextPredicate leftPredicate;
36   /**
37    * This represents plan of second search pattern
38    */

39   _FullTextPredicate rightPredicate;
40   /**
41    * columnName against which search pattern is searched
42    */

43   String JavaDoc columnName;
44   private _Order order;
45
46   public OrFullTextpredicate(_FullTextPredicate leftPredicate,
47                              _FullTextPredicate rightPredicate) {
48     this.leftPredicate = leftPredicate;
49     this.rightPredicate = rightPredicate;
50   }
51
52   /**
53    * this method is used to get type of plan which is required to merged two
54    * plan either with Logically AND and OR Operator.
55    * @return type of plan
56    * @throws DException
57    */

58   public int getType() throws DException {
59     return PredicateConstant.orFullTextPredicate;
60   }
61
62   /**
63    * It is required to get columnName of searched column against which search
64    * pattern is searched.
65    * @return columnName
66    * @throws DException
67    */

68   public String JavaDoc getColumn() throws DException {
69     return columnName = leftPredicate.getColumn();
70   }
71
72   /**
73    * It is used to set columnName of searched column against which search
74    * pattern is searched.
75    * @param colName
76    * @throws DException
77    */

78   public void setColumn(String JavaDoc colName) throws DException {
79     leftPredicate.setColumn(colName);
80     rightPredicate.setColumn(colName);
81   }
82
83   public double getCost() throws DException {
84     return 0.0;
85   }
86
87   public double getCost(Object JavaDoc session) throws DException {
88     return 0.0;
89   }
90
91   /**
92    * It allows for execution of plan,which gives a resultset.ResultSet used for
93    * navigating records.Resultset contains records which is union of both
94    * underlying resultset.
95    * @param session
96    * @return _Iterator
97    * @throws DException
98    */

99   public _Iterator execute(Object JavaDoc session) throws DException {
100     int[] appropriateDataType = new int[] {
101         Datatypes.LONGSIZE};
102     _Iterator leftIterator = leftPredicate.executeForSortedResult(session);
103     _Iterator rightIterator = rightPredicate.executeForSortedResult(session);
104     _Reference[] leftReferences = new _Reference[] {
105         GeneralPurposeStaticClass.getColumnDetails("documentId")};
106     _Reference[] rightReferences = new _Reference[] {
107         GeneralPurposeStaticClass.getColumnDetails("documentId")};
108     SuperComparator comparator = new CKpjoDpnqbsbups(new SuperComparator[] {
109         GetByteComparator.getComparator(Datatypes.LONG, true, null)});
110     _Reference[] orderLeftColumnDetails = new _Reference[] {
111         GeneralPurposeStaticClass.getColumnDetails("documentId")};
112     _Reference[] orderRightColumnDetails = new _Reference[] {
113         GeneralPurposeStaticClass.getColumnDetails("documentId")};
114
115     return new UnionDistinctIterator(leftIterator, rightIterator,leftReferences, rightReferences,comparator, appropriateDataType,appropriateDataType,orderLeftColumnDetails,orderRightColumnDetails, comparator,comparator);
116   }
117
118   public double getEstimatedRow() throws DException {
119     return 1;
120   }
121
122   public void setOrder(_Order order) throws DException {
123     this.order = order;
124   }
125
126   public _Order getOrder() throws DException {
127     return order;
128   }
129
130   /**
131    * It allows for execution of plan,which gives a resultset.ResultSet used for
132    * navigating records.Resultset contains records which is common in
133    * underlying resultset.
134    * @param session
135    * @return _Iterator
136    * @throws DException
137    */

138   public _Iterator executeForSortedResult(Object JavaDoc indexTable) throws DException {
139     return execute(indexTable);
140   }
141 }
142
Popular Tags