Exemple #1
0
 public List<Double> averageColumnSizes(Union rel, RelMetadataQuery mq) {
   final int fieldCount = rel.getRowType().getFieldCount();
   List<List<Double>> inputColumnSizeList = Lists.newArrayList();
   for (RelNode input : rel.getInputs()) {
     final List<Double> inputSizes = mq.getAverageColumnSizes(input);
     if (inputSizes != null) {
       inputColumnSizeList.add(inputSizes);
     }
   }
   switch (inputColumnSizeList.size()) {
     case 0:
       return null; // all were null
     case 1:
       return inputColumnSizeList.get(0); // all but one were null
   }
   final ImmutableNullableList.Builder<Double> sizes = ImmutableNullableList.builder();
   int nn = 0;
   for (int i = 0; i < fieldCount; i++) {
     double d = 0d;
     int n = 0;
     for (List<Double> inputColumnSizes : inputColumnSizeList) {
       Double d2 = inputColumnSizes.get(i);
       if (d2 != null) {
         d += d2;
         ++n;
         ++nn;
       }
     }
     sizes.add(n > 0 ? d / n : null);
   }
   if (nn == 0) {
     return null; // all columns are null
   }
   return sizes.build();
 }
Exemple #2
0
 public List<Double> averageColumnSizes(Project rel, RelMetadataQuery mq) {
   final List<Double> inputColumnSizes = mq.getAverageColumnSizesNotNull(rel.getInput());
   final ImmutableNullableList.Builder<Double> sizes = ImmutableNullableList.builder();
   for (RexNode project : rel.getProjects()) {
     sizes.add(averageRexSize(project, inputColumnSizes));
   }
   return sizes.build();
 }