Java Code Examples for org.apache.calcite.rel.core.Values#estimateRowCount()

The following examples show how to use org.apache.calcite.rel.core.Values#estimateRowCount() . 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 5 votes vote down vote up
public Double getDistinctRowCount(Values rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  if (predicate == null || predicate.isAlwaysTrue()) {
    if (groupKey.isEmpty()) {
      return 1D;
    }
  }
  double selectivity = RelMdUtil.guessSelectivity(predicate);

  // assume half the rows are duplicates
  double nRows = rel.estimateRowCount(mq) / 2;
  return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
}
 
Example 2
Source File: RelMdDistinctRowCount.java    From calcite with Apache License 2.0 5 votes vote down vote up
public Double getDistinctRowCount(Values rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  if (predicate == null || predicate.isAlwaysTrue()) {
    if (groupKey.isEmpty()) {
      return 1D;
    }
  }
  double selectivity = RelMdUtil.guessSelectivity(predicate);

  // assume half the rows are duplicates
  double nRows = rel.estimateRowCount(mq) / 2;
  return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
}
 
Example 3
Source File: RelMdPopulationSize.java    From Bats with Apache License 2.0 4 votes vote down vote up
public Double getPopulationSize(Values rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey) {
  // assume half the rows are duplicates
  return rel.estimateRowCount(mq) / 2;
}
 
Example 4
Source File: RelMdRowCount.java    From Bats with Apache License 2.0 4 votes vote down vote up
public Double getRowCount(Values rel, RelMetadataQuery mq) {
  return rel.estimateRowCount(mq);
}
 
Example 5
Source File: RelMdPopulationSize.java    From calcite with Apache License 2.0 4 votes vote down vote up
public Double getPopulationSize(Values rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey) {
  // assume half the rows are duplicates
  return rel.estimateRowCount(mq) / 2;
}
 
Example 6
Source File: RelMdRowCount.java    From calcite with Apache License 2.0 4 votes vote down vote up
public Double getRowCount(Values rel, RelMetadataQuery mq) {
  return rel.estimateRowCount(mq);
}