Esempio n. 1
0
 public List<Double> averageColumnSizes(Values rel, RelMetadataQuery mq) {
   final List<RelDataTypeField> fields = rel.getRowType().getFieldList();
   final ImmutableList.Builder<Double> list = ImmutableList.builder();
   for (int i = 0; i < fields.size(); i++) {
     RelDataTypeField field = fields.get(i);
     double d;
     if (rel.getTuples().isEmpty()) {
       d = averageTypeValueSize(field.getType());
     } else {
       d = 0;
       for (ImmutableList<RexLiteral> literals : rel.getTuples()) {
         d += typeValueSize(field.getType(), literals.get(i).getValue());
       }
       d /= rel.getTuples().size();
     }
     list.add(d);
   }
   return list.build();
 }
  public Double getDistinctRowCount(Values rel, 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.getRows() / 2;
    return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
  }
Esempio n. 3
0
 public Double getMaxRowCount(Values values, RelMetadataQuery mq) {
   // For Values, the maximum row count is the actual row count.
   // This is especially useful if Values is empty.
   return (double) values.getTuples().size();
 }