KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sessionsystem > CommittedIterator


1 package com.daffodilwoods.daffodildb.server.sessionsystem;
2
3 import com.daffodilwoods.daffodildb.server.sql99.dql.execution._OrderCount;
4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
5 import java.util.*;
6 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem.*;
7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*;
8 import com.daffodilwoods.daffodildb.server.datasystem.utility.*;
9 import com.daffodilwoods.daffodildb.server.sql99.common.*;
10 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
11 import com.daffodilwoods.database.resource.*;
12 import com.daffodilwoods.database.utility.*;
13 import com.daffodilwoods.database.sqlinitiator._Order;
14 import com.daffodilwoods.database.general.SystemFields;
15 import com.daffodilwoods.daffodildb.client._ExecutionPlan;
16 import com.daffodilwoods.daffodildb.client.ExecutionPlan;
17 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
18 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
19 import com.daffodilwoods.daffodildb.server.sessionsystem.sessioncondition.*;
20
21 /**
22  *
23  * <p>Title: UnionIterator</p>
24  * <p>Description:Objective of the union iterator is to manage the operations of both the iterators
25  * memoryIterator and fileIterator it has.
26  */

27 public class CommittedIterator implements _Iterator, _TableOperations, _UserTableOperations,_IndexIteratorInfo {
28   _Iterator[] iterators;
29   /**
30    * Used to maintain the pointer of the UnionIterator
31    */

32
33   protected Object JavaDoc currentKey;
34   SuperComparator comparator;
35   protected int status;
36   private Object JavaDoc[] sessionIds;
37   _Iterator memoryIteratorSeek;
38   boolean isTempIterator;
39   DException DSE879 = new DException("DSE879", null);
40   /**
41    * Constructs the Union iterator with an array of two index iterators and an index table.
42    * @param iterators0 is an array of two index iterators one to iterate on the memory table and the other to iterate on file table..
43    * @param table0 is an index table that maintains the operations on memory and the file table.
44    */

45
46   protected HashMap exMap;
47
48   BitSet currentIteratorSet;
49   int lengthOfBtreeColunms;
50   Object JavaDoc[] globalKeys = new Object JavaDoc[2];
51   boolean isForward = true;
52   ArrayList rowIdsList;
53
54
55   public CommittedIterator(_Iterator[] iterators0, SuperComparator comparator0,
56                            Object JavaDoc[] sessionId0, _Iterator memoryIteratorSeek0) {
57     iterators = iterators0;
58     comparator = comparator0;
59     status = -1;
60     exMap = new HashMap();
61     currentIteratorSet = new BitSet();
62     sessionIds = sessionId0;
63     memoryIteratorSeek = memoryIteratorSeek0;
64     rowIdsList = new ArrayList(5);
65     try {
66       lengthOfBtreeColunms = ( (int[]) iterators0[0].getUniqueColumnReference()[
67                               0]).length;
68     }
69     catch (Exception JavaDoc ex) {
70     }
71   }
72
73   /**
74    * set it's pointer to the first record in the table
75    * @return true if it gets the key corresponding to the first record in the table.
76    */

77
78   public boolean first() throws DException {
79
80     rowIdsList.clear();
81     int hasFirst = 0;
82     Object JavaDoc[] keys = new Object JavaDoc[iterators.length];
83     for (int i = 0; i < iterators.length; i++) {
84       if (iterators[i] != null && iterators[i].first()) {
85         hasFirst += 1;
86         keys[i] = iterators[i].getKey();
87       }
88
89     }
90     if (hasFirst == 0)
91       return false;
92     getLowestKey(keys);
93     if (currentIteratorSet.get(1)) {
94       Object JavaDoc key = iterators[1].getKey();
95       if (isTempIterator == false && memoryIteratorSeek.seek(key)) {
96         Object JavaDoc invalidSessionId = null;
97         try {
98           invalidSessionId = memoryIteratorSeek.getColumnValues(
99               SessionConditionReferences.invalidSessionIdReference_4);
100         }
101         catch (DException ex) {
102           String JavaDoc dseCode = ex.getDseCode();
103           if (dseCode.equalsIgnoreCase("DSE2019")) {
104             Object JavaDoc rowId = ( (Object JavaDoc[]) globalKeys[1])[lengthOfBtreeColunms - 3];
105             rowIdsList.clear();
106             rowIdsList.add(rowId);
107             isForward = true;
108             return true;
109           }
110           if (dseCode.equalsIgnoreCase("DSE2004"))
111             return next();
112           throw ex;
113         }
114         if (hasSameSessionId(invalidSessionId)) {
115           return next();
116         }
117       }
118     }
119
120     Object JavaDoc rowId = getRowId();
121     rowIdsList.clear();
122     rowIdsList.add(rowId);
123     isForward = true;
124     return true;
125   }
126
127   public void setKeyCount(Object JavaDoc[][] tableAndKeyCount) throws DException {
128     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.dql.interfaces._Iterator method*/
129     throw new java.lang.UnsupportedOperationException JavaDoc("Method setKeyCount() not yet implemented.");
130   }
131
132   /**
133    *
134    * @returns rowID of the current record from File or Memory which is currently set.
135    * @throws DException
136    */

137   private Object JavaDoc getRowId() throws DException {
138     if (currentIteratorSet.get(1))
139       return ( (Object JavaDoc[]) globalKeys[1])[lengthOfBtreeColunms - 3];
140     else
141       return ( (Object JavaDoc[]) globalKeys[0])[lengthOfBtreeColunms - 3];
142   }
143
144   /**
145    *
146    * @param isForward
147    * @param rowId
148    * @return
149    * @throws DException
150    */

151   private boolean checkInList(boolean isForward, Object JavaDoc rowId) throws
152       DException {
153     if (isForward) {
154       if (rowIdsList.contains(rowId))
155         return false;
156       else {
157         rowIdsList.add(rowId);
158         return true;
159       }
160     }
161     else {
162       rowIdsList.clear();
163       rowIdsList.add(rowId);
164       return true;
165     }
166
167   }
168
169   private boolean isRecordValid(boolean forwardCall, Object JavaDoc rowId) throws
170       DException {
171     if (forwardCall) {
172       if (isForward)
173         return checkInList(true, rowId);
174       else
175         return checkInList(false, rowId);
176     }
177     else {
178       if (!isForward)
179         return checkInList(true, rowId);
180       else
181         return checkInList(false, rowId);
182     }
183   }
184
185   private boolean hasSameSessionId(Object JavaDoc invalidSessionId) throws DException {
186     if (isTempIterator)
187       return false;
188     for (int i = 0; i < sessionIds.length; i++) {
189       if (invalidSessionId.equals(sessionIds[i]))
190         return true;
191     }
192     return false;
193   }
194
195   /**
196    * sets the pointer to the last record in the table
197        * @return true if it gets the key corresponding to the last record in the table.
198    */

199
200   public boolean last() throws DException {
201     rowIdsList.clear();
202     int hasLast = 0;
203     Object JavaDoc[] keys = new Object JavaDoc[iterators.length];
204     for (int i = 0; i < iterators.length; i++) {
205       if (iterators[i] != null && iterators[i].last()) {
206         hasLast += 1;
207         keys[i] = iterators[i].getKey();
208       }
209     }
210     if (hasLast == 0)
211       return false;
212     getHighestKey(keys);
213     if (currentIteratorSet.get(1)) {
214       Object JavaDoc key = iterators[1].getKey();
215       if (isTempIterator == false && memoryIteratorSeek.seek(key)) {
216         Object JavaDoc invalidSessionId = null;
217         try {
218           invalidSessionId = memoryIteratorSeek.getColumnValues(
219               SessionConditionReferences.invalidSessionIdReference_4);
220         }
221         catch (DException ex) {
222           if (ex.getDseCode().equalsIgnoreCase("DSE2019")) {
223             Object JavaDoc rowId = ( (Object JavaDoc[]) globalKeys[1])[lengthOfBtreeColunms - 3];
224             rowIdsList.clear();
225             rowIdsList.add(rowId);
226             isForward = false;
227             return true;
228           }
229           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
230             return previous();
231           throw ex;
232         }
233         if (hasSameSessionId(invalidSessionId))
234           return previous();
235       }
236     }
237     Object JavaDoc rowId = getRowId();
238     rowIdsList.clear();
239     rowIdsList.add(rowId);
240     isForward = false;
241     return true;
242   }
243
244   /**
245    * sets the pointer to the next record in the table
246        * @return true if it gets the key corresponding to the next record in the table.
247    */

248
249   public boolean next() throws DException {
250     int hasNext = 0;
251     Object JavaDoc[] keys = new Object JavaDoc[iterators.length];
252     for (int i = 0; i < iterators.length; i++) {
253       if (currentIteratorSet.get(i)) {
254         if (iterators[i].next()) {
255           hasNext++;
256           keys[i] = iterators[i].getKey();
257         }
258       }
259       else {
260         hasNext += globalKeys[i] == null ? 0 : 1;
261         keys[i] = globalKeys[i];
262       }
263     }
264     if (hasNext == 0) {
265       rowIdsList.clear();
266       return false;
267     }
268     getLowestKey(keys);
269     if (currentIteratorSet.get(1)) {
270       Object JavaDoc key = iterators[1].getKey();
271       if (isTempIterator == false && memoryIteratorSeek.seek(key)) {
272         Object JavaDoc invalidSessionId = null;
273         try {
274           invalidSessionId = memoryIteratorSeek.getColumnValues(
275               SessionConditionReferences.invalidSessionIdReference_4);
276         }
277         catch (DException ex) {
278           if (ex.getDseCode().equalsIgnoreCase("DSE2019")) {
279             Object JavaDoc rowId = ( (Object JavaDoc[]) globalKeys[1])[lengthOfBtreeColunms - 3];
280             if (isRecordValid(true, rowId)) {
281               isForward = true;
282               return true;
283             }
284             return next();
285           }
286           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
287             return next();
288           throw ex;
289         }
290         if (hasSameSessionId(invalidSessionId))
291           return next();
292       }
293     }
294     Object JavaDoc rowId = getRowId();
295     if (isRecordValid(true, rowId)) {
296       isForward = true;
297       return true;
298     }
299     return next();
300
301   }
302
303   /**
304    * sets the pointer to the previous record in the table.
305    * @return true if it gets the key corresponding to the previous record in the table.
306    */

307
308   public boolean previous() throws DException {
309     int hasPrevious = 0;
310     Object JavaDoc[] keys = new Object JavaDoc[iterators.length];
311     for (int i = 0; i < iterators.length; i++) {
312       if (iterators[i] == null)
313         continue;
314       if (currentIteratorSet.get(i)) {
315         if (iterators[i].previous()) {
316           hasPrevious += 1;
317           keys[i] = iterators[i].getKey();
318         }
319       }
320       else {
321         hasPrevious += globalKeys[i] == null ? 0 : 1;
322         keys[i] = globalKeys[i];
323       }
324     }
325     if (hasPrevious == 0) {
326       rowIdsList.clear();
327       return false;
328     }
329     getHighestKey(keys);
330     if (currentIteratorSet.get(1)) {
331       Object JavaDoc key = iterators[1].getKey();
332       if (isTempIterator == false && memoryIteratorSeek.seek(key)) {
333         Object JavaDoc invalidSessionId = null;
334         try {
335           invalidSessionId = memoryIteratorSeek.getColumnValues(
336               SessionConditionReferences.invalidSessionIdReference_4);
337         }
338         catch (DException ex) {
339           if (ex.getDseCode().equalsIgnoreCase("DSE2019")) {
340             Object JavaDoc rowId = ( (Object JavaDoc[]) globalKeys[1])[lengthOfBtreeColunms - 3];
341             if (isRecordValid(false, rowId)) {
342               isForward = false;
343               return true;
344             }
345             return previous();
346           }
347           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
348             return previous();
349           throw ex;
350         }
351         if (hasSameSessionId(invalidSessionId))
352           return previous();
353       }
354     }
355     Object JavaDoc rowId = getRowId();
356     if (isRecordValid(false, rowId)) {
357       isForward = false;
358       return true;
359     }
360     return previous();
361   }
362
363   public Object JavaDoc getKey() throws DException {
364     for (int i = 0; i < iterators.length; i++)
365       if (currentIteratorSet.get(i))
366         return iterators[i].getKey();
367     return null;
368   }
369
370   /**
371    * moves the pointer to the given key in the table
372    * @param key Key to which the iterator will move its pointer
373    * @return true true if it gets the record corresponding to the given key in the table.
374    */

375
376   public void move(Object JavaDoc key) throws DException {
377     if (key == null)
378       return;
379     for (int i = 0; i < iterators.length; i++)
380       if (iterators[i] != null) {
381         iterators[i].move(key);
382       }
383   }
384
385   /**
386    * retreives the value of the record at the current pointer from the table.
387    * @param columns array of columns whose value is to be retreived.
388    * @return an array of values corresponding to those columns.
389    */

390
391   public Object JavaDoc getColumnValues(int[] columns) throws DException {
392     for (int i = 0; i < iterators.length; i++) {
393       if (currentIteratorSet.get(i)) {
394         try {
395           return iterators[i].getColumnValues(columns);
396         }
397         catch (DException ex) {
398           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
399             throw DSE879;
400           throw ex;
401         }
402       }
403     }
404     return null;
405   }
406
407   /**
408    * Used to set the current key of all the file iterators to the given key position.
409    * @param currentKey The current key of the iterator
410    * @param newKey The Key to which the iterator will move its pointer.
411    */

412
413   public _KeyColumnInformation[] getKeyColumnInformations() throws DException {
414     return iterators[0].getKeyColumnInformations();
415   }
416
417   public Object JavaDoc[] getUniqueColumnReference() throws DException {
418     return iterators[0].getUniqueColumnReference();
419   }
420
421   public SuperComparator getComparator() {
422     return comparator;
423   }
424
425
426   public Object JavaDoc getColumnValues(_Reference[] parm1) throws com.daffodilwoods.
427
      database.resource.DException {
428     for (int i = 0; i < iterators.length; i++)
429       if (currentIteratorSet.get(i)) {
430         try {
431           return iterators[i].getColumnValues(parm1);
432         }
433         catch (DException ex) {
434           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
435             throw DSE879;
436           throw ex;
437         }
438       }
439     return null;
440   }
441
442   public Object JavaDoc getColumnValues() throws com.daffodilwoods.database.resource.
443
      DException {
444     for (int i = 0; i < iterators.length; i++)
445       if (currentIteratorSet.get(i)) {
446         try {
447           return iterators[i].getColumnValues();
448         }
449         catch (DException ex) {
450           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
451             throw DSE879;
452           throw ex;
453         }
454       }
455     return null;
456   }
457
458   protected void getLowestKey(Object JavaDoc[] values) throws DException {
459     globalKeys = values;
460     BitSet flag = new BitSet();
461     if (values[0] == null) {
462       flag.set(1);
463       currentIteratorSet = flag;
464       return;
465     }
466     else if (values[1] == null) {
467       flag.set(0);
468       currentIteratorSet = flag;
469       return;
470     }
471
472
473     int cmp = lengthOfBtreeColunms == 1 ?
474         comparator.compare( ( (Object JavaDoc[]) values[0])[0],
475                            ( (Object JavaDoc[]) values[1])[0]) :
476         comparator.compare(values[0], values[1]);
477     if (cmp == 0) {
478       flag.set(1);
479       flag.set(0);
480       currentIteratorSet = flag;
481     }
482     else if (cmp < 0) {
483       flag.set(0);
484       currentIteratorSet = flag;
485     }
486     else {
487       flag.set(1);
488       currentIteratorSet = flag;
489     }
490   }
491
492   protected void getHighestKey(Object JavaDoc[] values) throws DException {
493     globalKeys = values;
494     BitSet flag = new BitSet();
495     if (values[0] == null) {
496       flag.set(1);
497       currentIteratorSet = flag;
498       return;
499     }
500     else if (values[1] == null) {
501       flag.set(0);
502       currentIteratorSet = flag;
503       return;
504     }
505     int cmp = lengthOfBtreeColunms == 1 ?
506         comparator.compare( ( (Object JavaDoc[]) values[0])[0],
507                            ( (Object JavaDoc[]) values[1])[0]) :
508         comparator.compare(values[0], values[1]);
509     if (cmp == 0) {
510       flag.set(0);
511       flag.set(1);
512       currentIteratorSet = flag;
513     }
514     else if (cmp > 0) {
515       flag.set(0);
516       currentIteratorSet = flag;
517     }
518     else {
519       flag.set(1);
520       currentIteratorSet = flag;
521     }
522   }
523
524   public boolean seek(Object JavaDoc indexKey) throws DException {
525     try {
526       rowIdsList.clear();
527       if (!iterators[0].seek(indexKey)) {
528         boolean flagOfSecondIterator = iterators[1] != null ?
529             iterators[1].seek(indexKey) : false;
530         if (!flagOfSecondIterator)
531           return false;
532         boolean isLocateKey = ( (_IndexIteratorInfo) iterators[0]).locateKey(
533             indexKey, true);
534         if (!isLocateKey) {
535           getLowestKey(new Object JavaDoc[] {null, iterators[1].getKey()});
536           return true;
537         }
538       }
539       else if (iterators[1] != null) {
540         boolean isLocateKey = ( (_IndexIteratorInfo) iterators[1]).locateKey(
541             indexKey, true);
542         if (!isLocateKey) {
543           getLowestKey(new Object JavaDoc[] {iterators[0].getKey(), null});
544           return true;
545         }
546       }
547       setLowestKey();
548       status = 0;
549       return true;
550     }
551     catch (DException ex) {
552       if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
553         return seek(indexKey);
554       throw ex;
555     }
556
557   }
558
559   public boolean seekFromBottomRelative(Object JavaDoc indexKey) throws DException {
560     int length = iterators.length;
561     Object JavaDoc[] keys = new Object JavaDoc[length];
562     int num = 0;
563     for (int i = 0; i < length; i++) {
564       boolean flag = iterators[i] != null ?
565           iterators[i].seekFromBottomRelative(indexKey) : false;
566       if (flag) {
567         keys[i] = iterators[i].getKey();
568         num++;
569       }
570     }
571     if (num == 0)
572       return false;
573     getHighestKey(keys);
574     return true;
575
576   }
577
578   public boolean seekFromTopRelative(Object JavaDoc indexKey) throws DException {
579     int length = iterators.length;
580     Object JavaDoc[] keys = new Object JavaDoc[length];
581     int num = 0;
582     for (int i = 0; i < length; i++) {
583       boolean flag = iterators[i] != null ?
584           iterators[i].seekFromTopRelative(indexKey) : false;
585       if (flag) {
586         keys[i] = iterators[i].getKey();
587         num++;
588       }
589     }
590     if (num == 0)
591       return false;
592     getLowestKey(keys);
593     return true;
594   }
595
596   public boolean seekFromTop(_IndexPredicate[] condition) throws DException {
597     if (!iterators[0].seekFromTop(condition)) {
598       boolean flagOfSecondIterator = iterators[1] != null ?
599           iterators[1].seekFromTop(condition) : false;
600       if (!flagOfSecondIterator)
601         return false;
602       ( (_IndexIteratorInfo) iterators[0]).locateKey(iterators[1].getKey(), true);
603     }
604     else if (iterators[1] != null)
605       ( (_IndexIteratorInfo) iterators[1]).locateKey(iterators[0].getKey(), true);
606     setLowestKey();
607     status = 0;
608     return true;
609   }
610
611   public boolean seekFromBottom(_IndexPredicate[] condition) throws DException {
612     if (!iterators[0].seekFromBottom(condition)) {
613       boolean flagOfSecondIterator = iterators[1] != null ?
614           iterators[1].seekFromBottom(condition) : false;
615       if (!flagOfSecondIterator)
616         return false;
617       ( (_IndexIteratorInfo) iterators[0]).locateKey(iterators[1].getKey(), false);
618     }
619     else if (iterators[1] != null)
620       ( (_IndexIteratorInfo) iterators[1]).locateKey(iterators[0].getKey(), false);
621     setHighestKey();
622     status = 0;
623     return true;
624   }
625
626   private void setLowestKey() throws DException {
627     int length = iterators.length;
628     Object JavaDoc[] keys = new Object JavaDoc[length];
629     for (int i = 0; i < length; i++) {
630       try {
631         keys[i] = iterators[i] != null ? iterators[i].getKey() : null;
632       }
633       catch (DException ex) {
634         if (!ex.getDseCode().equalsIgnoreCase("DSE2019"))
635           throw ex;
636       }
637     }
638     getLowestKey(keys);
639   }
640
641   private void setHighestKey() throws DException {
642     int length = iterators.length;
643     Object JavaDoc[] keys = new Object JavaDoc[length];
644     for (int i = 0; i < length; i++) {
645       try {
646         keys[i] = iterators[i] != null ? iterators[i].getKey() : null;
647       }
648       catch (DException ex) {
649         if (!ex.getDseCode().equalsIgnoreCase("DSE2019"))
650           throw ex;
651       }
652     }
653     getHighestKey(keys);
654   }
655
656   public void delete(_DatabaseUser user) throws DException {
657     ( (_UserTableOperations) iterators[0]).delete(user);
658   }
659
660   public void delete() throws DException {
661     ( (_TableOperations) iterators[0]).delete();
662   }
663
664   public void insert(_DatabaseUser user, Object JavaDoc values) throws DException {
665     ( (_UserTableOperations) iterators[0]).insert(user, values);
666   }
667
668   public void insert(Object JavaDoc values) throws DException {
669     ( (_TableOperations) iterators[0]).insert(values);
670   }
671
672   public void update(Object JavaDoc values) throws DException {
673     ( (_TableOperations) iterators[0]).update(values);
674   }
675
676   public void update(_DatabaseUser user, Object JavaDoc values) throws DException {
677     ( (_UserTableOperations) iterators[0]).update(user, values);
678   }
679
680   public void update(int[] columns, Object JavaDoc[] values) throws DException {
681     if (currentIteratorSet.get(0))
682       ( (_TableOperations) iterators[0]).update(columns, values);
683     else {
684       ( (_TableOperations) iterators[0]).insert(iterators[1].getColumnValues());
685       ( (_TableOperations) iterators[0]).update(columns, values);
686     }
687
688   }
689
690   public void update(_DatabaseUser user, int[] columns, Object JavaDoc[] values) throws
691       DException {
692     ( (_UserTableOperations) iterators[0]).update(user, columns, values);
693   }
694
695   public _OrderCount getOrderCounts() throws com.daffodilwoods.database.
696
      resource.DException {
697     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.dql.interfaces._Iterator method*/
698     throw new java.lang.UnsupportedOperationException JavaDoc(
699         "Method getOrderCounts() not yet implemented.");
700   }
701
702   public TableDetails[] getTableDetails() throws com.daffodilwoods.database.
703
      resource.DException {
704     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.dql.interfaces._Iterator method*/
705     throw new java.lang.UnsupportedOperationException JavaDoc(
706         "Method getTableDetails() not yet implemented.");
707   }
708
709   public _Iterator getBaseIterator(ColumnDetails column) throws com.
710
      daffodilwoods.database.resource.DException {
711     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.dql.interfaces._Iterator method*/
712     throw new java.lang.UnsupportedOperationException JavaDoc(
713         "Method getBaseIterator() not yet implemented.");
714   }
715
716   public void setConditionVariableValue(_Reference[] parm1, Object JavaDoc[] parm2,
717                                         int parm3) throws com.daffodilwoods.
718
      database.resource.DException {
719     for (int i = 0; i < iterators.length; i++)
720       iterators[i].setConditionVariableValue(parm1, parm2, parm3);
721   }
722
723   public Object JavaDoc getColumnValues(_Reference parm1) throws com.daffodilwoods.
724
      database.resource.DException {
725     for (int i = 0; i < iterators.length; i++)
726       if (currentIteratorSet.get(i)) {
727         try {
728           return iterators[i].getColumnValues(parm1);
729         }
730         catch (DException ex) {
731           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
732             throw DSE879;
733           throw ex;
734         }
735       }
736     return null;
737   }
738
739   public void setIterator(_Iterator parm1) throws com.daffodilwoods.database.
740
      resource.DException {
741     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.utils._VariableValues method*/
742     throw new java.lang.UnsupportedOperationException JavaDoc(
743         "Method setIterator() not yet implemented.");
744   }
745
746   public _Record getRecord() throws com.daffodilwoods.database.resource.
747
      DException {
748     for (int i = 0; i < iterators.length; i++)
749       if (currentIteratorSet.get(i))
750         try {
751           return iterators[i].getRecord();
752         }
753         catch (DException ex) {
754           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
755             throw DSE879;
756           throw ex;
757         }
758     return null;
759   }
760
761   public _Order getDefaultOrder() throws com.daffodilwoods.database.resource.
762
      DException {
763     /**@todo Implement this com.daffodilwoods.daffodildb.server.sql99.dql.interfaces._Iterator method*/
764     throw new java.lang.UnsupportedOperationException JavaDoc(
765         "Method getDefaultOrder() not yet implemented.");
766   }
767
768   public String JavaDoc toString() {
769     return "COMMITTEDITERATOR [" + iterators[0] + " ]";
770   }
771
772   public int getBtreeIndex() throws com.daffodilwoods.database.resource.
773
      DException {
774     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo method*/
775     throw new java.lang.UnsupportedOperationException JavaDoc(
776         "Method getBtreeIndex() not yet implemented.");
777   }
778
779   public boolean locateKey(Object JavaDoc parm1, boolean parm2) throws com.
780
      daffodilwoods.database.resource.DException {
781     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo method*/
782     throw new java.lang.UnsupportedOperationException JavaDoc(
783         "Method locateKey() not yet implemented.");
784   }
785
786   public void ensureRecordInMemory() throws com.daffodilwoods.database.resource.
787
      DException {
788     if (currentIteratorSet.get(1)) {
789       Object JavaDoc key = globalKeys[1];
790       seek(key);
791     }
792   }
793
794   public void moveOnActualKey(Object JavaDoc parm1) throws com.daffodilwoods.database.
795
      resource.DException {
796     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo method*/
797     throw new java.lang.UnsupportedOperationException JavaDoc(
798         "Method moveOnActualKey() not yet implemented.");
799   }
800
801   public Object JavaDoc getActualKey() throws com.daffodilwoods.database.resource.
802
      DException {
803     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo method*/
804     throw new java.lang.UnsupportedOperationException JavaDoc(
805         "Method getActualKey() not yet implemented.");
806   }
807
808
809   public _ExecutionPlan getExecutionPlan() throws DException {
810     int length = iterators.length;
811     _ExecutionPlan cplans[] = new _ExecutionPlan[length + 1];
812     for (int i = 0; i < length; i++) {
813       cplans[i] = iterators[i].getExecutionPlan();
814     }
815     cplans[length] = memoryIteratorSeek.getExecutionPlan();
816     return new ExecutionPlan("CommittedIterator", cplans, null, null, null);
817   }
818
819   public boolean seekKeyAddress(Object JavaDoc indexKey) throws DException {
820     Object JavaDoc[] keys = (Object JavaDoc[]) indexKey; // 0-position => indexKey, 1-position => address
821
if (keys[1] == null)
822       return seek(keys[0]);
823     else {
824       boolean flag = ( (_IndexIteratorInfo) iterators[1]).seekKeyAddress(keys[1]); // call seek key Address with key[1]
825
Object JavaDoc keyValues = iterators[1].getKey();
826       return checkValidity(keyValues, keys[0]);
827     }
828   }
829
830   private boolean checkValidity(Object JavaDoc keyFromFile, Object JavaDoc indexkeys) throws
831       DException {
832     if (iterators[0].seek(keyFromFile)) {
833       return seek(indexkeys);
834     }
835     else {
836       Object JavaDoc[] temp = (Object JavaDoc[]) iterators[1].getColumnValues(new int[] {
837           SystemFields.invalidSessionId, SystemFields.invalidTransactionId});
838       if (!temp[0].equals(SystemFields.maxIntegerValue) &&
839           !temp[1].equals(SystemFields.maxIntegerValue))
840         return seek(indexkeys);
841       else {
842         ( (_IndexIteratorInfo) iterators[0]).locateKey(keyFromFile, true); //locateKey()
843
return true;
844       }
845     }
846   }
847
848   public Object JavaDoc getPhysicalAddress() throws com.daffodilwoods.database.resource.
849
      DException {
850     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexIteratorInfo method*/
851     throw new java.lang.UnsupportedOperationException JavaDoc(
852         "Method getPhysicalAddress() not yet implemented.");
853   }
854
855   public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException {
856     int length = iterators.length;
857     ExecutionPlanForBrowser cplans[] = new ExecutionPlanForBrowser[length + 1];
858     for (int i = 0; i < length; i++) {
859       cplans[i] = iterators[i].getExecutionPlanForBrowser();
860     }
861     cplans[length] = memoryIteratorSeek.getExecutionPlanForBrowser();
862     return new ExecutionPlanForBrowser("CommitedIterator", "CommittedIterator",
863                                        cplans, null, null, null);
864   }
865
866   public Object JavaDoc[][] getFunctionalColumnMapping() throws DException {
867     throw new UnsupportedOperationException JavaDoc(
868         "getFunctionalColumnMapping() Not Supported");
869   }
870
871   public _Iterator getBaseIteratorHasRecord(ColumnDetails colDetails) throws
872       DException {
873     throw new UnsupportedOperationException JavaDoc("Not Supported");
874   }
875
876   public SuperComparator getObjectComparator() throws DException {
877     return ( (_IndexIteratorInfo) iterators[0]).getObjectComparator();
878   }
879
880   public FieldBase field(_Reference reference) throws com.daffodilwoods.
881
      database.resource.DException {
882     for (int i = 0; i < iterators.length; i++)
883       if (currentIteratorSet.get(i)) {
884         try {
885           return iterators[i].field(reference);
886         }
887         catch (DException ex) {
888           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
889             throw DSE879;
890           throw ex;
891         }
892       }
893     return null;
894   }
895
896   public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.
897
      database.resource.DException {
898     for (int i = 0; i < iterators.length; i++)
899       if (currentIteratorSet.get(i)) {
900         try {
901           return iterators[i].fields(references);
902         }
903         catch (DException ex) {
904           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
905             throw DSE879;
906           throw ex;
907         }
908       }
909     return null;
910   }
911
912   public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.
913
      resource.DException {
914     for (int i = 0; i < iterators.length; i++) {
915       if (currentIteratorSet.get(i)) {
916         try {
917           return iterators[i].fields(columns);
918         }
919         catch (DException ex) {
920           if (ex.getDseCode().equalsIgnoreCase("DSE2004"))
921             throw DSE879;
922           throw ex;
923         }
924       }
925     }
926     return null;
927   }
928
929   public void releaseResource() throws DException {
930     for (int i = 0; i < iterators.length; i++) {
931       iterators[i].releaseResource();
932     }
933   }
934   public byte[] getByteKey() throws DException{
935     throw new java.lang.UnsupportedOperationException JavaDoc(
936         "Method getByteKey() not yet implemented.");
937 }
938   public void moveByteKey(byte[] key) throws DException{
939     throw new java.lang.UnsupportedOperationException JavaDoc(
940         "Method moveByteKey() not yet implemented.");
941       }
942
943       public void setSpecificUnderlyingReferences(_Reference[] specificUnderlyingReferences) throws DException{
944         throw new UnsupportedOperationException JavaDoc("Method not yet Implemented");
945       }
946
947       public void deleteBlobClobRecord(_DatabaseUser user) throws DException {
948               ( (_TableOperations) iterators[0]).deleteBlobClobRecord(user) ;
949             }
950
951 }
952
Popular Tags