@Override public FactPartitionBasedQueryCost add(final FactPartitionBasedQueryCost other) { return new FactPartitionBasedQueryCost(partitionCost + other.partitionCost); }
@Override public StaticQueryCost add(final StaticQueryCost other) { return new StaticQueryCost(staticCost + other.staticCost); }
@Override public String toString() { return getQueryCostType() + "(" + getEstimatedResourceUsage() + ")"; } }
private QueryCost calculateQueryCost(AbstractQueryContext qctx) throws LensException { if (qctx.isOlapQuery()) { QueryCost cost = queryCostCalculator.calculateCost(qctx, this); if (cost != null) { return cost; } } return new FactPartitionBasedQueryCost(Double.MAX_VALUE); }
@Override public QueryCost calculateCost(final AbstractQueryContext queryContext, LensDriver driver) throws LensException { Double cost = getTotalPartitionCost(queryContext, driver); QueryCost queryCost = cost == null ? null : new FactPartitionBasedQueryCost(cost); if (queryCost != null) { queryCost.setQueryCostType(queryCostTypeDecider.decideCostType(queryCost)); } return queryCost; }
@Override public void init(LensDriver lensDriver) throws LensException { QueryCostTypeDecider queryCostTypeDecider = new RangeBasedQueryCostTypeDecider( lensDriver.getConf().get(DRIVER_COST_TYPE_RANGES, DRIVER_QUERY_COST_TYPE_DEFAULT_RANGES)); this.queryCost = new StaticQueryCost(lensDriver.getConf().getDouble(DRIVER_QUERY_COST, DEFAULT_DRIVER_QUERY_COST)); this.queryCost.setQueryCostType(queryCostTypeDecider.decideCostType(this.queryCost)); }
@Test public void testAdd() throws Exception { assertEquals(cost1.add(cost2), new FactPartitionBasedQueryCost(0.5)); }
@Override public QueryCostType decideCostType(@NonNull final QueryCost cost) throws LensException { QueryCostType q = queryCostTypeRangeMap.get(cost.getEstimatedResourceUsage()); log.info("cost was: {}, decided querytype: {}", cost, q); return q; } }
@Override public int compare(LensDriver d1, LensDriver d2) { final QueryCost c1 = ctx.getDriverQueryCost(d1); final QueryCost c2 = ctx.getDriverQueryCost(d2); return c1.compareTo(c2); } });
public QueryCost calculateQueryCost(AbstractQueryContext qctx) throws LensException { return queryCostCalculator.calculateCost(qctx, this); } /**
@BeforeTest public void beforeTest() throws LensException { cost0.setQueryCostType(costRangeQueryTypeDecider.decideCostType(cost0)); cost1.setQueryCostType(costRangeQueryTypeDecider.decideCostType(cost1)); cost11.setQueryCostType(costRangeQueryTypeDecider.decideCostType(cost11)); cost2.setQueryCostType(costRangeQueryTypeDecider.decideCostType(cost2)); scost0.setQueryCostType(costRangeQueryTypeDecider.decideCostType(scost0)); scost1.setQueryCostType(costRangeQueryTypeDecider.decideCostType(scost1)); scost2.setQueryCostType(costRangeQueryTypeDecider.decideCostType(scost2)); } @Test(expectedExceptions = {IllegalArgumentException.class})
@Override public String toString() { return getQueryCostType() + "(" + getEstimatedResourceUsage() + ")"; }
public RangeBasedQueryCostTypeDecider(String queryCostTypeRange) { this.queryCostTypeRangeMap = new QueryCostTypeRangeConf(queryCostTypeRange); }
@Override public FactPartitionBasedQueryCost add(final FactPartitionBasedQueryCost other) { return new FactPartitionBasedQueryCost(partitionCost + other.partitionCost); }
private QueryCost calculateQueryCost(AbstractQueryContext qctx) throws LensException { if (qctx.isOlapQuery()) { QueryCost cost = queryCostCalculator.calculateCost(qctx, this); if (cost != null) { return cost; } } return new FactPartitionBasedQueryCost(Double.MAX_VALUE); }
@Override public String toString() { return getQueryCostType() + "(" + getEstimatedResourceUsage() + ")"; }
@Override public FactPartitionBasedQueryCost parse(String value) { return new FactPartitionBasedQueryCost(Double.parseDouble(value)); } }
@Override public QueryCost getCost() { return new FactPartitionBasedQueryCost(0); } }
@Override public QueryCost calculateCost(AbstractQueryContext queryContext, LensDriver driver) throws LensException { return new FactPartitionBasedQueryCost(10.0); } }
@Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { return new FactPartitionBasedQueryCost(0); }