1 package com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition; 2 3 import com.daffodilwoods.daffodildb.server.sql99.common.*; 4 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 5 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.predicates.*; 6 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 7 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 8 import com.daffodilwoods.database.resource.*; 9 10 22 public class RangePredicate extends PredicateAbstract implements booleanvalueexpression, predicate { 23 27 public predicate topPredicate; 28 31 public predicate bottomPredicate; 33 public RangePredicate(predicate topPredicate1, predicate bottomPredicate1) { 34 bottomPredicate = bottomPredicate1; 35 topPredicate = topPredicate1; 36 } 37 42 public predicate getBottomPredicate() throws DException { 43 return bottomPredicate; 44 } 45 50 public predicate getTopPredicate() throws DException { 51 return topPredicate; 52 } 53 54 public void setColumnPredicates(_AllColumnPredicates allColumnPredicates) throws DException { 55 throw new DException("DSE565", new Object [] {"execute()"}); 56 } 57 58 public ParameterInfo[] getParameterInfo() throws DException { 59 throw new DException("DSE565", new Object [] {"getParameterInfo()"}); 60 } 61 public com.daffodilwoods.daffodildb.server.sql99.utils._Reference[] checkSemantic(com.daffodilwoods.daffodildb.server.serversystem._ServerSession parent) throws DException { 62 throw new DException("DSE565", new Object [] {"checkSemantic(queryspecification parent)"}); 63 } 64 65 public Object run(Object object) throws DException { 66 Object cmp = bottomPredicate.run(object); 67 if (cmp.hashCode() == 0) { 68 Object o = topPredicate.run(object); 69 return o; 70 } 71 return cmp; 72 } 73 74 public String toString() { 75 return bottomPredicate + " AND " + topPredicate; 76 } 77 81 public double getCost(long rowCount, boolean index) throws DException { 82 long rowsReduced = topPredicate.getEstimatedRows(rowCount); 83 rowsReduced = bottomPredicate.getEstimatedRows(rowsReduced); 84 if (index) { 85 return rowsReduced * CostFactorConstants.INDEXPREDICATE / 100; 86 } 87 return rowsReduced; 88 } 89 94 public AbstractRowValueExpression[] getChilds() { 95 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {}; 96 return childs; 97 } 98 99 public void setDefaultValues(_VariableValueOperations variableValueOperations) throws DException { 100 } 101 102 109 110 public long getEstimatedRows(long noOfRows) throws DException { 111 long rowCount = topPredicate.getEstimatedRows(noOfRows); 112 return bottomPredicate.getEstimatedRows(rowCount); 113 } 114 119 120 public int getPredicateType() throws DException { 121 return OperatorConstants.RANGE_PREDICATE; 122 } 123 } 124 | Popular Tags |