use of com.facebook.presto.spi.statistics.ColumnStatistics.Builder in project presto by prestodb.
the class ConnectorFilterStatsCalculatorService method toColumnStatistics.
private static ColumnStatistics toColumnStatistics(VariableStatsEstimate variableStatsEstimate, double rowCount) {
if (variableStatsEstimate.isUnknown()) {
return ColumnStatistics.empty();
}
double nullsFractionDouble = variableStatsEstimate.getNullsFraction();
double nonNullRowsCount = rowCount * (1.0 - nullsFractionDouble);
Builder builder = ColumnStatistics.builder();
if (!Double.isNaN(nullsFractionDouble)) {
builder.setNullsFraction(Estimate.of(nullsFractionDouble));
}
if (!Double.isNaN(variableStatsEstimate.getDistinctValuesCount())) {
builder.setDistinctValuesCount(Estimate.of(variableStatsEstimate.getDistinctValuesCount()));
}
if (!Double.isNaN(variableStatsEstimate.getAverageRowSize())) {
builder.setDataSize(Estimate.of(variableStatsEstimate.getAverageRowSize() * nonNullRowsCount));
}
if (!Double.isNaN(variableStatsEstimate.getLowValue()) && !Double.isNaN(variableStatsEstimate.getHighValue())) {
builder.setRange(new DoubleRange(variableStatsEstimate.getLowValue(), variableStatsEstimate.getHighValue()));
}
return builder.build();
}
Aggregations