1 package com.daffodilwoods.daffodildb.server.sessionsystem; 2 3 import com.daffodilwoods.daffodildb.server.sql99.dql.execution._OrderCount; 4 5 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 6 7 8 9 10 11 12 13 14 15 import com.daffodilwoods.daffodildb.server.datasystem.utility.*; 16 import com.daffodilwoods.database.resource.DException; 17 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 18 import com.daffodilwoods.daffodildb.server.sql99.common._KeyColumnInformation; 19 import com.daffodilwoods.daffodildb.server.sql99.common.TableDetails; 20 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record; 21 import com.daffodilwoods.database.sqlinitiator._Order; 22 import com.daffodilwoods.database.general.*; 23 import com.daffodilwoods.daffodildb.client.*; 24 import com.daffodilwoods.daffodildb.server.sql99.common.ExecutionPlanForBrowser; 25 import com.daffodilwoods.daffodildb.server.sql99.common.ColumnDetails; 26 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 27 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 28 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator; 29 import com.daffodilwoods.daffodildb.server.datasystem.persistentsystem.DatabaseConstants; 30 import com.daffodilwoods.daffodildb.utils.byteconverter.CCzufDpowfsufs; 31 import com.daffodilwoods.daffodildb.utils.FieldUtility; 32 import com.daffodilwoods.daffodildb.utils.BufferRange; 33 34 public class SessionIterator extends BaseExceptionSingleIterator 35 implements _TableOperations,_Iterator, _IndexIteratorInfo{ 36 _Iterator iterator; 37 int[] intValue = {0,1,3}; 38 _Key sessionKey = new SessionKey(); 39 int[] columnIndexes; 40 int[] backUpColumnIndexes; 41 _Reference[] references; 42 Object [] parameters, excludingChild; 43 public static final int LENGTH = 2; 44 48 public SessionIterator(_Iterator iterator0) throws DException{ 49 iterator = iterator0; 50 try { 51 columnIndexes = (int[])(iterator.getUniqueColumnReference())[0]; 52 backUpColumnIndexes = columnIndexes; 53 } 54 catch (Exception ex) { 55 } 56 } 57 58 63 64 public boolean seekFromTop(_IndexPredicate[] condition) throws DException { 65 return iterator.seekFromTop(null); 66 } 67 72 73 public boolean seekFromTopRelative(_IndexPredicate condition) throws DException { 74 return iterator.seekFromTopRelative(null); 75 } 76 81 82 public boolean seekFromBottom(_IndexPredicate[] condition) throws DException { 83 return iterator.seekFromBottom(condition); 84 } 85 86 public void setKeyCount(Object [][] tableAndKeyCount) throws DException { 87 88 throw new java.lang.UnsupportedOperationException ("Method setKeyCount() not yet implemented."); 89 } 90 91 96 97 public boolean seekFromBottomRelative(_IndexPredicate condition) throws DException { 98 return iterator.seekFromBottomRelative(null); 99 } 100 101 107 108 public void reAdjustFileKey(Object currentKey, Object newKey) throws DException { 109 throw new UnsupportedOperationException (" Not supported "); 110 } 111 115 116 public void reAdjustMemoryKey(Object currentKey, Object newKey) throws DException { 117 throw new UnsupportedOperationException (" Not supported "); 118 } 119 120 125 126 public _Record getRecord() throws DException { 127 return iterator.getRecord(); 128 } 129 130 135 136 public boolean first() throws DException { 137 boolean b = iterator.first(); 138 return b; 139 } 140 141 146 147 public boolean last() throws DException { 148 return iterator.last(); 149 } 150 151 156 157 public boolean next() throws DException { 158 return iterator.next(); 159 } 160 161 166 167 public boolean previous() throws DException { 168 return iterator.previous(); 169 } 170 171 176 177 public void insert(Object value) throws DException { 178 ((_TableOperations)iterator).insert(value); 179 } 180 181 186 187 public void update(Object value) throws DException { 188 ((_TableOperations)iterator).update(value); 189 } 190 191 197 198 public void update(int[] columns, Object [] value) throws DException { 199 ((_TableOperations)iterator).update(columns, value); 200 } 201 202 206 207 public void delete() throws DException { 208 ((_TableOperations)iterator).delete(); 209 } 210 211 217 218 public void move(Object key) throws DException { 219 220 if(! iterator.seek(key)){ 221 throw new DException("DSE5528", null); 222 } 223 } 224 225 231 232 public Object getColumnValues(int[] columns) throws DException { 233 return iterator.getColumnValues(columns); 234 } 235 236 public Object getKey() throws DException { 237 return iterator.getColumnValues(columnIndexes); 238 239 } 240 241 242 243 248 249 250 256 257 258 262 263 264 269 270 271 272 273 278 279 public void setConditionVariableValue(VariableValues variableValues) throws DException{ 280 } 281 282 288 289 public Object getColumnValues(_Reference[] reference) throws DException{ 290 Object obj = null; 291 obj = iterator.getColumnValues(reference); 292 return obj; 293 } 294 public Object getColumnValues(_Reference reference) throws DException{ 295 return ((Object [])iterator.getColumnValues( new _Reference[]{ reference}))[0]; 296 } 297 298 305 306 public void setConditionVariableValue(_Reference[] references ,Object [] values , int priority) throws DException{ 307 ((_Iterator)iterator).setConditionVariableValue(references,values,priority); 308 columnIndexes = (int[])(iterator.getUniqueColumnReference())[0]; 309 if(columnIndexes == null){ 310 iterator.getUniqueColumnReference(); 311 } 312 } 313 314 public Object getColumnValues() throws DException{ 315 try{ 316 return ((_Iterator)iterator).getColumnValues(); 317 }catch(ClassCastException ce){ 318 return iterator.getColumnValues((int[])null); 319 } 320 } 321 322 public String toString(){ 323 return "SESSIONITERATOR["+iterator+"]"; 324 } 325 public boolean seek(Object indexKey) throws DException{ 326 return iterator.seek(indexKey); 327 } 328 public Object [] getUniqueColumnReference() throws DException{ 329 return iterator.getUniqueColumnReference(); 330 } 331 public _KeyColumnInformation[] getKeyColumnInformations() throws DException{ 332 return iterator.getKeyColumnInformations(); 333 } 334 public TableDetails[] getTableDetails() throws DException { 335 return null; 336 } 337 public _Iterator getBaseIterator(ColumnDetails column) throws DException { 338 return this; 339 } 340 public boolean seekFromTopRelative(Object indexKey) throws DException { 341 342 throw new java.lang.UnsupportedOperationException ("Method seekFromTopRelative() not yet implemented."); 343 } 344 public boolean seekFromBottomRelative(Object indexKey) throws DException { 345 346 throw new java.lang.UnsupportedOperationException ("Method seekFromBottomRelative() not yet implemented."); 347 } 348 public _OrderCount getOrderCounts() throws com.daffodilwoods.database.resource.DException { 349 return ((_Iterator)iterator).getOrderCounts(); 350 } 351 352 public Object [][] getReferenceAndValuePair() throws DException { 353 throw new java.lang.UnsupportedOperationException ("Method getReferences() not yet implemented."); 354 } 355 public _Order getDefaultOrder() throws com.daffodilwoods.database.resource.DException { 356 357 throw new java.lang.UnsupportedOperationException ("Method getDefaultOrder() not yet implemented."); 358 } 359 360 public void ensureRecordInMemory() throws com.daffodilwoods.database.resource.DException { 361 ((_IndexIteratorInfo)iterator).ensureRecordInMemory(); 362 363 } 364 365 public void moveOnActualKey(Object parm1) throws com.daffodilwoods.database.resource.DException { 366 iterator.seek(parm1); 367 } 368 public Object getActualKey() throws com.daffodilwoods.database.resource.DException { 369 return getKey(); 370 } 371 372 public boolean locateKey(Object parm1, boolean parm2) throws com.daffodilwoods.database.resource.DException { 373 return ((_IndexIteratorInfo)iterator).locateKey(parm1,parm2); 374 } 375 376 public int getBtreeIndex() throws com.daffodilwoods.database.resource.DException { 377 return ((_IndexIteratorInfo)iterator).getBtreeIndex(); 378 } 379 380 public void setReferencesOfReadCommitted(_Reference[] references0, Object [] parameters0, Object [] excludingChild0 ) throws DException{ 381 references = references0; 382 parameters = parameters0; 383 excludingChild = excludingChild0; 384 } 385 386 387 public _ExecutionPlan getExecutionPlan() throws DException{ 388 _ExecutionPlan plan = null; 389 try{ 390 plan = ((_Iterator)iterator).getExecutionPlan(); 391 }catch(ClassCastException cce){ 392 _ExecutionPlan cplans[] = new _ExecutionPlan[]{plan}; 393 return new ExecutionPlan("SessionIterator",cplans,null,null,null); 394 } 395 return plan; 396 } 397 public boolean seekKeyAddress(Object parm1) throws com.daffodilwoods.database.resource.DException { 398 return ((_IndexIteratorInfo)iterator).seekKeyAddress(parm1); 399 } 400 public Object getPhysicalAddress() throws com.daffodilwoods.database.resource.DException { 401 402 throw new java.lang.UnsupportedOperationException ("Method getPhysicalAddress() not yet implemented."); 403 404 } 405 public _Iterator getForeignKeyIterator() throws DException { 406 return (_Iterator)iterator; 407 } 408 409 public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException { 410 ExecutionPlanForBrowser plan = null; 411 try{ 412 plan = ((_Iterator)iterator).getExecutionPlanForBrowser(); 413 }catch(ClassCastException cce){ 414 } 415 return plan; 416 } 417 418 public SuperComparator getComparator() { 419 return ((_IndexIteratorInfo)iterator).getComparator(); 420 } 421 422 public SuperComparator getObjectComparator() throws com.daffodilwoods.database.resource.DException { 423 return ((_IndexIteratorInfo)iterator).getObjectComparator(); 424 } 425 426 public _Iterator getBaseIteratorHasRecord(ColumnDetails hasRecordColumn) throws DException { 427 throw new DException("DSE565",new Object []{"getBaseIterator"}); 428 } 429 public FieldBase field(_Reference reference) throws com.daffodilwoods.database.resource.DException { 430 return ((FieldBase[])iterator.fields( new _Reference[]{ reference}))[0]; 431 } 432 public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.database.resource.DException { 433 FieldBase[] obj = null; 434 obj = iterator.fields(references); 435 return obj; 436 } 437 public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.resource.DException { 438 return iterator.fields(columns); 439 } 440 public void releaseResource() throws DException { 441 iterator.releaseResource(); 442 } 443 public byte[] getByteKey() throws DException{ 444 FieldBase[] columnValues = FieldUtility.changeIntoFildBase(getKey()); 445 int numberOfColumns = columnValues.length; 446 int totalLengthOfKey = numberOfColumns * 2 * LENGTH + LENGTH; 447 for (int i = 0; i < numberOfColumns; i++) { 448 totalLengthOfKey += columnValues[i].getLength(); 449 } 450 byte[] byteKey = new byte[totalLengthOfKey]; 451 int pointer = 0; 452 System.arraycopy(CCzufDpowfsufs.getBytes((short)numberOfColumns),0,byteKey,pointer,LENGTH); 453 pointer+=LENGTH; 454 for (int i = 0; i < numberOfColumns; i++) { 455 short dataType =(short) columnValues[i].getDatatype(); 456 short length = 0; 457 byte[] columnValue = new byte[]{}; 458 if(!columnValues[i].isNull()){ 459 columnValue = columnValues[i].getBytes(); 460 length = (short) columnValue.length; 461 } 462 463 System.arraycopy(CCzufDpowfsufs.getBytes(dataType),0,byteKey,pointer,LENGTH); 464 pointer+=LENGTH; 465 System.arraycopy(CCzufDpowfsufs.getBytes(length),0,byteKey,pointer,LENGTH); 466 pointer+=LENGTH; 467 System.arraycopy(columnValue,0,byteKey,pointer,length); 468 pointer+=length; 469 } 470 return byteKey; 471 } 472 public void moveByteKey(byte[] key) throws DException{ 473 int pointer=0; 474 int numberOfColumns = CCzufDpowfsufs.getShortValue(key,pointer); 475 pointer+=LENGTH; 476 Object [] columnValues = new FieldBase[numberOfColumns]; 477 for (int i = 0; i < numberOfColumns; i++) { 478 int dataType = CCzufDpowfsufs.getShortValue(key,pointer); 479 pointer+=LENGTH; 480 int columnLength = CCzufDpowfsufs.getShortValue(key,pointer); 481 pointer+=LENGTH; 482 byte[] b = new byte[columnLength]; 483 System.arraycopy(key,pointer,b,0,columnLength); 484 BufferRange buffer= null; 485 if (columnLength == 0) 486 buffer = FieldUtility.NULLBUFFERRANGE; 487 else 488 buffer = new BufferRange(b, 0, columnLength); 489 columnValues[i] = FieldUtility.getField(dataType,buffer); 490 pointer+=columnLength; 491 } 492 moveOnActualKey(columnValues); 493 } 494 495 public void deleteBlobClobRecord(_DatabaseUser user) throws DException { 496 ((_TableOperations)iterator).deleteBlobClobRecord(user); 497 } 498 499 500 } 501 | Popular Tags |