use of org.apache.parquet.column.statistics.DoubleStatistics in project parquet-mr by apache.
the class TestStatisticsFilter method testClearExceptionForNots.
@Test
public void testClearExceptionForNots() {
List<ColumnChunkMetaData> columnMetas = Arrays.asList(getDoubleColumnMeta(new DoubleStatistics(), 0L), getIntColumnMeta(new IntStatistics(), 0L));
FilterPredicate pred = and(not(eq(doubleColumn, 12.0)), eq(intColumn, 17));
try {
canDrop(pred, columnMetas);
fail("This should throw");
} catch (IllegalArgumentException e) {
assertEquals("This predicate contains a not! Did you forget to run this predicate through LogicalInverseRewriter?" + " not(eq(double.column, 12.0))", e.getMessage());
}
}
use of org.apache.parquet.column.statistics.DoubleStatistics in project drill by apache.
the class RangeExprEvaluator method evalCastFunc.
private Statistics evalCastFunc(FunctionHolderExpression holderExpr, Statistics input) {
try {
DrillSimpleFuncHolder funcHolder = (DrillSimpleFuncHolder) holderExpr.getHolder();
DrillSimpleFunc interpreter = funcHolder.createInterpreter();
final ValueHolder minHolder, maxHolder;
TypeProtos.MinorType srcType = holderExpr.args.get(0).getMajorType().getMinorType();
TypeProtos.MinorType destType = holderExpr.getMajorType().getMinorType();
if (srcType.equals(destType)) {
// same type cast ==> NoOp.
return input;
} else if (!CAST_FUNC.containsKey(srcType) || !CAST_FUNC.get(srcType).contains(destType)) {
// cast func between srcType and destType is NOT allowed.
return null;
}
switch(srcType) {
case INT:
minHolder = ValueHolderHelper.getIntHolder(((IntStatistics) input).getMin());
maxHolder = ValueHolderHelper.getIntHolder(((IntStatistics) input).getMax());
break;
case BIGINT:
minHolder = ValueHolderHelper.getBigIntHolder(((LongStatistics) input).getMin());
maxHolder = ValueHolderHelper.getBigIntHolder(((LongStatistics) input).getMax());
break;
case FLOAT4:
minHolder = ValueHolderHelper.getFloat4Holder(((FloatStatistics) input).getMin());
maxHolder = ValueHolderHelper.getFloat4Holder(((FloatStatistics) input).getMax());
break;
case FLOAT8:
minHolder = ValueHolderHelper.getFloat8Holder(((DoubleStatistics) input).getMin());
maxHolder = ValueHolderHelper.getFloat8Holder(((DoubleStatistics) input).getMax());
break;
default:
return null;
}
final ValueHolder[] args1 = { minHolder };
final ValueHolder[] args2 = { maxHolder };
final ValueHolder minFuncHolder = InterpreterEvaluator.evaluateFunction(interpreter, args1, holderExpr.getName());
final ValueHolder maxFuncHolder = InterpreterEvaluator.evaluateFunction(interpreter, args2, holderExpr.getName());
switch(destType) {
//TODO : need handle # of nulls.
case INT:
return getStatistics(((IntHolder) minFuncHolder).value, ((IntHolder) maxFuncHolder).value);
case BIGINT:
return getStatistics(((BigIntHolder) minFuncHolder).value, ((BigIntHolder) maxFuncHolder).value);
case FLOAT4:
return getStatistics(((Float4Holder) minFuncHolder).value, ((Float4Holder) maxFuncHolder).value);
case FLOAT8:
return getStatistics(((Float8Holder) minFuncHolder).value, ((Float8Holder) maxFuncHolder).value);
default:
return null;
}
} catch (Exception e) {
throw new DrillRuntimeException("Error in evaluating function of " + holderExpr.getName());
}
}
use of org.apache.parquet.column.statistics.DoubleStatistics in project drill by axbaretto.
the class RangeExprEvaluator method getStatistics.
private DoubleStatistics getStatistics(double min, double max) {
final DoubleStatistics doubleStatistics = new DoubleStatistics();
doubleStatistics.setMinMax(min, max);
return doubleStatistics;
}
use of org.apache.parquet.column.statistics.DoubleStatistics in project parquet-mr by apache.
the class TestParquetMetadataConverter method testDoubleStats.
private void testDoubleStats(StatsHelper helper) {
// make fake stats and verify the size check
DoubleStatistics stats = new DoubleStatistics();
stats.incrementNumNulls(3004);
double min = Double.MIN_VALUE;
double max = Double.MAX_VALUE;
stats.updateStats(min);
stats.updateStats(max);
org.apache.parquet.format.Statistics formatStats = helper.toParquetStatistics(stats);
Assert.assertEquals("Min should match", min, Double.longBitsToDouble(BytesUtils.bytesToLong(formatStats.getMin())), 0.000001);
Assert.assertEquals("Max should match", max, Double.longBitsToDouble(BytesUtils.bytesToLong(formatStats.getMax())), 0.000001);
Assert.assertEquals("Num nulls should match", 3004, formatStats.getNull_count());
}
Aggregations