KickJava   Java API By Example, From Geeks To Geeks.

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


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.utils._Reference;
7 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass;
8 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
9 import com.daffodilwoods.daffodildb.utils.comparator.CKpjoDpnqbsbups;
10 import com.daffodilwoods.daffodildb.utils.GetByteComparator;
11 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.set.UnionDistinctIterator;
12 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes;
13
14 /**
15  * This class represents a plan ,which generated when search pattern is combination
16  * of two serach pattern combined with logical OR operator and underlying plan
17  * resultset are not able to give documents in sorted order.It provide
18  * functioanlity to get resultset which provides documents in sorted order.
19  * ResultSet contains documents in which either all or any serach pattern are
20  * present.
21  * <p>Title: </p>
22  * <p>Description: </p>
23  * <p>Copyright: Copyright (c) 2003</p>
24  * <p>Company: </p>
25  * @author not attributable
26  * @version 1.0
27  */

28
29 public class AnyKeyWordSortedPredicate implements _FullTextPredicate {
30
31   /**
32    * It represents plan of first search pattern.
33    */

34   _FullTextPredicate leftPredicate ;
35   /**
36    * It represents plan of second search pattern.
37    */

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

42    String JavaDoc columnName;
43    _Order order;
44
45
46   public AnyKeyWordSortedPredicate(_FullTextPredicate leftPredicate0,_FullTextPredicate rightPredicate0) {
47     leftPredicate = leftPredicate0;
48     rightPredicate = rightPredicate0;
49
50   }
51
52   /**
53    * This method is used to get type of plan which is required plan merger to merged
54    * two 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.anyKeyWordSortedPredicate;
60   }
61   /**
62    * It is required to get columnName of searched column against which search
63    * pattern is searched.
64    * @return columnName
65    * @throws DException
66    */

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

77   public void setColumn(String JavaDoc colName) throws DException {
78     leftPredicate.setColumn(colName);
79     rightPredicate.setColumn(colName);
80   }
81   public double getCost() throws DException {
82     return 0.0;
83   }
84   public double getCost(Object JavaDoc session) throws DException {
85     return 0.0;
86   }
87   /**
88    * It provides functionality of plan execution.Which gives resultset,Resultset
89    * contains documents which are union of underlying resultset.
90    * @param session
91    * @return _Iterator
92    * @throws DException
93    */

94   public _Iterator execute(Object JavaDoc session) throws DException {
95     _Iterator leftIterator = leftPredicate.executeForSortedResult(session);
96     _Iterator rightIterator = rightPredicate.executeForSortedResult(session) ;
97     _Reference[] leftReferences = new _Reference[]{GeneralPurposeStaticClass.getColumnDetails("documentId")};
98     _Reference[] rightReferences = new _Reference[]{GeneralPurposeStaticClass.getColumnDetails("documentId")};
99      SuperComparator comparator = new CKpjoDpnqbsbups(new SuperComparator[]{GetByteComparator.getComparator(Datatypes.LONG,true,null)});
100     _Reference[] orderLeftColumnDetails = new _Reference[]{GeneralPurposeStaticClass.getColumnDetails("documentId")};
101     _Reference[] orderRightColumnDetails = new _Reference[]{GeneralPurposeStaticClass.getColumnDetails("documentId")};
102     int[] appropriateDataType = new int[]{Datatypes.LONGSIZE};
103
104     return new UnionDistinctIterator(leftIterator,rightIterator,leftReferences,rightReferences,comparator,appropriateDataType,appropriateDataType,orderLeftColumnDetails,orderRightColumnDetails,comparator,comparator);
105   }
106   public double getEstimatedRow() throws DException {
107     return 1;
108   }
109   public void setOrder(_Order order0) throws DException {
110     this.order = order0;
111   }
112   public _Order getOrder() throws DException {
113     return order;
114   }
115   /**
116    * It provides functionality of plan execution which gives resultset. Resultset
117    * contains documents which are union of underlying resultset.
118    * @param session
119    * @return _Iterator
120    * @throws DException
121    */

122   public _Iterator executeForSortedResult(Object JavaDoc indexTable) throws DException{
123     return execute(indexTable);
124   }
125
126
127 }
128
Popular Tags