当前位置: 首页>>代码示例>>Java>>正文


Java RelOptCost类代码示例

本文整理汇总了Java中org.apache.calcite.plan.RelOptCost的典型用法代码示例。如果您正苦于以下问题:Java RelOptCost类的具体用法?Java RelOptCost怎么用?Java RelOptCost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RelOptCost类属于org.apache.calcite.plan包,在下文中一共展示了RelOptCost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  RelNode child = this.getInput();
  double inputRows = RelMetadataQuery.getRowCount(child);

  int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
  double hashCpuCost = DrillCostBase.HASH_CPU_COST * inputRows * distFields.size();
  double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
  double mergeCpuCost = DrillCostBase.COMPARE_CPU_COST * inputRows * (Math.log(numEndPoints)/Math.log(2));
  double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
  DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, hashCpuCost + svrCpuCost + mergeCpuCost, 0, networkCost);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:HashToMergeExchangePrel.java

示例2: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  double leftRowCount = RelMetadataQuery.getRowCount(this.getLeft());
  double rightRowCount = RelMetadataQuery.getRowCount(this.getRight());
  double nljFactor = PrelUtil.getSettings(getCluster()).getNestedLoopJoinFactor();

  // cpu cost of evaluating each leftkey=rightkey join condition
  double joinConditionCost = DrillCostBase.COMPARE_CPU_COST * this.getLeftKeys().size();

  double cpuCost = joinConditionCost * (leftRowCount * rightRowCount) * nljFactor;

  DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
  return costFactory.makeCost(leftRowCount * rightRowCount, cpuCost, 0, 0, 0);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:NestedLoopJoinPrel.java

