KickJava   Java API By Example, From Geeks To Geeks.

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


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.ExceptAllIterator;
7 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.set.ExceptDistinctIterator;
8 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
9 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass;
10 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes;
11 import com.daffodilwoods.daffodildb.utils.GetByteComparator;
12 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
13 import com.daffodilwoods.daffodildb.utils.comparator.CKpjoDpnqbsbups;
14
15 /**
16  * It represents a plan which genrated whenever two search pattern combined with
17  * logical AND Operator.first search pattern is single word or array of single word
18  * and second search pattern is a pattren with Not operator(means second
19  * search pattern is of type NotFullTextPredicate ).It provides functionality to
20  * get resultset.
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 OptimizedNotPredicate implements _FullTextPredicate{
30   /**
31    * This represents first search pattern ,It will be single word or array of single word.
32    */

33   _Word word;
34   /**
35    * this represents second search pattern,Not attribute is appended in front of
36    * this search pattern.
37    */

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

42   String JavaDoc columnName;
43   private _Order order;
44
45   public OptimizedNotPredicate(_Word word0,_FullTextPredicate notPredicate0 ) {
46     word = word0;
47     notPredicate = notPredicate0;
48   }
49   /**
50    * This method is used to get type of plan which is required to merged two
51    * plan either with Logically AND and OR Operator.
52    * @return type of plan
53    * @throws DException
54    */

55   public int getType() throws DException{
56     return PredicateConstant.optimizedNotPredicate;
57   }
58   /**
59    * It is required to get columnName of searched column against which search
60    * pattern is searched.
61    * @return columnName
62    * @throws DException
63    */

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

73  public void setColumn(String JavaDoc colName) throws DException{
74    word.setColumn(colName);
75    notPredicate.setColumn(colName);
76  }
77   public double getCost() throws DException {
78     return 0.0;
79   }
80   public double getCost(Object JavaDoc session) throws DException {
81     return 0.0;
82   }
83   /**
84    * It provides functionality of plan execution which gives resultset.ResultantResultset contains
85    * those all documents of first resultSet EXCEPT Second Resultset.
86    * @param session
87    * @return _Iterator
88    * @throws DException
89    */

90   public _Iterator execute(Object JavaDoc session) throws DException {
91     _Iterator iter1 = word.execute(session);
92     _Iterator iter2 = ( (NotFullTextPredicate) notPredicate).getWordIterator(session);
93     _Reference[] leftReferences = new _Reference[] {
94      GeneralPurposeStaticClass.getColumnDetails("documentId")};
95     _Reference[] rightReferences = new _Reference[] {
96      GeneralPurposeStaticClass.getColumnDetails("documentId")};
97      SuperComparator comparator = GetByteComparator.getComparator(Datatypes.LONG, true, null);
98      CKpjoDpnqbsbups joinComparator = new CKpjoDpnqbsbups(new SuperComparator[] {comparator});
99     _Reference[] orderLeftColumnDetails = new _Reference[] {GeneralPurposeStaticClass.getColumnDetails("documentId")};
100     _Reference[] orderRightColumnDetails = new _Reference[] {GeneralPurposeStaticClass.getColumnDetails("documentId")};
101     return new ExceptDistinctIterator(iter1, iter2, leftReferences,
102                                       rightReferences, joinComparator,
103                                       orderLeftColumnDetails,
104                                       orderRightColumnDetails, joinComparator,
105                                       joinComparator);
106
107 }
108
109
110    public double getEstimatedRow() throws DException {
111       return 1;
112    }
113    public void setOrder(_Order order) throws DException {
114       this.order = order;
115    }
116    public _Order getOrder() throws DException {
117       return order;
118    }
119    /**
120     * This method is used to get first search pattern.It is required by plan Merger
121     * when first plan is of type single word and second is of type OptimizedNotPredicate
122     * It merge single word of first plan with first search pattern of optimizedNotPredicate
123     * @return _Word
124     * @throws DException
125     */

126    public _Word getWord() throws DException{
127       return word;
128    }
129    /**
130     * Sets the first search pattern. It is required during the merging of word
131     * with OptimizedNotPredicate.
132     * @param word0
133     * @throws DException
134     */

135    public void setWord(_Word word0) throws DException{
136       word = word0;
137    }
138
139    /**
140     * It allows for execution of plan,which gives a resultset.ResultSet provides
141     * records in sorted order.this method required to get record in sorted order.
142     * @param session
143     * @return _Iterator
144     * @throws DException
145     */

146    public _Iterator executeForSortedResult(Object JavaDoc indexTable) throws DException{
147       return execute(indexTable);
148    }
149 }
150
Popular Tags