Java Code Examples for org.apache.calcite.plan.volcano.RelSubset#getBest()

The following examples show how to use org.apache.calcite.plan.volcano.RelSubset#getBest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelMdDistinctRowCount.java    From Bats with Apache License 2.0 6 votes vote down vote up
public Double getDistinctRowCount(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  final RelNode best = rel.getBest();
  if (best != null) {
    return mq.getDistinctRowCount(best, groupKey, predicate);
  }
  if (!Bug.CALCITE_1048_FIXED) {
    return getDistinctRowCount((RelNode) rel, mq, groupKey, predicate);
  }
  Double d = null;
  for (RelNode r2 : rel.getRels()) {
    try {
      Double d2 = mq.getDistinctRowCount(r2, groupKey, predicate);
      d = NumberUtil.min(d, d2);
    } catch (CyclicMetadataException e) {
      // Ignore this relational expression; there will be non-cyclic ones
      // in this set.
    }
  }
  return d;
}
 
Example 2
Source File: RelMdDistinctRowCount.java    From calcite with Apache License 2.0 6 votes vote down vote up
public Double getDistinctRowCount(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  final RelNode best = rel.getBest();
  if (best != null) {
    return mq.getDistinctRowCount(best, groupKey, predicate);
  }
  if (!Bug.CALCITE_1048_FIXED) {
    return getDistinctRowCount((RelNode) rel, mq, groupKey, predicate);
  }
  Double d = null;
  for (RelNode r2 : rel.getRels()) {
    try {
      Double d2 = mq.getDistinctRowCount(r2, groupKey, predicate);
      d = NumberUtil.min(d, d2);
    } catch (CyclicMetadataException e) {
      // Ignore this relational expression; there will be non-cyclic ones
      // in this set.
    }
  }
  return d;
}
 
Example 3
Source File: DrillRelMdSelectivity.java    From Bats with Apache License 2.0 5 votes vote down vote up
private Double getSubsetSelectivity(RelSubset rel, RelMetadataQuery mq, RexNode predicate) {
  if (rel.getBest() != null) {
    return getSelectivity(rel.getBest(), mq, predicate);
  } else {
    List<RelNode> list = rel.getRelList();
    if (list != null && list.size() > 0) {
      return getSelectivity(list.get(0), mq, predicate);
    }
  }
  //TODO: Not required? return mq.getSelectivity(((RelSubset)rel).getOriginal(), predicate);
  return RelMdUtil.guessSelectivity(predicate);
}
 
Example 4
Source File: RelMdCost.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public RelOptCost getCumulativeCost(RelSubset subset, RelMetadataQuery mq) {
  final RelNode best = subset.getBest();
  if (best != null) {
    return mq.getCumulativeCost(best);
  }

  return null;
}
 
Example 5
Source File: RelMdCost.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public RelOptCost getNonCumulativeCost(RelSubset subset, RelMetadataQuery mq) {
  final RelNode best = subset.getBest();
  if (best != null) {
    return mq.getNonCumulativeCost(best);
  }

  return null;
}