示例3: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
/**
 * A SingleMergeExchange processes a total of M rows coming from N
 * sorted input streams (from N senders) and merges them into a single
 * output sorted stream. For costing purposes we can assume each sender
 * is sending M/N rows to a single receiver.
 * (See DrillCostBase for symbol notations)
 * C =  CPU cost of SV remover for M/N rows
 *     + Network cost of sending M/N rows to 1 destination.
 * So, C = (s * M/N) + (w * M/N)
 * Cost of merging M rows coming from N senders = (M log2 N) * c
 * Total cost = N * C + (M log2 N) * c
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  RelNode child = this.getInput();
  double inputRows = RelMetadataQuery.getRowCount(child);
  int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
  double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
  double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
  int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints();
  double mergeCpuCost = DrillCostBase.COMPARE_CPU_COST * inputRows * (Math.log(numEndPoints)/Math.log(2));
  DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, svrCpuCost + mergeCpuCost, 0, networkCost);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:28,代码来源:SingleMergeExchangePrel.java

示例4: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  RelNode child = this.getInput();
  double inputRows = RelMetadataQuery.getRowCount(child);

  int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;

  double rangePartitionCpuCost = DrillCostBase.RANGE_PARTITION_CPU_COST * inputRows;
  double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
  double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
  DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, rangePartitionCpuCost + svrCpuCost, 0, networkCost);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:OrderedPartitionExchangePrel.java

示例5: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:SortPrel.java

示例6: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
/**
 * HashToRandomExchange processes M input rows and hash partitions them
 * based on computing a hash value on the distribution fields.
 * If there are N nodes (endpoints), we can assume for costing purposes
 * on average each sender will send M/N rows to 1 destination endpoint.
 * (See DrillCostBase for symbol notations)
 * Include impact of skewness of distribution : the more keys used, the less likely the distribution will be skewed.
 * The hash cpu cost will be proportional to 1 / #_keys.
 * C =  CPU cost of hashing k fields of M/N rows
 *      + CPU cost of SV remover for M/N rows
 *      + Network cost of sending M/N rows to 1 destination.
 * So, C = (h * 1/k * M/N) + (s * M/N) + (w * M/N)
 * Total cost = N * C
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }

  RelNode child = this.getInput();
  double inputRows = RelMetadataQuery.getRowCount(child);

  int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;

  double hashCpuCost = DrillCostBase.HASH_CPU_COST * inputRows / fields.size();
  double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
  double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
  DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, hashCpuCost + svrCpuCost, 0, networkCost);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:32,代码来源:HashToRandomExchangePrel.java

示例7: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  if (joincategory == JoinCategory.CARTESIAN || joincategory == JoinCategory.INEQUALITY) {
    return ((DrillCostFactory)planner.getCostFactory()).makeInfiniteCost();
  }
  double leftRowCount = RelMetadataQuery.getRowCount(this.getLeft());
  double rightRowCount = RelMetadataQuery.getRowCount(this.getRight());
  // cost of evaluating each leftkey=rightkey join condition
  double joinConditionCost = DrillCostBase.COMPARE_CPU_COST * this.getLeftKeys().size();
  double cpuCost = joinConditionCost * (leftRowCount + rightRowCount);
  DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
  return costFactory.makeCost(leftRowCount + rightRowCount, cpuCost, 0, 0);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:MergeJoinPrel.java

示例8: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
/**
 * In a BroadcastExchange, each sender is sending data to N receivers (for costing
 * purposes we assume it is also sending to itself).
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner) {
  if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }

  RelNode child = this.getInput();

  final int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints();
  final double broadcastFactor = PrelUtil.getSettings(getCluster()).getBroadcastFactor();
  final double inputRows = RelMetadataQuery.getRowCount(child);

  final int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
  final double cpuCost = broadcastFactor * DrillCostBase.SVR_CPU_COST * inputRows ;
  final double networkCost = broadcastFactor * DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth * numEndPoints;

  return new DrillCostBase(inputRows, cpuCost, 0, networkCost);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:BroadcastExchangePrel.java

示例9: computeCartesianJoinCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
protected  RelOptCost computeCartesianJoinCost(RelOptPlanner planner) {
  final double probeRowCount = RelMetadataQuery.getRowCount(this.getLeft());
  final double buildRowCount = RelMetadataQuery.getRowCount(this.getRight());

  final DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();

  final double mulFactor = 10000; // This is a magic number,
                                  // just to make sure Cartesian Join is more expensive
                                  // than Non-Cartesian Join.

  final int keySize = 1 ;  // assume having 1 join key, when estimate join cost.
  final DrillCostBase cost = (DrillCostBase) computeHashJoinCostWithKeySize(planner, keySize).multiplyBy(mulFactor);

  // Cartesian join row count will be product of two inputs. The other factors come from the above estimated DrillCost.
  return costFactory.makeCost(
      buildRowCount * probeRowCount,
      cost.getCpu(),
      cost.getIo(),
      cost.getNetwork(),
      cost.getMemory() );

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:DrillJoinRelBase.java

示例10: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
  // Make the cost inversely proportional to the height of the rel tree under this node.  We want to maximize the
  // height of the tree because we want to pushdown as much as possible to the jdbc source.  The main problem here is the
  // Projects.  ProjectRelBase.computeSelfCost() generally returns a cost of "tiny" (which is 1).  So, even if we
  // match LogicalProject to two different options with the same cost (one with Project on top of JdbcRel, and another with
  // JdbcProject below JdbcRel), we may choose the one with Project on top of JdbcRel.  This is because if the costs
  // are the same, calcite will choose the first plan option it generated.

  // Compute the height of the tree.
  int minDepth = MoreRelOptUtil.getDepth(input);
  if (minDepth <= 0) {
    return planner.getCostFactory().makeInfiniteCost();
  }
  return planner.getCostFactory().makeCost(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE).multiplyBy(1.0/minDepth);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:JdbcCrel.java

示例11: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery relMetadataQuery) {
  for (AggregateCall aggCall : getAggCallList()) {
    // For avg, stddev_pop, stddev_samp, var_pop and var_samp, the ReduceAggregatesRule is supposed
    // to convert them to use sum and count. Here, we make the cost of the original functions high
    // enough such that the planner does not choose them and instead chooses the rewritten functions.
    if (aggCall.getAggregation().getKind() == SqlKind.AVG
        || aggCall.getAggregation().getKind() == SqlKind.STDDEV_SAMP
        || aggCall.getAggregation().getKind() == SqlKind.STDDEV_POP
        || aggCall.getAggregation().getKind() == SqlKind.VAR_POP
        || aggCall.getAggregation().getKind() == SqlKind.VAR_SAMP) {
      return planner.getCostFactory().makeHugeCost();
    }
  }

  final double rowCount = relMetadataQuery.getRowCount(this);
  final double childRowCount = relMetadataQuery.getRowCount(this.getInput());
  // Aggregates with more aggregate functions cost a bit more
  float multiplier = 1f + (float) aggCalls.size() * 0.125f;
  return ((Factory) planner.getCostFactory()).makeCost(rowCount,childRowCount * multiplier * DremioCost.FUNC_CPU_COST, 0, 0);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:AggregateRel.java

示例12: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
  if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  double leftRowCount = mq.getRowCount(this.getLeft());
  double rightRowCount = mq.getRowCount(this.getRight());
  double nljFactor = PrelUtil.getSettings(getCluster()).getNestedLoopJoinFactor();

  // cpu cost of evaluating each leftkey=rightkey join condition
  double joinConditionCost = DremioCost.COMPARE_CPU_COST * this.getLeftKeys().size();

  double cpuCost = joinConditionCost * (leftRowCount * rightRowCount) * nljFactor;

  Factory costFactory = (Factory) planner.getCostFactory();
  return costFactory.makeCost(leftRowCount * rightRowCount, cpuCost, 0, 0, 0);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:NestedLoopJoinPrel.java

示例13: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
/**
 * A SingleMergeExchange processes a total of M rows coming from N
 * sorted input streams (from N senders) and merges them into a single
 * output sorted stream. For costing purposes we can assume each sender
 * is sending M/N rows to a single receiver.
 * (See DremioCost for symbol notations)
 * C =  CPU cost of SV remover for M/N rows
 *     + Network cost of sending M/N rows to 1 destination.
 * So, C = (s * M/N) + (w * M/N)
 * Cost of merging M rows coming from N senders = (M log2 N) * c
 * Total cost = N * C + (M log2 N) * c
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  RelNode child = this.getInput();
  double inputRows = mq.getRowCount(child);
  int  rowWidth = child.getRowType().getFieldCount() * DremioCost.AVG_FIELD_WIDTH;
  double svrCpuCost = DremioCost.SVR_CPU_COST * inputRows;
  double networkCost = DremioCost.BYTE_NETWORK_COST * inputRows * rowWidth;
  int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints();
  double mergeCpuCost = DremioCost.COMPARE_CPU_COST * inputRows * (Math.log(numEndPoints)/Math.log(2));
  Factory costFactory = (Factory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, svrCpuCost + mergeCpuCost, 0, networkCost);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:SingleMergeExchangePrel.java

示例14: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }
  RelNode child = this.getInput();
  double inputRows = mq.getRowCount(child);

  int  rowWidth = child.getRowType().getFieldCount() * DremioCost.AVG_FIELD_WIDTH;

  double rangePartitionCpuCost = DremioCost.RANGE_PARTITION_CPU_COST * inputRows;
  double svrCpuCost = DremioCost.SVR_CPU_COST * inputRows;
  double networkCost = DremioCost.BYTE_NETWORK_COST * inputRows * rowWidth;
  Factory costFactory = (Factory)planner.getCostFactory();
  return costFactory.makeCost(inputRows, rangePartitionCpuCost + svrCpuCost, 0, networkCost);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:OrderedPartitionExchangePrel.java

示例15: computeSelfCost

import org.apache.calcite.plan.RelOptCost; //导入依赖的package包/类
/**
 * Sends a copy of each batch to one node (same as the data size)
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
  if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return super.computeSelfCost(planner).multiplyBy(.1);
  }

  RelNode child = this.getInput();
  final double inputRows = mq.getRowCount(child);

  final int  rowWidth = child.getRowType().getFieldCount() * DremioCost.AVG_FIELD_WIDTH;
  final double cpuCost = DremioCost.SVR_CPU_COST * inputRows;
  final double networkCost = DremioCost.BYTE_NETWORK_COST * inputRows * rowWidth;

  return new DremioCost(inputRows, cpuCost, 0, networkCost);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:RoundRobinExchangePrel.java


注:本文中的org.apache.calcite.plan.RelOptCost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。