| 1 package com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.predicates; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition.*; 7 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.table.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 9 import com.daffodilwoods.daffodildb.server.sql99.expression.expressionprimary.*; 10 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 11 import com.daffodilwoods.daffodildb.server.sql99.token.*; 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.utility.*; 16 17 26 public class nullpredicate extends PredicateAbstract implements predicate, IntegerPool, ExecutionPlanConstants { 27 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439220; 28 public SRESERVEDWORD1206543922 _OptSRESERVEDWORD12065439221; 29 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 30 public rowvalueexpressionwithoutboolean _rowvalueexpressionwithoutboolean3; 31 32 39 public double getCost(long rowCount, boolean index) throws DException { 40 return rowCount * CostFactorConstants.NONINDEXPREDICATE / 100; 41 } 42 43 69 public _QualifiedBVE getQualifiedBVE(TableDetails[] tableDetails) throws DException { 70 ArrayList uniqueTableDetailsList = getUniqueTableDetails(new ArrayList(),columnDetails); 71 if (uniqueTableDetailsList.size() != 1) { 72 return new QualifiedBVE(null, BVEPlanMerger.getBooleanFactor(this)); 73 } 74 QualifiedBVE qualifiedBVE = getQualifiedBVEifBelongsToSingleTablePlan(tableDetails, uniqueTableDetailsList); 75 if (qualifiedBVE == null) { 76 qualifiedBVE = new QualifiedBVE(null, BVEPlanMerger.getBooleanFactor(this)); 77 } 78 return qualifiedBVE; 79 } 80 81 94 private QualifiedBVE getQualifiedBVEifBelongsToSingleTablePlan(TableDetails[] planTableDetails, ArrayList uniqueTableDetailsList) throws DException { 95 TableDetails conditionTableDetail = (TableDetails) uniqueTableDetailsList.get(0); 96 for (int j = 0, length1 = planTableDetails.length; j < length1; j++) { 97 if (planTableDetails[j] == conditionTableDetail) { 98 BVESingleTablePlan bveSingleTablePlan = new BVESingleTablePlan(BVEPlanMerger.getBooleanFactor(this), conditionTableDetail); 99 return new QualifiedBVE(new BVESingleTablePlan[] {bveSingleTablePlan} 100 , null); 101 } 102 } 103 return null; 104 } 105 106 130 131 136 137 public int getPredicateType() throws DException { 138 if (_OptSRESERVEDWORD12065439221 != null) { 139 return OperatorConstants.NOTNULL; 140 } 141 return OperatorConstants.NULLPREDICATE_IN_QUALIFIEDPLAN; 142 } 143 144 162 163 public void setColumnPredicates(_AllColumnPredicates allColumnPredicates) throws DException { 164 if (checkForSubQuery() || _OptSRESERVEDWORD12065439221 != null || checkForOtherCases()) { 165 allColumnPredicates.addToNonIndex(new booleanfactor(new booleantest(this))); 166 return; 167 } 168 SingleColumnPredicate singleColumnPredicate = new SingleColumnPredicate(); 169 singleColumnPredicate.setColumnName(columnDetails[0].getColumn()); 170 singleColumnPredicate.setPredicate(this); 171 allColumnPredicates.addSinglePredicate(new SingleColumnPredicate[] {singleColumnPredicate}); 172 } 173 174 184 185 private boolean checkForOtherCases() throws DException { 186 if (columnDetails.length != 1) { 187 return true; 188 } 189 return! (columnDetails[0].getType() == REFERENCE) || columnDetails[0].getUnderLyingReference(); 190 } 191 192 198 199 private boolean checkForComplexInnerQuery() throws DException { 200 _Reference[] references = getReferences(null); 201 int length = references.length; 202 for (int i = 0; i < length; i++) { 203 if (references[i].getReferenceType() == SimpleConstants.SUBQUERY) { 204 if ( ( (subquery) references[i]).getUnderlyingReferences() != null) { 205 return true; 206 } 207 } 208 } 209 return false; 210 } 211 212 229 230 private int getBVEPlanType(ArrayList tableList) throws DException { 231 for (int i = 0; i < columnDetails.length; i++) { 232 int type = columnDetails[i].getType(); 233 if (type == GROUPING) { 234 return BVEConstants.BVEAGGREGATEPLAN; 235 } 236 if (type == SCALARFUNCTION || type == CASEEXPRESSION || type == FUNCTIONAL || type == USERFUNCTION ) { 237 return BVEConstants.BVEALLTABLEPLAN; 238 } 239 if (type != CONSTANT) { 240 TableDetails tableDetail = columnDetails[i].getTableDetails(); 241 if (tableDetail != null && !tableList.contains(tableDetail)) { 242 tableList.add(tableDetail); 243 } 244 } 245 } 246 if (checkForSubQuery() && checkForComplexInnerQuery()) { 247 return BVEConstants.BVEALLTABLEPLAN; 248 } 249 int size = tableList.size(); 250 if (size == 1) { 251 return BVEConstants.BVESINGLETABLEPLAN; 252 } else if (size == 2) { 253 return BVEConstants.BVEJOINRELATION; 254 } else { 255 return BVEConstants.BVEALLTABLEPLAN; 256 } 257 } 258 259 276 277 public _BVEPlan getExecutionPlan() throws DException { 278 ArrayList tableList = new ArrayList(); 279 int type = getBVEPlanType(tableList); 280 281 BVESingleTablePlan[] bveSTP = null; 282 int size = tableList.size(); 283 if (size > 1) { 284 bveSTP = new BVESingleTablePlan[size]; 285 for (int i = 0; i < size; i++) { 286 bveSTP[i] = new BVESingleTablePlan(BVEPlanMerger.getBooleanFactor(this), (TableDetails) tableList.get(i)); 287 } 288 } 289 290 switch (type) { 291 case BVEConstants.BVEAGGREGATEPLAN: 292 return new BVEAggregatePlan(BVEPlanMerger.getBooleanFactor(this)); 293 case BVEConstants.BVESINGLETABLEPLAN: 294 return new BVESingleTablePlan(BVEPlanMerger.getBooleanFactor(this), (TableDetails) tableList.get(0)); 295 case BVEConstants.BVEJOINRELATION: 296 _JoinRelation sr = new SimpleRelation( (TableDetails[]) tableList.toArray(new TableDetails[0]), BVEPlanMerger.getBooleanFactor(this)); 297 AllTablesJoinRelation atjr = new AllTablesJoinRelation(new _JoinRelation[] {sr}); 298 return new BVEAllTablePlan(bveSTP, atjr, BVEPlanMerger.getBooleanFactor(this)); 299 case BVEConstants.BVEALLTABLEPLAN: 300 return new BVEAllTablePlan(bveSTP, null, BVEPlanMerger.getBooleanFactor(this)); 301 } 302 throw new DException("DSE3547", new Object [] {this.toString()}); 303 } 304 305 317 318 public Object run(Object object) throws DException { 319 Object result = _rowvalueexpressionwithoutboolean3.run(object); 320 boolean nullValue = true; 321 try { 322 nullValue = ( (FieldBase) result).isNull(); 323 } catch (ClassCastException ex) { 324 Object [] values = (Object []) result; 325 FieldBase[] fieldBases = GeneralPurposeStaticClass.changeIntoFieldBase(values); 326 for (int i = 0, length = fieldBases.length; i < length; i++) { 327 if(_OptSRESERVEDWORD12065439221 != null && fieldBases[i].isNull()){ 328 nullValue=true; 329 break; 330 } 331 nullValue &= fieldBases[i].isNull(); 332 } 333 } 334 return _OptSRESERVEDWORD12065439221 == null ? nullValue ? IntegerPool.Integer0 : IntegerPool.Integer1 335 : nullValue ? IntegerPool.Integer1 : IntegerPool.Integer0; 336 } 337 338 public ParameterInfo[] getParameterInfo() throws DException { 339 return _rowvalueexpressionwithoutboolean3.getParameterInfo(); 340 } 341 342 public AbstractRowValueExpression[] getChilds() { 343 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] { (AbstractRowValueExpression) (_rowvalueexpressionwithoutboolean3)}; 344 return childs; 345 } 346 347 public ColumnDetails[] getColumnDetails() throws DException { 348 if (columnDetails == null) { 349 columnDetails = _rowvalueexpressionwithoutboolean3.getColumnDetails(); 350 for (int i = 0, length = columnDetails.length; i < length; i++) { 351 columnDetails[i].setAsBelongToAllowedPredicateColumn(); 352 } 353 } 354 return columnDetails; 355 } 356 357 public void setDefaultValues(_VariableValueOperations variableValueOperation) throws DException { 358 } 359 360 public com.daffodilwoods.daffodildb.server.sql99.utils._Reference[] checkSemantic(com.daffodilwoods.daffodildb.server.serversystem._ServerSession parent) throws DException { 361 return _rowvalueexpressionwithoutboolean3.checkSemantic(parent); 362 } 363 364 public String toString() { 365 StringBuffer sb = new StringBuffer (); 366 sb.append(" "); 367 sb.append(_rowvalueexpressionwithoutboolean3); 368 sb.append(" "); 369 sb.append(_SRESERVEDWORD12065439222); 370 sb.append(" "); 371 if (_OptSRESERVEDWORD12065439221 != null) { 372 sb.append(_OptSRESERVEDWORD12065439221); 373 } 374 sb.append(" "); 375 sb.append(_SRESERVEDWORD12065439220); 376 return sb.toString(); 377 } 378 379 public boolean isNullPredicate() throws DException { 380 return true; 381 } 382 383 public Object clone() throws CloneNotSupportedException { 384 nullpredicate tempClass = new nullpredicate(); 385 tempClass._SRESERVEDWORD12065439220 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439220.clone(); 386 if (_OptSRESERVEDWORD12065439221 != null) { 387 tempClass._OptSRESERVEDWORD12065439221 = (SRESERVEDWORD1206543922) _OptSRESERVEDWORD12065439221.clone(); 388 } 389 tempClass._SRESERVEDWORD12065439222 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439222.clone(); 390 tempClass._rowvalueexpressionwithoutboolean3 = (rowvalueexpressionwithoutboolean) _rowvalueexpressionwithoutboolean3.clone(); 391 try { 392 tempClass.getColumnDetails(); 393 } catch (DException ex) { 394 throw new RuntimeException (ex.getMessage()); 395 } 396 return tempClass; 397 } 398 } 399 | Popular Tags |