use of org.apache.parquet.column.statistics.BooleanStatistics in project drill by axbaretto.
the class ParquetMetaStatCollector method getStat.
/**
* Builds column statistics using given primitiveType, originalType, scale,
* precision, numNull, min and max values.
*
* @param min min value for statistics
* @param max max value for statistics
* @param numNull num_nulls for statistics
* @param primitiveType type that determines statistics class
* @param originalType type that determines statistics class
* @param scale scale value (used for DECIMAL type)
* @param precision precision value (used for DECIMAL type)
* @return column statistics
*/
private ColumnStatistics getStat(Object min, Object max, Long numNull, PrimitiveType.PrimitiveTypeName primitiveType, OriginalType originalType, int scale, int precision) {
Statistics stat = Statistics.getStatsBasedOnType(primitiveType);
Statistics convertedStat = stat;
TypeProtos.MajorType type = ParquetGroupScan.getType(primitiveType, originalType, scale, precision);
if (numNull != null) {
stat.setNumNulls(numNull);
}
if (min != null && max != null) {
switch(type.getMinorType()) {
case INT:
case TIME:
((IntStatistics) stat).setMinMax(Integer.parseInt(min.toString()), Integer.parseInt(max.toString()));
break;
case BIGINT:
case TIMESTAMP:
((LongStatistics) stat).setMinMax(Long.parseLong(min.toString()), Long.parseLong(max.toString()));
break;
case FLOAT4:
((FloatStatistics) stat).setMinMax(Float.parseFloat(min.toString()), Float.parseFloat(max.toString()));
break;
case FLOAT8:
((DoubleStatistics) stat).setMinMax(Double.parseDouble(min.toString()), Double.parseDouble(max.toString()));
break;
case DATE:
convertedStat = new LongStatistics();
convertedStat.setNumNulls(stat.getNumNulls());
final long minMS = convertToDrillDateValue(Integer.parseInt(min.toString()));
final long maxMS = convertToDrillDateValue(Integer.parseInt(max.toString()));
((LongStatistics) convertedStat).setMinMax(minMS, maxMS);
break;
case BIT:
((BooleanStatistics) stat).setMinMax(Boolean.parseBoolean(min.toString()), Boolean.parseBoolean(max.toString()));
break;
default:
}
}
return new ColumnStatistics(convertedStat, type);
}
use of org.apache.parquet.column.statistics.BooleanStatistics in project presto by prestodb.
the class TestTupleDomainParquetPredicate method booleanColumnStats.
private static BooleanStatistics booleanColumnStats(boolean minimum, boolean maximum) {
BooleanStatistics statistics = new BooleanStatistics();
statistics.setMinMax(minimum, maximum);
return statistics;
}
use of org.apache.parquet.column.statistics.BooleanStatistics in project parquet-mr by apache.
the class TestParquetMetadataConverter method testBooleanStats.
private void testBooleanStats(StatsHelper helper) {
// make fake stats and verify the size check
BooleanStatistics stats = new BooleanStatistics();
stats.incrementNumNulls(3004);
boolean min = Boolean.FALSE;
boolean max = Boolean.TRUE;
stats.updateStats(min);
stats.updateStats(max);
org.apache.parquet.format.Statistics formatStats = helper.toParquetStatistics(stats);
Assert.assertEquals("Min should match", min, BytesUtils.bytesToBool(formatStats.getMin()));
Assert.assertEquals("Max should match", max, BytesUtils.bytesToBool(formatStats.getMax()));
Assert.assertEquals("Num nulls should match", 3004, formatStats.getNull_count());
}
use of org.apache.parquet.column.statistics.BooleanStatistics in project drill by axbaretto.
the class RangeExprEvaluator method getStatistics.
private BooleanStatistics getStatistics(boolean min, boolean max) {
final BooleanStatistics booleanStatistics = new BooleanStatistics();
booleanStatistics.setMinMax(min, max);
return booleanStatistics;
}
Aggregations