Skip to content
Permalink
Browse files
DRILL-6481: Rename ParquetXXXPredicates to ParquetXXXPredicate
closes #1312
  • Loading branch information
vrozov authored and ilooner committed Jun 12, 2018
1 parent 0ac0825 commit ded643deeafbabe9363499960a135d33652bf567
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
@@ -27,10 +27,10 @@
/**
* Boolean predicates for parquet filter pushdown.
*/
public abstract class ParquetBooleanPredicates<C extends Comparable<C>> extends BooleanOperator
public abstract class ParquetBooleanPredicate<C extends Comparable<C>> extends BooleanOperator
implements ParquetFilterPredicate<C> {

private ParquetBooleanPredicates(String name, List<LogicalExpression> args, ExpressionPosition pos) {
private ParquetBooleanPredicate(String name, List<LogicalExpression> args, ExpressionPosition pos) {
super(name, args, pos);
}

@@ -45,7 +45,7 @@ private static <C extends Comparable<C>> LogicalExpression createAndPredicate(
List<LogicalExpression> args,
ExpressionPosition pos
) {
return new ParquetBooleanPredicates<C>(name, args, pos) {
return new ParquetBooleanPredicate<C>(name, args, pos) {
@Override
public boolean canDrop(RangeExprEvaluator<C> evaluator) {
// "and" : as long as one branch is OK to drop, we can drop it.
@@ -65,7 +65,7 @@ private static <C extends Comparable<C>> LogicalExpression createOrPredicate(
List<LogicalExpression> args,
ExpressionPosition pos
) {
return new ParquetBooleanPredicates<C>(name, args, pos) {
return new ParquetBooleanPredicate<C>(name, args, pos) {
@Override
public boolean canDrop(RangeExprEvaluator<C> evaluator) {
for (LogicalExpression child : this) {
@@ -87,9 +87,9 @@ public static <C extends Comparable<C>> LogicalExpression createBooleanPredicate
) {
switch (function) {
case "booleanOr":
return ParquetBooleanPredicates.<C>createOrPredicate(name, args, pos);
return ParquetBooleanPredicate.<C>createOrPredicate(name, args, pos);
case "booleanAnd":
return ParquetBooleanPredicates.<C>createAndPredicate(name, args, pos);
return ParquetBooleanPredicate.<C>createAndPredicate(name, args, pos);
default:
logger.warn("Unknown Boolean '{}' predicate.", function);
return null;
@@ -34,13 +34,13 @@
/**
* Comparison predicates for parquet filter pushdown.
*/
public class ParquetComparisonPredicates<C extends Comparable<C>> extends LogicalExpressionBase
public class ParquetComparisonPredicate<C extends Comparable<C>> extends LogicalExpressionBase
implements ParquetFilterPredicate<C> {
private final LogicalExpression left;
private final LogicalExpression right;
private final BiPredicate<Statistics<C>, Statistics<C>> predicate;

private ParquetComparisonPredicates(
private ParquetComparisonPredicate(
LogicalExpression left,
LogicalExpression right,
BiPredicate<Statistics<C>, Statistics<C>> predicate
@@ -109,7 +109,7 @@ private static <C extends Comparable<C>> LogicalExpression createEqualPredicate(
LogicalExpression left,
LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when left's max < right's min, or right's max < left's min
final C leftMin = leftStat.genericGetMin();
final C rightMin = rightStat.genericGetMin();
@@ -129,7 +129,7 @@ private static <C extends Comparable<C>> LogicalExpression createGTPredicate(
LogicalExpression left,
LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when left's max <= right's min.
final C rightMin = rightStat.genericGetMin();
return leftStat.genericGetMax().compareTo(rightMin) <= 0;
@@ -143,7 +143,7 @@ private static <C extends Comparable<C>> LogicalExpression createGEPredicate(
LogicalExpression left,
LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when left's max < right's min.
final C rightMin = rightStat.genericGetMin();
return leftStat.genericGetMax().compareTo(rightMin) < 0;
@@ -157,7 +157,7 @@ private static <C extends Comparable<C>> LogicalExpression createLTPredicate(
LogicalExpression left,
LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when right's max <= left's min.
final C leftMin = leftStat.genericGetMin();
return rightStat.genericGetMax().compareTo(leftMin) <= 0;
@@ -170,7 +170,7 @@ private static <C extends Comparable<C>> LogicalExpression createLTPredicate(
private static <C extends Comparable<C>> LogicalExpression createLEPredicate(
LogicalExpression left, LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when right's max < left's min.
final C leftMin = leftStat.genericGetMin();
return rightStat.genericGetMax().compareTo(leftMin) < 0;
@@ -184,7 +184,7 @@ private static <C extends Comparable<C>> LogicalExpression createNEPredicate(
LogicalExpression left,
LogicalExpression right
) {
return new ParquetComparisonPredicates<C>(left, right, (leftStat, rightStat) -> {
return new ParquetComparisonPredicate<C>(left, right, (leftStat, rightStat) -> {
// can drop when there is only one unique value.
final C leftMax = leftStat.genericGetMax();
final C rightMax = rightStat.genericGetMax();
@@ -200,17 +200,17 @@ public static <C extends Comparable<C>> LogicalExpression createComparisonPredic
) {
switch (function) {
case FunctionGenerationHelper.EQ:
return ParquetComparisonPredicates.<C>createEqualPredicate(left, right);
return ParquetComparisonPredicate.<C>createEqualPredicate(left, right);
case FunctionGenerationHelper.GT:
return ParquetComparisonPredicates.<C>createGTPredicate(left, right);
return ParquetComparisonPredicate.<C>createGTPredicate(left, right);
case FunctionGenerationHelper.GE:
return ParquetComparisonPredicates.<C>createGEPredicate(left, right);
return ParquetComparisonPredicate.<C>createGEPredicate(left, right);
case FunctionGenerationHelper.LT:
return ParquetComparisonPredicates.<C>createLTPredicate(left, right);
return ParquetComparisonPredicate.<C>createLTPredicate(left, right);
case FunctionGenerationHelper.LE:
return ParquetComparisonPredicates.<C>createLEPredicate(left, right);
return ParquetComparisonPredicate.<C>createLEPredicate(left, right);
case FunctionGenerationHelper.NE:
return ParquetComparisonPredicates.<C>createNEPredicate(left, right);
return ParquetComparisonPredicate.<C>createNEPredicate(left, right);
default:
return null;
}
@@ -37,13 +37,13 @@
/**
* IS predicates for parquet filter pushdown.
*/
public class ParquetIsPredicates <C extends Comparable<C>> extends LogicalExpressionBase
public class ParquetIsPredicate<C extends Comparable<C>> extends LogicalExpressionBase
implements ParquetFilterPredicate<C> {

private final LogicalExpression expr;
private final BiPredicate<Statistics<C>, RangeExprEvaluator<C>> predicate;

private ParquetIsPredicates(LogicalExpression expr, BiPredicate<Statistics<C>, RangeExprEvaluator<C>> predicate) {
private ParquetIsPredicate(LogicalExpression expr, BiPredicate<Statistics<C>, RangeExprEvaluator<C>> predicate) {
super(expr.getPosition());
this.expr = expr;
this.predicate = predicate;
@@ -75,7 +75,7 @@ public boolean canDrop(RangeExprEvaluator<C> evaluator) {
* IS NULL predicate.
*/
private static <C extends Comparable<C>> LogicalExpression createIsNullPredicate(LogicalExpression expr) {
return new ParquetIsPredicates<C>(expr,
return new ParquetIsPredicate<C>(expr,
//if there are no nulls -> canDrop
(exprStat, evaluator) -> hasNoNulls(exprStat)) {
private final boolean isArray = isArray(expr);
@@ -102,7 +102,7 @@ public boolean canDrop(RangeExprEvaluator<C> evaluator) {
* IS NOT NULL predicate.
*/
private static <C extends Comparable<C>> LogicalExpression createIsNotNullPredicate(LogicalExpression expr) {
return new ParquetIsPredicates<C>(expr,
return new ParquetIsPredicate<C>(expr,
//if there are all nulls -> canDrop
(exprStat, evaluator) -> isAllNulls(exprStat, evaluator.getRowCount())
);
@@ -112,7 +112,7 @@ private static <C extends Comparable<C>> LogicalExpression createIsNotNullPredic
* IS TRUE predicate.
*/
private static LogicalExpression createIsTruePredicate(LogicalExpression expr) {
return new ParquetIsPredicates<Boolean>(expr,
return new ParquetIsPredicate<Boolean>(expr,
//if max value is not true or if there are all nulls -> canDrop
(exprStat, evaluator) -> !exprStat.genericGetMax().equals(Boolean.TRUE) || isAllNulls(exprStat, evaluator.getRowCount())
);
@@ -122,7 +122,7 @@ private static LogicalExpression createIsTruePredicate(LogicalExpression expr) {
* IS FALSE predicate.
*/
private static LogicalExpression createIsFalsePredicate(LogicalExpression expr) {
return new ParquetIsPredicates<Boolean>(expr,
return new ParquetIsPredicate<Boolean>(expr,
//if min value is not false or if there are all nulls -> canDrop
(exprStat, evaluator) -> !exprStat.genericGetMin().equals(Boolean.FALSE) || isAllNulls(exprStat, evaluator.getRowCount())
);
@@ -132,7 +132,7 @@ private static LogicalExpression createIsFalsePredicate(LogicalExpression expr)
* IS NOT TRUE predicate.
*/
private static LogicalExpression createIsNotTruePredicate(LogicalExpression expr) {
return new ParquetIsPredicates<Boolean>(expr,
return new ParquetIsPredicate<Boolean>(expr,
//if min value is not false or if there are no nulls -> canDrop
(exprStat, evaluator) -> !exprStat.genericGetMin().equals(Boolean.FALSE) && hasNoNulls(exprStat)
);
@@ -142,7 +142,7 @@ private static LogicalExpression createIsNotTruePredicate(LogicalExpression expr
* IS NOT FALSE predicate.
*/
private static LogicalExpression createIsNotFalsePredicate(LogicalExpression expr) {
return new ParquetIsPredicates<Boolean>(expr,
return new ParquetIsPredicate<Boolean>(expr,
//if max value is not true or if there are no nulls -> canDrop
(exprStat, evaluator) -> !exprStat.genericGetMax().equals(Boolean.TRUE) && hasNoNulls(exprStat)
);
@@ -151,9 +151,9 @@ private static LogicalExpression createIsNotFalsePredicate(LogicalExpression exp
public static <C extends Comparable<C>> LogicalExpression createIsPredicate(String function, LogicalExpression expr) {
switch (function) {
case FunctionGenerationHelper.IS_NULL:
return ParquetIsPredicates.<C>createIsNullPredicate(expr);
return ParquetIsPredicate.<C>createIsNullPredicate(expr);
case FunctionGenerationHelper.IS_NOT_NULL:
return ParquetIsPredicates.<C>createIsNotNullPredicate(expr);
return ParquetIsPredicate.<C>createIsNotNullPredicate(expr);
case FunctionGenerationHelper.IS_TRUE:
return createIsTruePredicate(expr);
case FunctionGenerationHelper.IS_NOT_TRUE:
@@ -40,10 +40,10 @@
import org.apache.drill.exec.expr.holders.TimeStampHolder;
import org.apache.drill.exec.expr.holders.ValueHolder;
import org.apache.drill.exec.expr.holders.VarDecimalHolder;
import org.apache.drill.exec.expr.stat.ParquetBooleanPredicates;
import org.apache.drill.exec.expr.stat.ParquetComparisonPredicates;
import org.apache.drill.exec.expr.stat.ParquetBooleanPredicate;
import org.apache.drill.exec.expr.stat.ParquetComparisonPredicate;
import org.apache.drill.exec.expr.stat.ParquetFilterPredicate;
import org.apache.drill.exec.expr.stat.ParquetIsPredicates;
import org.apache.drill.exec.expr.stat.ParquetIsPredicate;
import org.apache.drill.exec.ops.UdfUtilities;
import org.apache.drill.exec.util.DecimalUtility;
import org.slf4j.Logger;
@@ -159,7 +159,7 @@ public LogicalExpression visitBooleanOperator(BooleanOperator op, Set<LogicalExp
} else {
if (childPredicate instanceof TypedFieldExpr) {
// Calcite simplifies `= true` expression to field name, wrap it with is true predicate
childPredicate = ParquetIsPredicates.createIsPredicate(FunctionGenerationHelper.IS_TRUE, childPredicate);
childPredicate = ParquetIsPredicate.createIsPredicate(FunctionGenerationHelper.IS_TRUE, childPredicate);
}
childPredicates.add(childPredicate);
}
@@ -170,7 +170,7 @@ public LogicalExpression visitBooleanOperator(BooleanOperator op, Set<LogicalExp
} else if (childPredicates.size() == 1) {
return childPredicates.get(0); // only one leg is qualified, remove boolean op.
} else {
return ParquetBooleanPredicates.createBooleanPredicate(functionName, op.getName(), childPredicates, op.getPosition());
return ParquetBooleanPredicate.createBooleanPredicate(functionName, op.getName(), childPredicates, op.getPosition());
}
}

@@ -268,7 +268,7 @@ private LogicalExpression handleCompareFunction(FunctionHolderExpression functio

String funcName = ((DrillSimpleFuncHolder) functionHolderExpression.getHolder()).getRegisteredNames()[0];

return ParquetComparisonPredicates.createComparisonPredicate(funcName, newArgs.get(0), newArgs.get(1));
return ParquetComparisonPredicate.createComparisonPredicate(funcName, newArgs.get(0), newArgs.get(1));
}

private LogicalExpression handleIsFunction(FunctionHolderExpression functionHolderExpression, Set<LogicalExpression> value) {
@@ -283,7 +283,7 @@ private LogicalExpression handleIsFunction(FunctionHolderExpression functionHold
}
LogicalExpression arg = functionHolderExpression.args.get(0);

return ParquetIsPredicates.createIsPredicate(funcName, arg.accept(this, value));
return ParquetIsPredicate.createIsPredicate(funcName, arg.accept(this, value));
}

private static boolean isCompareFunction(String funcName) {

0 comments on commit ded643d

Please sign in to comment.