Search in sources :

Example 1 with BooleanStatistics

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);
}
Also used : LongStatistics(org.apache.parquet.column.statistics.LongStatistics) FloatStatistics(org.apache.parquet.column.statistics.FloatStatistics) IntStatistics(org.apache.parquet.column.statistics.IntStatistics) DoubleStatistics(org.apache.parquet.column.statistics.DoubleStatistics) BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics) BinaryStatistics(org.apache.parquet.column.statistics.BinaryStatistics) FloatStatistics(org.apache.parquet.column.statistics.FloatStatistics) Statistics(org.apache.parquet.column.statistics.Statistics) IntStatistics(org.apache.parquet.column.statistics.IntStatistics) DoubleStatistics(org.apache.parquet.column.statistics.DoubleStatistics) LongStatistics(org.apache.parquet.column.statistics.LongStatistics) BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics) TypeProtos(org.apache.drill.common.types.TypeProtos)

Example 2 with BooleanStatistics

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;
}
Also used : BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics)

Example 3 with BooleanStatistics

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());
}
Also used : BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics)

Example 4 with BooleanStatistics

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;
}
Also used : BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics)

Aggregations

BooleanStatistics (org.apache.parquet.column.statistics.BooleanStatistics)4 TypeProtos (org.apache.drill.common.types.TypeProtos)1 BinaryStatistics (org.apache.parquet.column.statistics.BinaryStatistics)1 DoubleStatistics (org.apache.parquet.column.statistics.DoubleStatistics)1 FloatStatistics (org.apache.parquet.column.statistics.FloatStatistics)1 IntStatistics (org.apache.parquet.column.statistics.IntStatistics)1 LongStatistics (org.apache.parquet.column.statistics.LongStatistics)1 Statistics (org.apache.parquet.column.statistics.Statistics)1