1 package com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.fromclause; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*; 6 import com.daffodilwoods.daffodildb.server.serversystem.*; 7 import com.daffodilwoods.daffodildb.server.sql99.common.*; 8 import com.daffodilwoods.daffodildb.server.sql99.dql.common.*; 9 import com.daffodilwoods.daffodildb.server.sql99.dql.execution.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*; 11 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.*; 12 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*; 13 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.order.*; 14 import com.daffodilwoods.daffodildb.server.sql99.dql.queryexpression.*; 15 import com.daffodilwoods.daffodildb.server.sql99.dql.semanticchecker.*; 16 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 17 import com.daffodilwoods.daffodildb.server.sql99.token.*; 18 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 19 import com.daffodilwoods.daffodildb.utils.parser.*; 20 import com.daffodilwoods.database.resource.*; 21 import com.daffodilwoods.database.sqlinitiator.*; 22 23 37 38 public class crossjoin implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, joinedtable, TypeConstants, queryexpressionbody, tableprimary { 39 42 public tableprimary _tableprimary0; 43 46 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439221; 47 50 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 51 54 public tablereference _tablereference3; 55 58 private TableDetails[] tableDetails; 59 63 64 private TableDetails[] allTableDetails; 65 66 public crossjoin(tablereference _tablereference4, tableprimary _tableprimary1, TableDetails[] tableDetails0) throws DException { 67 _tablereference3 = _tablereference4; 68 _tableprimary0 = _tableprimary1; 69 tableDetails = tableDetails0; 70 _SRESERVEDWORD12065439221 = new SRESERVEDWORD1206543922(); 71 _SRESERVEDWORD12065439221._SRESERVEDWORD12065439220 = "JOIN"; 72 _SRESERVEDWORD12065439222 = new SRESERVEDWORD1206543922(); 73 _SRESERVEDWORD12065439222._SRESERVEDWORD12065439220 = "CROSS"; 74 getColumnDetails(); 75 } 76 77 public crossjoin() { 78 } 79 80 94 public _TablePlan[] getTablePlan(_ServerSession serverSession, _DatedFramework datedCondition, _BVEPlan bvePlan, _OrderPlan orderPlan, _QueryColumns queryColumns, ConditionArray conditionArray) throws DException { 95 _TablePlan leftPlan[] = _tablereference3.getTablePlan(serverSession, datedCondition, bvePlan, orderPlan, queryColumns, conditionArray); 96 _TablePlan rightPlan[] = _tableprimary0.getTablePlan(serverSession, datedCondition, bvePlan, orderPlan, queryColumns, conditionArray); 97 _TablePlan tablePlans[] = new _TablePlan[leftPlan.length + rightPlan.length]; 98 System.arraycopy(leftPlan, 0, tablePlans, 0, leftPlan.length); 99 System.arraycopy(rightPlan, 0, tablePlans, leftPlan.length, rightPlan.length); 100 return tablePlans; 101 } 102 113 public _TablePlan[] getTablePlans(_ServerSession session, _DatedFramework datedCondition, _BVEPlan bvePlan, _OrderPlan orderPlan, _QueryColumns queryColumns, ConditionArray conditionArray) throws DException { 114 return getTablePlan(session, datedCondition, bvePlan, orderPlan, queryColumns, conditionArray); 115 } 116 117 125 public com.daffodilwoods.daffodildb.server.sql99.utils._Reference[] checkSemantic(com.daffodilwoods.daffodildb.server.serversystem._ServerSession parent, ColumnDetails[] queryColumns, boolean checkUserRight) throws DException { 126 return GeneralPurposeStaticClass.getJointReferences(_tablereference3.checkSemantic(parent, queryColumns, checkUserRight), _tableprimary0.checkSemantic(parent, queryColumns, checkUserRight)); 127 } 128 129 130 136 public TableDetails[] getTableDetails(_ServerSession serverSession, ColumnDetails[] queryColumns) throws DException { 137 TableDetails[] table1 = _tablereference3.getTableDetails(serverSession, queryColumns); 138 TableDetails[] table2 = _tableprimary0.getTableDetails(serverSession, queryColumns); 139 TableDetails[] result = new TableDetails[table1.length + table2.length]; 140 int i; 141 for (i = 0; i < table1.length; i++) { 142 result[i] = table1[i]; 143 } 144 for (int j = 0; j < table2.length; j++, i++) { 145 result[i] = table2[j]; 146 } 147 this.tableDetails = result; 148 return result; 149 } 150 151 public ColumnDetails[] getColumnDetails() throws DException { 152 ColumnDetails[] columnDetails1 = _tablereference3.getColumnDetails(); 153 ColumnDetails[] columnDetails2 = _tableprimary0.getColumnDetails(); 154 return SemanticChecker.addColumnDetails(columnDetails1, columnDetails2); 155 } 156 157 public void getColumnsIncluded(ArrayList aList) throws DException { 158 _tablereference3.getColumnsIncluded(aList); 159 _tableprimary0.getColumnsIncluded(aList); 160 } 161 162 public void getTablesIncluded(ArrayList aList) throws DException { 163 _tablereference3.getTablesIncluded(aList); 164 _tableprimary0.getTablesIncluded(aList); 165 } 166 167 public ParameterInfo[] getParameterInfo() throws DException { 168 ParameterInfo[] parameterInfo1 = _tableprimary0.getParameterInfo(); 169 ParameterInfo[] parameterInfo2 = _tablereference3.getParameterInfo(); 170 if (parameterInfo1 == null && parameterInfo2 == null) { 171 return null; 172 } 173 if (parameterInfo1 == null) { 174 return parameterInfo2; 175 } 176 if (parameterInfo2 == null) { 177 return parameterInfo1; 178 } 179 ParameterInfo[] result = new ParameterInfo[parameterInfo1.length + parameterInfo2.length]; 180 System.arraycopy(parameterInfo1, 0, result, 0, parameterInfo1.length); 181 System.arraycopy(parameterInfo2, 0, result, parameterInfo1.length, parameterInfo2.length); 182 return result; 183 } 184 185 public void setTablesForInsertion(ColumnMappingHandler parm1, _VariableValueOperations vv) throws com.daffodilwoods.database.resource.DException { 186 _tablereference3.setTablesForInsertion(parm1, vv); 187 _tableprimary0.setTablesForInsertion(parm1, vv); 188 } 189 190 public void verifyValues(_VariableValueOperations variableValueOperation) throws DException { 191 } 192 193 public void setDefaultValues(_VariableValueOperations variableValueOperation) throws DException { 194 _tablereference3.setDefaultValues(variableValueOperation); 195 _tableprimary0.setDefaultValues(variableValueOperation); 196 } 197 public Object [] getParameters(Object object) throws DException { 198 Object [] parameter1 = _tableprimary0.getParameters(object); 199 Object [] parameter2 = _tablereference3.getParameters(object); 200 if (parameter1 == null) { 201 return parameter2; 202 } 203 if (parameter2 == null) { 204 return parameter1; 205 } 206 Object [] result = new ParameterInfo[parameter1.length + parameter2.length]; 207 System.arraycopy(parameter1, 0, result, 0, parameter1.length); 208 System.arraycopy(parameter2, 0, result, parameter1.length, parameter2.length); 209 return result; 210 } 211 212 public TableDetails[] getAllTableDetails() throws DException { 213 if (allTableDetails == null) { 214 TableDetails[] td1 = _tablereference3.getAllTableDetails(); 215 TableDetails[] td2 = _tableprimary0.getAllTableDetails(); 216 allTableDetails = GeneralPurposeStaticClass.getJointTableDetails(td1, td2); 217 } 218 return allTableDetails; 219 } 220 221 public TableDetails[] getViewTableDetails() throws DException { 222 TableDetails[] td1 = _tablereference3.getViewTableDetails(); 223 TableDetails[] td2 = _tableprimary0.getViewTableDetails(); 224 return GeneralPurposeStaticClass.getJointTableDetails(td1, td2); 225 } 226 227 public TableDetails[] getTablesForBlankInsert() throws DException { 228 ArrayList arr = new ArrayList(); 229 arr.addAll(Arrays.asList(_tablereference3.getTablesForBlankInsert())); 230 arr.addAll(Arrays.asList(_tableprimary0.getTablesForBlankInsert())); 231 return (TableDetails[]) arr.toArray(new TableDetails[0]); 232 } 233 234 public _BVEPlan getBveExecutionPlan() throws DException { 235 return BVEPlanMerger.mergeTablePlansWithAnd(_tablereference3.getBveExecutionPlan(), _tableprimary0.getBveExecutionPlan()); 236 } 237 238 245 246 public _Reference[] getUnderlyingReferences() throws DException { 247 return GeneralPurposeStaticClass.getJointReferences(_tablereference3.getUnderlyingReferences(), _tableprimary0.getUnderlyingReferences()); 248 } 249 250 public String toString() { 251 StringBuffer sb = new StringBuffer (); 252 sb.append(" "); 253 sb.append(_tablereference3); 254 sb.append(" "); 255 sb.append(_SRESERVEDWORD12065439222); 256 sb.append(" "); 257 sb.append(_SRESERVEDWORD12065439221); 258 sb.append(" "); 259 sb.append(_tableprimary0); 260 return sb.toString(); 261 } 262 263 public Object clone() throws CloneNotSupportedException { 264 crossjoin tempClass = new crossjoin(); 265 tempClass._tableprimary0 = (tableprimary) _tableprimary0.clone(); 266 tempClass._SRESERVEDWORD12065439221 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439221.clone(); 267 tempClass._SRESERVEDWORD12065439222 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439222.clone(); 268 tempClass._tablereference3 = (tablereference) _tablereference3.clone(); 269 return tempClass; 270 } 271 272 281 private OrderMappingWithTableRefernces[] concat(OrderMappingWithTableRefernces[] mapping1, OrderMappingWithTableRefernces[] mapping2) throws DException { 282 OrderMappingWithTableRefernces[] finalOrderMappingWithTableRefernces = new OrderMappingWithTableRefernces[mapping1.length + mapping2.length]; 283 System.arraycopy(mapping1, 0, finalOrderMappingWithTableRefernces, 0, mapping1.length); 284 System.arraycopy(mapping2, 0, finalOrderMappingWithTableRefernces, mapping1.length, mapping2.length); 285 return finalOrderMappingWithTableRefernces; 286 } 287 294 private OrderMappingWithTableRefernces[] changeTableRefernceInMapping(OrderMappingWithTableRefernces mapping1[], OrderMappingWithTableRefernces[] mapping2) throws DException { 295 if (mapping1 == null) { 296 return mapping2; 297 } 298 if (mapping2 == null) { 299 return mapping1; 300 } 301 return concat(mapping1, mapping2); 302 } 303 304 321 public OrderMappingWithTableRefernces[] checkForOrderSequencePlan(_ServerSession session, _OrderPlan orderPlan, _BVEPlan bvePlan, _QueryColumns queryColumns, ConditionArray conditionArray, boolean isUnderLoj) throws DException { 322 OrderMappingWithTableRefernces[] leftMapping = _tablereference3.checkForOrderSequencePlan(session, orderPlan, null, queryColumns, conditionArray, isUnderLoj); 323 OrderMappingWithTableRefernces[] rightMapping = _tableprimary0.checkForOrderSequencePlan(session, orderPlan, null, queryColumns, conditionArray, isUnderLoj); 324 return getJoinOrderMappingWithTableRefernces(leftMapping, rightMapping, isUnderLoj); 325 } 326 327 350 private OrderMappingWithTableRefernces[] getJoinOrderMappingWithTableRefernces(OrderMappingWithTableRefernces[] source1, OrderMappingWithTableRefernces[] source2, boolean isUnderLoj) throws DException { 351 ArrayList array = new ArrayList(); 352 if (isUnderLoj) { 353 if (source1 == null || source2 == null) { 354 return null; 355 } 356 357 for (int i = 0; i < source1.length; i++) { 358 _SingleTableOrderPlan[] source1Stops = source1[i].getStops(); 359 array.addAll(Arrays.asList(source1Stops)); 360 } 361 for (int j = 0; j < source2.length; j++) { 362 _SingleTableOrderPlan[] source2Stops = source2[j].getStops(); 363 array.addAll(Arrays.asList(source2Stops)); 364 } 365 _SingleTableOrderPlan[] resultStops = (_SingleTableOrderPlan[]) array.toArray(new _SingleTableOrderPlan[array.size()]); 366 int resultMatch = resultantMatchOfInnerJoin(source1, source2); 367 return new OrderMappingWithTableRefernces[] {new OrderMappingWithTableRefernces(resultStops, resultMatch, getResultantTableDetails(source1, source2))}; 368 } else { 369 if (source1 == null) { 370 return source2; 371 } 372 if (source2 == null) { 373 return source1; 374 } 375 OrderMappingWithTableRefernces buffered[] = new 376 OrderMappingWithTableRefernces[source1.length + source2.length]; 377 System.arraycopy(source1, 0, buffered, 0, source1.length); 378 System.arraycopy(source2, 0, buffered, source1.length, source2.length); 379 return buffered; 380 } 381 } 382 383 392 private int resultantMatchOfInnerJoin(OrderMappingWithTableRefernces[] 393 source1, 394 OrderMappingWithTableRefernces[] 395 source2) throws 396 DException { 397 int resultMatch = TableExpressionConstants.FULLYMATCHED; 398 int match; 399 for (int i = 0; i < source1.length; i++) { 400 match = source1[i].getMatch(); 401 if (match < resultMatch) { 402 resultMatch = match; 403 } 404 } 405 for (int j = 0; j < source2.length; j++) { 406 match = source2[j].getMatch(); 407 if (match < resultMatch) { 408 resultMatch = match; 409 } 410 } 411 return resultMatch; 412 413 } 414 415 423 private TableDetails[] getResultantTableDetails( 424 OrderMappingWithTableRefernces[] mapping1, 425 OrderMappingWithTableRefernces[] mapping2) throws DException { 426 ArrayList list = new ArrayList(); 427 for (int i = 0; i < mapping1.length; i++) { 428 list.addAll(Arrays.asList(mapping1[i].getTableDetails())); 429 } 430 for (int i = 0; i < mapping2.length; i++) { 431 list.addAll(Arrays.asList(mapping2[i].getTableDetails())); 432 } 433 return (TableDetails[]) list.toArray(new TableDetails[list.size()]); 434 } 435 436 443 444 private OrderMappingWithTableRefernces[] getJoinOrderMappingWithTableRefernces(OrderMappingWithTableRefernces[] source1, OrderMappingWithTableRefernces[] source2) throws DException { 445 if (source1 == null) { 446 return source2; 447 } 448 if (source2 == null) { 449 return source1; 450 } 451 OrderMappingWithTableRefernces buffered[] = new OrderMappingWithTableRefernces[source1.length + source2.length]; 452 System.arraycopy(source1, 0, buffered, 0, source1.length); 453 System.arraycopy(source2, 0, buffered, source1.length, source2.length); 454 return buffered; 455 } 456 457 464 public boolean isSimpleQuery(_ServerSession serverSession) throws DException { 465 return false; 466 } 467 468 474 475 public Object run(Object object) throws com.daffodilwoods.database.resource.DException { 476 throw new DException("DSE16", new Object [] {"run"}); 477 } 478 479 public _Reference[] checkSemantic(_ServerSession session,_OrderByClause orderClause,boolean checkUserRight,boolean checkSetOperatorPresent ) throws DException { 480 throw new DException("DSE565",new Object []{"checkSemantic()"}); 481 } 482 483 public _ColumnCharacteristics getColumnCharacteristics(Object parm1) throws com.daffodilwoods.database.resource.DException { 484 throw new java.lang.UnsupportedOperationException ("Method getColumnCharacteristics() not yet implemented."); 485 } 486 487 public QueryProperty getStrings() throws com.daffodilwoods.database.resource.DException { 488 489 throw new java.lang.UnsupportedOperationException ("Method getStrings() not yet implemented."); 490 } 491 492 public _TablePlan getExecutionPlan(_ServerSession session, booleanvalueexpression bve, _DatedFramework datedCondition, _Order order, ColumnDetails[] cdsWithActualTableDetails, ConditionArray conditionArray) throws DException { 493 494 throw new java.lang.UnsupportedOperationException ("Method getExecutionPlan() not yet implemented."); 495 } 496 497 public void setFKeyColumnDetails(ColumnDetails[] parm1) throws com.daffodilwoods.database.resource.DException { 498 499 throw new java.lang.UnsupportedOperationException ("Method setFKeyColumnDetails() not yet implemented."); 500 } 501 502 public ColumnDetails[] getSelectedColumns() throws com.daffodilwoods.database.resource.DException { 503 504 throw new java.lang.UnsupportedOperationException ("Method getSelectedColumns() not yet implemented."); 505 } 506 507 public _Reference[] getReferences(TableDetails[] tableDetails) throws DException { 508 throw new java.lang.UnsupportedOperationException ("Method getReferences( TableDetails[] ) not yet implemented."); 509 } 510 511 public boolean isViewOptimizationPossible() throws DException { 512 throw new UnsupportedOperationException ("Method isViewOptimizationPossible is not supported."); 513 } 514 515 public _TablePlan[] getTablePlans(_ServerSession session, booleanvalueexpression condition, _Order order, ColumnDetails[] columnDetails, ConditionArray conditionArray) throws DException { 516 throw new UnsupportedOperationException ("Method getTablePlans() not supported"); 517 } 518 519 public boolean hasConstantSelectedColumn(booleanvalueexpression bve) throws DException { 520 throw new UnsupportedOperationException ("Method hasConstantSelectedColumn() not supported"); 521 } 522 } 523 | Popular Tags |