KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > fulltext > dql > iterator > ContainsIterator


1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.iterator;
2
3 import com.daffodilwoods.daffodildb.server.sql99.utils.BaseExceptionSingleIterator;
4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
5 import com.daffodilwoods.database.resource.DException;
6 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
7 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference;
8 import com.daffodilwoods.daffodildb.server.sql99.common.ColumnDetails;
9 import com.daffodilwoods.daffodildb.server.sql99.common._KeyColumnInformation;
10 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
11 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIterator;
12 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo;
13 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass;
14 import com.daffodilwoods.daffodildb.server.sql99.common.ExecutionPlanForBrowser;
15
16 /**
17  * <p>Title: ContainsIterator </p>
18  * <p>Description: This Class handles the rank based retrival of records.
19  * This Class handles the retrival of any particular attribute from the record
20  * either full-text indexed column or non full-text indexed column. </p>
21  * <p>Copyright: Copyright (c) 2003</p>
22  * <p>Company: </p>
23  * @author not attributable
24  * @version 1.0
25  */

26 public class ContainsIterator extends BaseExceptionSingleIterator implements _IndexIteratorInfo{
27
28   /**
29    * Iterator having the records after union of all rank1,2 and 3 iterators.
30    */

31   _Iterator fullTextIndex;
32   /**
33    * Iterator with the records of the table on which full text feature is enabled.
34    */

35   _Iterator tableIterator;
36   /**
37    * Attribute having the column name, type and table name.
38    */

39   ColumnDetails[] documentId;
40
41 public ContainsIterator(_Iterator fullTextIterator,_Iterator tableIterator)throws DException{
42     fullTextIndex = fullTextIterator;
43     this.tableIterator = tableIterator;
44     documentId = new ColumnDetails[]{GeneralPurposeStaticClass.getColumnDetails("documentId")};
45   }
46
47   /**
48    * Points the union iterator to the first record.
49    * @return true if record found, false otherwise.
50    * @throws DException
51    */

52   public boolean first() throws DException {
53     return fullTextIndex.first();
54   }
55
56   /**
57    * Points the union iterator to the next record.
58    * @return true if record found, false otherwise.
59    * @throws DException
60    */

61   public boolean next() throws DException {
62     return fullTextIndex.next();
63   }
64
65   /**
66    * Points the union iterator to the last record.
67    * @return true if record found, false otherwise.
68    * @throws DException
69    */

70   public boolean last() throws DException {
71     return fullTextIndex.last();
72   }
73
74   /**
75    * Points the union iterator to the previous record.
76    * @return true if record found, false otherwise.
77    * @throws DException
78    */

79   public boolean previous() throws DException {
80     return fullTextIndex.previous();
81   }
82
83   /**
84    * This method is used to retrive all values from
85    * the full-text indexed tableiterator current position.
86    * This method alignes the table iterator based on document
87    * id and retreives the values from full-text indexed table.
88    * @return an object array of values of current record.
89    * @throws DException
90    */

91   public Object JavaDoc getColumnValues() throws DException {
92     tableIterator.seek(fullTextIndex.getColumnValues(documentId));
93     return tableIterator.getColumnValues();
94   }
95
96   public Object JavaDoc getColumnValues(int[] columns) throws DException {
97     tableIterator.seek(fullTextIndex.getColumnValues(documentId));
98     return tableIterator.getColumnValues(columns);
99   }
100
101   public Object JavaDoc getColumnValues(_Reference[] references) throws DException {
102     Object JavaDoc[] fbsToRet = new Object JavaDoc[references.length];
103     for (int i = 0; i < references.length; i++) {
104       fbsToRet[i] = getColumnValues(references[i]);
105     }
106     return fbsToRet;
107   }
108
109   public Object JavaDoc getColumnValues(_Reference reference) throws DException {
110     tableIterator.seek(fullTextIndex.getColumnValues(documentId));
111     return tableIterator.getColumnValues(reference);
112   }
113
114   public FieldBase field(_Reference reference) throws com.daffodilwoods.database.resource.DException {
115     tableIterator.seek(fullTextIndex.getColumnValues(documentId));
116     return tableIterator.field(reference);
117   }
118
119   public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.database.resource.DException {
120     FieldBase[] fbsToRet = new FieldBase[references.length];
121     for (int i = 0; i < references.length; i++) {
122       fbsToRet[i] = field(references[i]);
123     }
124     return fbsToRet;
125   }
126
127   public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.resource.DException {
128     return (FieldBase[]) getColumnValues(columns);
129   }
130
131   public Object JavaDoc[] getUniqueColumnReference() throws DException {
132     return tableIterator.getUniqueColumnReference();
133   }
134
135   public _KeyColumnInformation[] getKeyColumnInformations() throws DException {
136     return tableIterator.getKeyColumnInformations();
137   }
138   public int getBtreeIndex() throws DException {
139     return ((_IndexIteratorInfo)tableIterator).getBtreeIndex();
140   }
141   public boolean locateKey(Object JavaDoc key, boolean top) throws DException {
142     return ((_IndexIteratorInfo)tableIterator).locateKey(key,top);
143
144   }
145   public void ensureRecordInMemory() throws DException {
146     ((_IndexIteratorInfo)tableIterator).ensureRecordInMemory();
147   }
148   public void moveOnActualKey(Object JavaDoc key) throws DException {
149     ((_IndexIteratorInfo)tableIterator).moveOnActualKey(key);
150   }
151   public Object JavaDoc getActualKey() throws DException {
152     return ((_IndexIteratorInfo)tableIterator).getActualKey();
153
154   }
155   public boolean seekKeyAddress(Object JavaDoc indexKey) throws DException {
156     return ((_IndexIteratorInfo)tableIterator).seekKeyAddress(indexKey);
157   }
158   public Object JavaDoc getPhysicalAddress() throws DException {
159     return ((_IndexIteratorInfo)tableIterator).getPhysicalAddress();
160   }
161   public SuperComparator getComparator() {
162     return ((_IndexIteratorInfo)tableIterator).getComparator();
163   }
164   public SuperComparator getObjectComparator() throws DException {
165     return ((_IndexIteratorInfo)tableIterator).getObjectComparator();
166
167   }
168   public void setConditionVariableValue(_Reference[] references, Object JavaDoc[] values, int priority) throws DException {
169     tableIterator.setConditionVariableValue(references,values,priority);
170
171   }
172   public String JavaDoc toString(){
173     String JavaDoc str = "Contains[FullTextIndex["+fullTextIndex+"]Table["+tableIterator+"]]";
174     return str;
175   }
176
177   public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException {
178      ExecutionPlanForBrowser cplan = tableIterator.getExecutionPlanForBrowser();
179      ExecutionPlanForBrowser cplans[] = cplan == null ? null :
180      new ExecutionPlanForBrowser[] {
181      cplan};
182      ExecutionPlanForBrowser plan = new ExecutionPlanForBrowser("ContainsClause",
183          "ContainsIterator", cplans, null, null, null);
184      return plan;
185    }
186
187 }
188
Popular Tags