1 package com.daffodilwoods.daffodildb.server.sessionsystem; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.client.*; 6 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem.*; 7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 8 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record; 9 import com.daffodilwoods.daffodildb.server.sql99.common.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.execution.*; 11 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 12 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 13 import com.daffodilwoods.daffodildb.utils.comparator.*; 14 import com.daffodilwoods.daffodildb.utils.field.*; 15 import com.daffodilwoods.database.resource.*; 16 import com.daffodilwoods.database.sqlinitiator.*; 17 18 23 public class FilterIterator 24 extends BaseExceptionSingleIterator 25 implements _TableIterator, _Iterator, _TableOperations, 26 _UserTableOperations,_IndexIteratorInfo { 27 _Iterator[] iterators; 28 31 32 protected int status; 33 private Object transactionId; 34 35 36 41 42 _Reference[] reference; 43 44 public FilterIterator(_Iterator[] iterators0, _Reference[] references0, 45 Object transactionId0) { 46 iterators = iterators0; 47 reference = references0; 48 transactionId = transactionId0; 49 status = -1; 50 } 51 52 56 57 public boolean first() throws DException { 58 if (iterators[0].first()) { 59 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 60 values[1] = transactionId; 61 iterators[1].setConditionVariableValue(reference, values, 1); 62 if (iterators[1].first()) 63 return next(); 64 return true; 65 } 66 return false; 67 } 68 69 73 74 public boolean last() throws DException { 75 if (iterators[0].last()) { 76 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 77 values[1] = transactionId; 78 iterators[1].setConditionVariableValue(reference, values, 1); 79 if (iterators[1].first()) 80 return previous(); 81 return true; 82 } 83 return false; 84 } 85 public void setKeyCount(Object [][] tableAndKeyCount) throws DException { 86 87 throw new java.lang.UnsupportedOperationException ("Method setKeyCount() not yet implemented."); 88 } 89 90 94 95 public boolean next() throws DException { 96 if (iterators[0].next()) { 97 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 98 values[1] = transactionId; 99 iterators[1].setConditionVariableValue(reference, values, 1); 100 if (iterators[1].first()) 101 return next(); 102 return true; 103 } 104 return false; 105 } 106 107 111 112 public boolean previous() throws DException { 113 if (iterators[0].previous()) { 114 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 115 values[1] = transactionId; 116 iterators[1].setConditionVariableValue(reference, values, 1); 117 if (iterators[1].first()) 118 return previous(); 119 return true; 120 } 121 return false; 122 } 123 124 public Object getKey() throws DException { 125 return iterators[0].getKey(); 126 } 127 128 133 134 public void move(Object key) throws DException { 135 if (key == null) 136 return; 137 iterators[0].move(key); 138 } 139 140 145 146 public Object getColumnValues(int[] columns) throws DException { 147 return iterators[0].getColumnValues(columns); 148 } 149 150 155 156 public void delete(_DatabaseUser user) throws DException { 157 ( (_UserTableOperations) iterators[0]).delete(user); 158 } 159 160 public void delete() throws DException { 161 ( (_TableOperations) iterators[0]).delete(); 162 } 163 164 public void insert(_DatabaseUser user, Object values) throws DException { 165 ( (_UserTableOperations) iterators[0]).insert(user, values); 166 } 167 168 public void insert(Object values) throws DException { 169 ( (_TableOperations) iterators[0]).insert(values); 170 } 171 172 public void update(Object values) throws DException { 173 ( (_TableOperations) iterators[0]).update(values); 174 } 175 176 public void update(_DatabaseUser user, Object values) throws DException { 177 ( (_UserTableOperations) iterators[0]).update(user, values); 178 } 179 180 public void update(int[] columns, Object [] values) throws DException { 181 ( (_TableOperations) iterators[0]).update(columns, values); 182 } 183 184 public void update(_DatabaseUser user, int[] columns, Object [] values) throws 185 DException { 186 ( (_UserTableOperations) iterators[0]).update(user, columns, values); 187 } 188 189 public _KeyColumnInformation[] getKeyColumnInformations() throws DException { 190 return iterators[0].getKeyColumnInformations(); 191 } 192 193 public Object [] getUniqueColumnReference() throws DException { 194 return iterators[0].getUniqueColumnReference(); 195 } 196 197 public int getBtreeIndex() throws DException { 198 return ( (IndexTableIterator) iterators[0]).getBtreeIndex(); 199 } 200 201 public _Record getRecord() throws com.daffodilwoods.database.resource. 202 DException { 203 return iterators[0].getRecord(); 204 } 205 206 public Object getColumnValues(_Reference[] parm1) throws com.daffodilwoods. 207 database.resource.DException { 208 return iterators[0].getColumnValues(parm1); 209 } 210 211 public boolean seek(Object indexKey) throws DException { 212 if (iterators[0].seek(indexKey)) { 213 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 214 values[1] = transactionId; 215 iterators[1].setConditionVariableValue(reference, values, 1); 216 return iterators[1].first() ? false : true; 217 218 } 219 return false; 220 } 221 222 public boolean seekFromBottomRelative(Object indexKey) throws DException { 223 if (iterators[0].seekFromBottomRelative(indexKey)) { 224 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 225 values[1] = transactionId; 226 iterators[1].setConditionVariableValue(reference, values, 1); 227 return iterators[1].first() ? false : true; 228 229 } 230 return false; 231 } 232 233 public boolean seekFromTopRelative(Object indexKey) throws DException { 234 if (iterators[0].seekFromTopRelative(indexKey)) { 235 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 236 values[1] = transactionId; 237 iterators[1].setConditionVariableValue(reference, values, 1); 238 return iterators[1].first() ? false : true; 239 240 } 241 return false; 242 } 243 244 public boolean seekFromTop(_IndexPredicate[] condition) throws DException { 245 if (iterators[0].seekFromTop(condition)) { 246 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 247 values[1] = transactionId; 248 iterators[1].setConditionVariableValue(reference, values, 1); 249 return iterators[1].first() ? false : true; 250 } 251 return false; 252 } 253 254 public boolean seekFromBottom(_IndexPredicate[] condition) throws DException { 255 if (iterators[0].seekFromBottom(condition)) { 256 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 257 values[1] = transactionId; 258 iterators[1].setConditionVariableValue(reference, values, 1); 259 return iterators[1].last() ? false : true; 260 261 } 262 return false; 263 } 264 265 public boolean locateKey(Object key, boolean top) throws DException { 266 if ( ( (_IndexIteratorInfo) iterators[0]).locateKey(key, top)) { 267 Object [] values = (Object []) iterators[0].getColumnValues(new int[] {0, 1}); 268 values[1] = transactionId; 269 iterators[1].setConditionVariableValue(reference, values, 1); 270 return iterators[1].last() ? true : false; 271 272 } 273 return false; 274 } 275 276 public _OrderCount getOrderCounts() throws com.daffodilwoods.database. 277 resource.DException { 278 279 throw new java.lang.UnsupportedOperationException ( 280 "Method getOrderCounts() not yet implemented."); 281 } 282 283 public TableDetails[] getTableDetails() throws com.daffodilwoods.database. 284 resource.DException { 285 286 throw new java.lang.UnsupportedOperationException ( 287 "Method getTableDetails() not yet implemented."); 288 } 289 290 public _Iterator getBaseIterator(ColumnDetails column) throws com. 291 daffodilwoods.database.resource.DException { 292 293 throw new java.lang.UnsupportedOperationException ( 294 "Method getBaseIterator() not yet implemented."); 295 } 296 297 public void setConditionVariableValue(_Reference[] parm1, Object [] parm2, 298 int parm3) throws com.daffodilwoods. 299 database.resource.DException { 300 iterators[0].setConditionVariableValue(parm1, parm2, parm3); 301 } 302 303 public Object getColumnValues() throws com.daffodilwoods.database.resource. 304 DException { 305 return iterators[0].getColumnValues(); 306 } 307 308 public Object getColumnValues(_Reference parm1) throws com.daffodilwoods. 309 database.resource.DException { 310 return iterators[0].getColumnValues(parm1); 311 } 312 313 public void setIterator(_Iterator parm1) throws com.daffodilwoods.database. 314 resource.DException { 315 316 throw new java.lang.UnsupportedOperationException ( 317 "Method setIterator() not yet implemented."); 318 } 319 320 public void addReferences(_Reference[] parm1) throws com.daffodilwoods. 321 database.resource.DException { 322 323 throw new java.lang.UnsupportedOperationException ( 324 "Method addReferences() not yet implemented."); 325 } 326 327 public Object [][] getReferenceAndValuePair() throws com.daffodilwoods. 328 database.resource.DException { 329 330 throw new java.lang.UnsupportedOperationException ( 331 "Method getReferenceAndValuePair() not yet implemented."); 332 } 333 334 public _Order getDefaultOrder() throws com.daffodilwoods.database.resource. 335 DException { 336 337 throw new java.lang.UnsupportedOperationException ( 338 "Method getDefaultOrder() not yet implemented."); 339 } 340 341 public Object getColumnValues(int column) throws DException { 342 343 throw new java.lang.UnsupportedOperationException ( 344 "Method getColumnValues() not yet implemented."); 345 } 346 347 public _ExecutionPlan getExecutionPlan() throws DException { 348 int length = iterators.length; 349 _ExecutionPlan cplans[] = new _ExecutionPlan[length]; 350 for (int i = 0; i < length; i++) { 351 cplans[i] = iterators[i].getExecutionPlan(); 352 } 353 return new ExecutionPlan("FilterIterator", cplans, null, null, null); 354 } 355 356 public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException { 357 int length = iterators.length; 358 ExecutionPlanForBrowser cplans[] = new ExecutionPlanForBrowser[length]; 359 for (int i = 0; i < length; i++) { 360 cplans[i] = iterators[i].getExecutionPlanForBrowser(); 361 } 362 return new ExecutionPlanForBrowser("Filter", "FilterIterator", cplans, 363 "" + Arrays.asList(reference), null, null); 364 } 365 366 public SuperComparator getComparator() { 367 return ( (_IndexIteratorInfo) iterators[0]).getComparator(); 368 } 369 370 public SuperComparator getObjectComparator() throws com.daffodilwoods. 371 database.resource.DException { 372 return ( (_IndexIteratorInfo) iterators[0]).getObjectComparator(); 373 } 374 375 public _Iterator getBaseIteratorHasRecord(ColumnDetails hasRecordColumn) throws 376 DException { 377 throw new DException("DSE565", new Object [] {"getBaseIterator"}); 378 } 379 380 public FieldBase field(_Reference reference) throws com.daffodilwoods. 381 database.resource.DException { 382 return iterators[0].field(reference); 383 } 384 385 public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods. 386 database.resource.DException { 387 return iterators[0].fields(reference); 388 } 389 390 public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database. 391 resource.DException { 392 return iterators[0].fields(columns); 393 } 394 395 public FieldBase field(int column) throws DException { 396 397 throw new java.lang.UnsupportedOperationException ( 398 "Method field() not yet implemented."); 399 } 400 401 public void releaseResource() throws DException { 402 iterators[0].releaseResource(); 403 } 404 405 public void ensureRecordInMemory() throws DException{ 406 ((_IndexIteratorInfo)iterators[0]).ensureRecordInMemory(); 407 } 408 public void moveOnActualKey(Object key) throws DException{ 409 throw new java.lang.UnsupportedOperationException ( 410 "Method moveOnActualKey() not yet implemented."); 411 412 } 413 public Object getActualKey() throws DException{ 414 throw new java.lang.UnsupportedOperationException ( 415 "Method getActualKey() not yet implemented."); 416 417 } 418 public boolean seekKeyAddress(Object indexKey) throws DException{ 419 throw new java.lang.UnsupportedOperationException ( 420 "Method seekKeyAddress() not yet implemented."); 421 422 } 423 public Object getPhysicalAddress () throws DException{ 424 throw new java.lang.UnsupportedOperationException ( 425 "Method getPhysicalAddress() not yet implemented."); 426 } 427 428 public void deleteBlobClobRecord( _DatabaseUser user) throws DException { 429 ( (_TableOperations) iterators[0]).deleteBlobClobRecord(user) ; 430 } 431 432 } 433 | Popular Tags |