| 1 package com.daffodilwoods.daffodildb.server.sql99.dql.iterator.table; 2 3 import com.daffodilwoods.daffodildb.client.*; 4 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 5 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record; 6 import com.daffodilwoods.daffodildb.server.sql99.common.*; 7 import com.daffodilwoods.daffodildb.server.sql99.dql.execution.*; 8 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 9 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 10 import com.daffodilwoods.database.general.*; 11 import com.daffodilwoods.database.resource.*; 12 import com.daffodilwoods.database.sqlinitiator.*; 13 import com.daffodilwoods.database.utility.P; 14 import com.daffodilwoods.database.general.SystemFields; 15 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator; 16 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIterator; 17 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo; 18 19 30 public class SingleTableIterator extends BaseSingleIterator implements _TableOperations ,_IndexIteratorInfo{ 31 34 private _Iterator backupIterator; 35 38 private TableDetails tableDetails; 39 42 private _Order order; 43 44 47 private TableDetails[] underLyingTables; 48 private boolean flag = false; 49 50 public SingleTableIterator(_Iterator iterator0, TableDetails tableDetails0, TableDetails[] underLyingTables0, _Order order0) { 51 super(iterator0); 52 backupIterator = iterator0; 53 tableDetails = tableDetails0; 54 underLyingTables = underLyingTables0; 55 order = order0; 56 } 57 58 63 public TableDetails[] getTableDetails() throws com.daffodilwoods.database.resource.DException { 64 return new TableDetails[] {tableDetails}; 65 } 66 67 75 public _Iterator getBaseIterator(ColumnDetails column) throws com.daffodilwoods.database.resource.DException { 76 if (column.getTableDetails() == tableDetails) { 77 return this; 78 } 79 return null; 80 } 81 82 89 public _KeyColumnInformation[] getKeyColumnInformations() throws com.daffodilwoods.database.resource.DException { 90 _KeyColumnInformation[] keyColumnInformation = iterator.getKeyColumnInformations(); 91 try { 92 int rightKeysCount = 0; 93 for (int i = 0; i < keyColumnInformation.length; i++) { 94 rightKeysCount += keyColumnInformation[i].getColumnDetails().getSize(); 95 } 96 } 97 catch (DException ex) { 98 } 99 for (int i = 0, length = keyColumnInformation.length; i < length; ++i) { 100 keyColumnInformation[i].setTableDetails(tableDetails); 101 } 102 return keyColumnInformation; 103 } 104 105 110 public Object getKey() throws DException { 111 Object object = iterator.getKey(); 112 return (object instanceof Object []) ? object : new Object [] {object}; 113 } 114 115 122 public void move(Object parm1) throws DException { 123 try { 124 Object [] array = (Object []) parm1; 125 iterator.move(array.length == 1 ? array[0] : array); 126 } catch (ClassCastException ex) { 127 iterator.move(parm1); 128 } 129 } 130 131 138 public _OrderCount getOrderCounts() throws DException { 139 if (order == null) { 140 return new OrderCount(0, order); 141 } 142 return new OrderCount(order.getKeyColumnDetails().length, order); 143 } 144 145 151 public _Order getDefaultOrder() throws DException { 152 ColumnDetails rowIdCd = new ColumnDetails(); 153 String catalogName = tableDetails.getCatalogName(); 154 String schemaName = tableDetails.getSchemaName(); 155 rowIdCd.setColumnName(new String [] {catalogName, schemaName, SystemFields.systemFields[SystemFields.rowId]}); 156 rowIdCd.setTableDetails(tableDetails); 157 rowIdCd.setType(TypeConstants.REFERENCE); 158 rowIdCd.setDatatype(Datatype.LONG); 159 rowIdCd.setSize(Datatype.LONGSIZE); 160 return new SelectOrder(new ColumnDetails[] {rowIdCd}); 161 } 162 163 168 public _ExecutionPlan getExecutionPlan() throws DException { 169 _ExecutionPlan cplan = iterator.getExecutionPlan(); 170 _ExecutionPlan cplans[] = cplan == null ? null : new _ExecutionPlan[] {cplan}; 171 String order = getOrderString(); 172 ExecutionPlan plan = new ExecutionPlan("SingleTableIterator[" + tableDetails + "]", cplans, null, order, null); 173 return plan; 174 } 175 176 182 private String getOrderString() throws DException { 183 String indexName = ""; 184 boolean[] b = order.getOrderOfColumns(); 185 ColumnDetails[] columns = order.getKeyColumnDetails(); 186 for (int j = 0, length1 = columns.length; j < length1; j++) { 187 indexName += columns[j].getColumn() + " " + (b[j] ? " ASC ," : " DESC ,"); 188 } 189 return indexName; 190 } 191 192 197 public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException { 198 int length = 1; 199 ExecutionPlanForBrowser cplans[] = new ExecutionPlanForBrowser[length]; 200 cplans[0] = iterator.getExecutionPlanForBrowser(); 201 String refer = tableDetails.getAppropriateOnlyTableName(); 202 return iterator.getExecutionPlanForBrowser(); 203 } 204 205 211 public Object [][] getFunctionalColumnMapping() throws DException { 212 return null; 213 } 214 215 public _Iterator getBaseIteratorHasRecord(ColumnDetails parm1) throws DException { 216 return null; 217 } 218 219 public void setKeyCount(Object [][] tableAndKeyCount) throws DException { 220 flag = true; 221 } 222 223 public byte[] getByteKey() throws DException { 224 byte[] keys = null; 225 try { 226 keys = iterator.getByteKey(); 227 } 228 catch (UnsupportedOperationException ex) { 229 throw new DException("DSE0",new Object []{ex.getMessage()}); 230 } 231 return keys; 232 } 233 234 public void moveByteKey(byte[] key) throws DException { 235 if (flag) { 236 byte[] keyAfterRemovingSizeField = new byte[key.length - 1]; 237 System.arraycopy(key, 1, keyAfterRemovingSizeField, 0, 238 keyAfterRemovingSizeField.length); 239 iterator.moveByteKey(keyAfterRemovingSizeField); 240 } 241 else 242 iterator.moveByteKey(key); 243 } 244 245 249 250 public boolean first() throws DException { 251 return iterator.first(); 252 } 253 254 public boolean last() throws DException { 255 return iterator.last(); 256 } 257 258 public boolean next() throws DException { 259 return iterator.next(); 260 } 261 262 public boolean previous() throws DException { 263 return iterator.previous(); 264 } 265 266 public Object getColumnValues() throws DException { 267 return iterator.getColumnValues(); 268 } 269 270 public Object getColumnValues(int[] parm1) throws DException { 271 return iterator.getColumnValues(parm1); 272 } 273 274 public void setConditionVariableValue(_Reference[] parm1, Object [] parm2, int parm3) throws DException { 275 try { 276 if(underlyingRef!=null){ 277 parm1 = GeneralPurposeStaticClass.getJointReferences(parm1,underlyingRef); 278 parm2 = GeneralPurposeStaticClass.getJointValues(this, parm2,underlyingRef.length); 279 } 280 iterator.setConditionVariableValue(parm1, parm2, parm3); 281 } catch (Exception E) { 282 } 283 } 284 285 public _Record getRecord() throws DException { 286 return iterator.getRecord(); 287 } 288 289 public void insert(Object parm1) throws DException { 290 ( (_TableOperations) iterator).insert(parm1); 291 } 292 293 public void update(Object parm1) throws DException { 294 ( (_TableOperations) iterator).update(parm1); 295 } 296 297 public void update(int[] parm1, Object [] parm2) throws DException { 298 ( (_TableOperations) iterator).update(parm1, parm2); 299 } 300 301 public void delete() throws DException { 302 ( (_TableOperations) iterator).delete(); 303 } 304 305 public Object [] getUniqueColumnReference() throws DException { 306 return iterator.getUniqueColumnReference(); 307 } 308 309 public boolean seek(Object parm1) throws DException { 310 return iterator.seek(parm1); 311 } 312 313 public boolean seekFromTop(_IndexPredicate[] parm1) throws DException { 314 return iterator.seekFromTop(parm1); 315 } 316 317 public boolean seekFromTopRelative(Object indexKey) throws DException { 318 return iterator.seekFromTopRelative(indexKey); 319 } 320 321 public boolean seekFromBottom(_IndexPredicate[] parm1) throws DException { 322 return iterator.seekFromBottom(parm1); 323 } 324 325 public boolean seekFromBottomRelative(Object indexKey) throws DException { 326 return iterator.seekFromBottomRelative(indexKey); 327 } 328 329 public Object getUpdatedEffect(_Reference[] references, Object [] values) throws DException { 330 throw new UnsupportedOperationException ("getUpdatedEffect() Not Supported"); 331 } 332 333 public String toString() { 334 try { 335 return "SingleTableIterator" + hashCode() + "[" + iterator + "][" + tableDetails.getNameOfTable() + "]"; 336 } catch (DException d) { 337 return null; 338 } 339 } 340 public void deleteBlobClobRecord(_DatabaseUser user) throws DException { 341 ( (_TableOperations) iterator).deleteBlobClobRecord(user) ; 342 } 343 344 349 public int getBtreeIndex() { 350 return 0; 351 } 352 353 360 public boolean locateKey(Object key, boolean top) throws DException{ 361 return ((_IndexIteratorInfo)iterator).locateKey(key,top) ; 362 } 363 364 367 public void ensureRecordInMemory() throws DException{ 368 ((_IndexIteratorInfo)iterator).ensureRecordInMemory() ; 369 } 370 371 376 public void moveOnActualKey(Object key) throws DException{ 377 ((_IndexIteratorInfo)iterator).moveOnActualKey(key); 378 } 379 380 385 public Object getActualKey() throws DException { 386 return ((_IndexIteratorInfo)iterator).getActualKey() ; 387 } 388 389 395 public boolean seekKeyAddress(Object indexKey) throws DException{ 396 return ((_IndexIteratorInfo)iterator).seekKeyAddress(indexKey); 397 } 398 399 404 public Object getPhysicalAddress() throws DException { 405 return ((_IndexIteratorInfo)iterator).getPhysicalAddress() ; 406 } 407 408 413 public SuperComparator getComparator() { 414 return ((_IndexIteratorInfo)iterator).getComparator() ; 415 } 416 417 422 public SuperComparator getObjectComparator() throws DException{ 423 return ((_IndexIteratorInfo)iterator).getObjectComparator() ; 424 } 425 426 } 427 | Popular Tags |