1 package com.daffodilwoods.daffodildb.server.sql99.dql.iterator.table; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.client.*; 6 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 7 import com.daffodilwoods.daffodildb.server.datasystem.utility._Record; 8 import com.daffodilwoods.daffodildb.server.sql99.common.*; 9 import com.daffodilwoods.daffodildb.server.sql99.dql.execution.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 11 import com.daffodilwoods.daffodildb.server.sql99.dql.resultsetmetadata.*; 12 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 13 import com.daffodilwoods.daffodildb.utils.field.*; 14 import com.daffodilwoods.database.resource.*; 15 import com.daffodilwoods.database.sqlinitiator.*; 16 import com.daffodilwoods.database.utility.P; 17 18 public class SelectIterator extends AbstractColumnIterator implements _SelectQueryIterator { 19 20 21 public SelectIterator(ColumnDetails[] columnDetails, _Iterator iterator0) throws DException { 22 selectColumnDetails = columnDetails; 23 iterator = iterator0; 24 columnCharacteristics = new SelectColumnCharacteristics(columnDetails, getTableCCMapping(iterator0.getTableDetails()), false); 25 keyColumns = iterator.getKeyColumnInformations(); 26 rowReader = new SelectRowReader(columnCharacteristics, null); 27 getOrderCounts(); } 29 30 private Object [][] getTableCCMapping(TableDetails[] tableDetails) throws DException { 31 Object [][] tableCC = new Object [tableDetails.length][2]; 32 for (int i = 0; i < tableDetails.length; i++) { 33 tableCC[i][0] = tableDetails[i]; 34 tableCC[i][0] = tableDetails[i].cc; 35 } 36 return tableCC; 37 } 38 39 public _ColumnCharacteristics getColumnCharacteristics() throws com.daffodilwoods.database.resource.DException { 40 return columnCharacteristics; 41 } 42 43 public _RowReader getRowReader() throws com.daffodilwoods.database.resource.DException { 44 return rowReader; 45 } 46 47 public void setConditionVariableValue(_Reference[] parm1, Object [] parm2, int parm3) throws com.daffodilwoods.database.resource.DException { 48 if(underlyingRef!=null){ 49 parm1 = GeneralPurposeStaticClass.getJointReferences(parm1,underlyingRef); 50 parm2 = GeneralPurposeStaticClass.getJointValues(this, parm2,underlyingRef.length); 51 } 52 iterator.setConditionVariableValue(parm1, parm2, parm3); 53 } 54 55 public Object getColumnValues() throws com.daffodilwoods.database.resource.DException { 56 return iterator.getColumnValues(selectColumnDetails); 57 } 58 59 public TableDetails[] getTableDetails() throws com.daffodilwoods.database.resource.DException { 60 return iterator.getTableDetails(); 61 } 62 63 public _KeyColumnInformation[] getKeyColumnInformations() throws com.daffodilwoods.database.resource.DException { 64 return keyColumns; 65 } 66 67 public Object getColumnValues(_Reference[] parm1) throws com.daffodilwoods.database.resource.DException { 68 73 _Reference[] ref=new _Reference[parm1.length]; 74 for (int i = 0; i < parm1.length; i++) { 75 for (int j = 0; j < selectColumnDetails.length; j++) { 76 79 80 84 if(((ColumnDetails)parm1[i]).getTable()==selectColumnDetails[j].getTable()){ 85 95 if ( ( (ColumnDetails) parm1[i]).getAppropriateColumn(). equalsIgnoreCase(selectColumnDetails[j].getAppropriateColumn())) { 96 ref[i] = selectColumnDetails[j]; 97 break; 98 } 99 } 100 101 } 102 103 if (ref[i] == null) { 104 ; throw new DException("DSE0",new Object []{parm1[i] + "Not Matched with anyOne"}); 106 } 107 } 108 return iterator.getColumnValues(ref); 109 } 110 111 public boolean seekFromTopRelative(Object parm1) throws com.daffodilwoods.database.resource.DException { 112 return iterator.seekFromTopRelative(parm1); 113 } 114 115 public boolean seekFromBottomRelative(Object parm1) throws com.daffodilwoods.database.resource.DException { 116 return iterator.seekFromBottomRelative(parm1); 117 } 118 119 public boolean first() throws com.daffodilwoods.database.resource.DException { 120 return iterator.first(); 121 } 122 123 public boolean last() throws com.daffodilwoods.database.resource.DException { 124 return iterator.last(); 125 } 126 127 public boolean next() throws com.daffodilwoods.database.resource.DException { 128 return iterator.next(); 129 } 130 131 public boolean previous() throws com.daffodilwoods.database.resource.DException { 132 return iterator.previous(); 133 } 134 135 public Object getKey() throws com.daffodilwoods.database.resource.DException { 136 return iterator.getKey(); 137 } 138 139 public Object getColumnValues(int[] parm1) throws com.daffodilwoods.database.resource.DException { 140 return iterator.getColumnValues(parm1); 141 } 142 143 public _Record getRecord() throws com.daffodilwoods.database.resource.DException { 144 throw new java.lang.UnsupportedOperationException ("Method getRecord() not yet implemented."); 145 } 146 147 public Object [] getUniqueColumnReference() throws DException { 148 throw new UnsupportedOperationException (); 149 } 150 151 public boolean seek(Object indexKey) throws DException { 152 throw new UnsupportedOperationException (); 153 } 154 155 public void setIterator(_Iterator iterator0) throws com.daffodilwoods.database.resource.DException { 156 iterator = iterator0; 157 } 158 159 public boolean seekFromTop(_IndexPredicate[] parm1) throws com.daffodilwoods.database.resource.DException { 160 throw new java.lang.UnsupportedOperationException ("Method seekFromTop() not yet implemented."); 161 } 162 163 public boolean seekFromBottom(_IndexPredicate[] parm1) throws com.daffodilwoods.database.resource.DException { 164 throw new java.lang.UnsupportedOperationException ("Method seekFromBottom() not yet implemented."); 165 } 166 167 public Object getColumnValues(_Reference references) throws DException { 168 return iterator.getColumnValues(references); 169 } 170 171 public String toString() { 172 return "SelectIterator[" + iterator + "]"; 173 174 } 175 176 public _OrderCount getOrderCounts() throws DException { 177 return iterator.getOrderCounts(); 178 } 179 180 public Object insert(int[] columnIndexes, Object [] columnValues) throws DException { 181 throw new java.lang.UnsupportedOperationException ("Method insert() not yet implemented."); 182 } 183 184 public Object update(Object key, int[] columnIndexes, Object [] values, Object row) throws DException { 185 throw new java.lang.UnsupportedOperationException ("Method update() not yet implemented."); 186 } 187 188 public void delete(Object key) throws DException { 189 throw new java.lang.UnsupportedOperationException ("Method delete() not yet implemented."); 190 } 191 192 public void addReferences(_Reference[] parm1) throws com.daffodilwoods.database.resource.DException { 193 throw new java.lang.UnsupportedOperationException ("Method addReferences() not yet implemented."); 194 } 195 196 public Object [][] getReferenceAndValuePair() throws DException { 197 throw new java.lang.UnsupportedOperationException ("Method getReferences() not yet implemented."); 198 } 199 200 public _Order getDefaultOrder() throws DException { 201 return iterator.getDefaultOrder(); 202 } 203 204 public Object moveToInsertRow() throws DException { 205 throw new UnsupportedOperationException (); 206 } 207 208 public _ExecutionPlan getExecutionPlan() throws DException { 209 _ExecutionPlan plan = iterator.getExecutionPlan(); 210 _ExecutionPlan cplans[] = plan == null ? null : new _ExecutionPlan[] {plan}; 211 return new ExecutionPlan("SelectIterator", cplans, null, null, null); 212 } 213 214 public _QueryPlan getQueryPlan() throws DException { 215 throw new UnsupportedOperationException (); 216 } 217 218 public Comparator getComparator() throws DException { 219 throw new UnsupportedOperationException (); 220 } 221 222 public Object getSelectColumnValues() throws DException { 223 return iterator.getColumnValues(selectColumnDetails); 224 } 225 226 public void flushInsertedRecord() throws DException { 227 } 228 229 public Object getColumnValueForReference(_Reference reference) throws DException { 230 return iterator.getColumnValues(reference); 231 } 232 233 public FieldBase getFieldValueForReference(_Reference reference) throws DException { 234 return iterator.field(reference); 235 } 236 237 public ExecutionPlanForBrowser getExecutionPlanForBrowser() throws DException { 238 int length = 1; 239 ExecutionPlanForBrowser cplans[] = new ExecutionPlanForBrowser[length]; 240 cplans[0] = iterator.getExecutionPlanForBrowser(); 241 return new ExecutionPlanForBrowser("Select", "Select Iterator", cplans, null, null, null); 242 } 243 244 public Object [][] getFunctionalColumnMapping() throws DException { 245 throw new UnsupportedOperationException ("getFunctionalColumnMapping() Not Supported"); 246 } 247 248 public FieldBase field(_Reference reference) throws com.daffodilwoods.database.resource.DException { 249 return iterator.field(reference); 250 } 251 252 253 public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.database.resource.DException { 254 return iterator.fields(references); 255 } 256 257 public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.resource.DException { 258 throw new java.lang.UnsupportedOperationException ("Method fields() not yet implemented."); 259 } 260 261 public Object getObject() throws DException { 262 return getValues( (Object []) iterator.getColumnValues(selectColumnDetails)); 263 } 264 265 private Object [] getValues(Object [] values) throws DException { 266 Object [] newValues = new Object [values.length]; 267 for (int i = 0; i < values.length; i++) { 268 newValues[i] = ( (FieldBase) values[i]).getObject(); 269 } 270 return newValues; 271 } 272 273 public boolean isUpdatable() throws DException { 274 return false; 275 } 276 public byte[] getByteKey() throws DException { 277 return iterator.getByteKey(); 278 } 279 public void moveByteKey(byte[] key) throws DException { 280 iterator.moveByteKey(key); 281 } 282 283 284 public int[] getDataTypes() throws DException { 285 int length = selectColumnDetails.length; 286 int[] dataTypes = new int[length]; 287 for (int i = 0; i < length; i++) { 288 dataTypes[i] = selectColumnDetails[i].getDatatype(); 289 } 290 return dataTypes; 291 } 292 293 public Object getColumnValues(ArrayList alist) throws com.daffodilwoods.database.resource.DException { 294 return iterator.getColumnValues(selectColumnDetails); 295 } 296 297 298 299 } 300 | Popular Tags |