Beispiel #1
0
 @Override
 public double getRows() {
   // REVIEW jvs 30-May-2005:  I just pulled this out of a hat.
   double dRows = RelMetadataQuery.getRowCount(inputs.get(0));
   for (int i = 1; i < inputs.size(); i++) {
     dRows -= 0.5 * RelMetadataQuery.getRowCount(inputs.get(i));
   }
   if (dRows < 0) {
     dRows = 0;
   }
   return dRows;
 }
Beispiel #2
0
    @Override
    public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
      // We always "build" the
      double rowCount = mq.getRowCount(this);

      return planner.getCostFactory().makeCost(rowCount, 0, 0);
    }
Beispiel #3
0
  @Override
  public RelOptCost computeSelfCost(RelOptPlanner planner) {
    if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
      // We use multiplier 0.05 for TopN operator, and 0.1 for Sort, to make TopN a preferred
      // choice.
      return super.computeSelfCost(planner).multiplyBy(.1);
    }

    RelNode child = this.getInput();
    double inputRows = RelMetadataQuery.getRowCount(child);
    // int  rowWidth = child.getRowType().getPrecision();
    int numSortFields = this.collation.getFieldCollations().size();
    double cpuCost =
        DrillCostBase.COMPARE_CPU_COST
            * numSortFields
            * inputRows
            * (Math.log(inputRows) / Math.log(2));
    double diskIOCost =
        0; // assume in-memory for now until we enforce operator-level memory constraints

    // TODO: use rowWidth instead of avgFieldWidth * numFields
    // avgFieldWidth * numFields * inputRows
    double numFields = this.getRowType().getFieldCount();
    long fieldWidth =
        PrelUtil.getPlannerSettings(planner)
            .getOptions()
            .getOption(ExecConstants.AVERAGE_FIELD_WIDTH_KEY)
            .num_val;

    double memCost = fieldWidth * numFields * inputRows;

    DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
    return costFactory.makeCost(inputRows, cpuCost, diskIOCost, 0, memCost);
  }
Beispiel #4
0
 public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
   double dRows = mq.getRowCount(this);
   double dCpu = mq.getRowCount(getInput()) * program.getExprCount();
   double dIo = 0;
   return planner.getCostFactory().makeCost(dRows, dCpu, dIo);
 }