use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.TrueConditionalResolverImpl in project carbondata by apache.
the class FilterExpressionProcessor method getFilterResolverBasedOnExpressionType.
/**
* Factory method which will return the resolver instance based on filter expression
* expressions.
*/
private FilterResolverIntf getFilterResolverBasedOnExpressionType(ExpressionType filterExpressionType, boolean isExpressionResolve, Expression expression, AbsoluteTableIdentifier tableIdentifier, Expression expressionTree) {
BinaryConditionalExpression currentCondExpression = null;
ConditionalExpression condExpression = null;
switch(filterExpressionType) {
case FALSE:
return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
case TRUE:
return new TrueConditionalResolverImpl(expression, false, false, tableIdentifier);
case EQUALS:
currentCondExpression = (BinaryConditionalExpression) expression;
if (currentCondExpression.isSingleDimension() && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.ARRAY && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.STRUCT) {
// getting new dim index.
if (!currentCondExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DICTIONARY) || currentCondExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft()) && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight()) || (FilterUtil.checkIfRightExpressionRequireEvaluation(currentCondExpression.getRight()) || FilterUtil.checkIfLeftExpressionRequireEvaluation(currentCondExpression.getLeft()))) {
return new RowLevelFilterResolverImpl(expression, isExpressionResolve, true, tableIdentifier);
}
if (currentCondExpression.getFilterExpressionType() == ExpressionType.GREATERTHAN || currentCondExpression.getFilterExpressionType() == ExpressionType.LESSTHAN || currentCondExpression.getFilterExpressionType() == ExpressionType.GREATERTHAN_EQUALTO || currentCondExpression.getFilterExpressionType() == ExpressionType.LESSTHAN_EQUALTO) {
return new RowLevelRangeFilterResolverImpl(expression, isExpressionResolve, true, tableIdentifier);
}
}
return new ConditionalFilterResolverImpl(expression, isExpressionResolve, true, tableIdentifier);
}
break;
case RANGE:
return new ConditionalFilterResolverImpl(expression, isExpressionResolve, true, tableIdentifier);
case NOT_EQUALS:
currentCondExpression = (BinaryConditionalExpression) expression;
if (currentCondExpression.isSingleDimension() && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.ARRAY && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.STRUCT) {
if (!currentCondExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DICTIONARY) || currentCondExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft()) && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight()) || (FilterUtil.checkIfRightExpressionRequireEvaluation(currentCondExpression.getRight()) || FilterUtil.checkIfLeftExpressionRequireEvaluation(currentCondExpression.getLeft()))) {
return new RowLevelFilterResolverImpl(expression, isExpressionResolve, false, tableIdentifier);
}
if (expressionTree.getFilterExpressionType() == ExpressionType.GREATERTHAN || expressionTree.getFilterExpressionType() == ExpressionType.LESSTHAN || expressionTree.getFilterExpressionType() == ExpressionType.GREATERTHAN_EQUALTO || expressionTree.getFilterExpressionType() == ExpressionType.LESSTHAN_EQUALTO) {
return new RowLevelRangeFilterResolverImpl(expression, isExpressionResolve, false, tableIdentifier);
}
return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false, tableIdentifier);
}
return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false, tableIdentifier);
}
break;
default:
if (expression instanceof ConditionalExpression) {
condExpression = (ConditionalExpression) expression;
if (condExpression.isSingleDimension() && condExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.ARRAY && condExpression.getColumnList().get(0).getCarbonColumn().getDataType() != DataType.STRUCT) {
condExpression = (ConditionalExpression) expression;
if (condExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
return new ConditionalFilterResolverImpl(expression, true, true, tableIdentifier);
}
}
}
}
return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
}
Aggregations