Search in sources :

Example 1 with FalseConditionalResolverImpl

use of org.apache.carbondata.core.scan.filter.resolver.resolverinfo.FalseConditionalResolverImpl 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 FalseConditionalResolverImpl(expression, false, false);
        case TRUE:
            return new TrueConditionalResolverImpl(expression, false, false);
        case EQUALS:
            currentCondExpression = (BinaryConditionalExpression) expression;
            // check for implicit column in the expression
            if (currentCondExpression instanceof InExpression) {
                CarbonColumn carbonColumn = currentCondExpression.getColumnList().get(0).getCarbonColumn();
                if (carbonColumn.hasEncoding(Encoding.IMPLICIT)) {
                    return new ConditionalFilterResolverImpl(expression, isExpressionResolve, true, currentCondExpression.getColumnList().get(0).getCarbonColumn().isMeasure());
                }
            }
            CarbonColumn column = currentCondExpression.getColumnList().get(0).getCarbonColumn();
            if (currentCondExpression.isSingleColumn() && !column.getDataType().isComplexType()) {
                if (column.isMeasure()) {
                    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, currentCondExpression.getColumnList().get(0).getCarbonColumn().isMeasure());
                }
                // 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, currentCondExpression.getColumnList().get(0).getCarbonColumn().isMeasure());
            }
            break;
        case RANGE:
            return new ConditionalFilterResolverImpl(expression, isExpressionResolve, true, false);
        case NOT_EQUALS:
            currentCondExpression = (BinaryConditionalExpression) expression;
            column = currentCondExpression.getColumnList().get(0).getCarbonColumn();
            if (currentCondExpression.isSingleColumn() && !column.getDataType().isComplexType()) {
                if (column.isMeasure()) {
                    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 (currentCondExpression.getFilterExpressionType() == ExpressionType.GREATERTHAN || currentCondExpression.getFilterExpressionType() == ExpressionType.LESSTHAN || currentCondExpression.getFilterExpressionType() == ExpressionType.GREATERTHAN_EQUALTO || currentCondExpression.getFilterExpressionType() == ExpressionType.LESSTHAN_EQUALTO) {
                        return new RowLevelRangeFilterResolverImpl(expression, isExpressionResolve, false, tableIdentifier);
                    }
                    return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false, true);
                }
                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, false);
                }
                return new ConditionalFilterResolverImpl(expression, isExpressionResolve, false, false);
            }
            break;
        default:
            if (expression instanceof ConditionalExpression) {
                condExpression = (ConditionalExpression) expression;
                column = condExpression.getColumnList().get(0).getCarbonColumn();
                if (condExpression.isSingleColumn() && !column.isComplex()) {
                    condExpression = (ConditionalExpression) expression;
                    if ((condExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0).getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) || (condExpression.getColumnList().get(0).getCarbonColumn().isMeasure())) {
                        return new ConditionalFilterResolverImpl(expression, true, true, condExpression.getColumnList().get(0).getCarbonColumn().isMeasure());
                    }
                }
            }
    }
    return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
}
Also used : ConditionalFilterResolverImpl(org.apache.carbondata.core.scan.filter.resolver.ConditionalFilterResolverImpl) CarbonColumn(org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn) RowLevelFilterResolverImpl(org.apache.carbondata.core.scan.filter.resolver.RowLevelFilterResolverImpl) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) InExpression(org.apache.carbondata.core.scan.expression.conditional.InExpression) RowLevelRangeFilterResolverImpl(org.apache.carbondata.core.scan.filter.resolver.RowLevelRangeFilterResolverImpl) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FalseConditionalResolverImpl(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.FalseConditionalResolverImpl) TrueConditionalResolverImpl(org.apache.carbondata.core.scan.filter.resolver.resolverinfo.TrueConditionalResolverImpl)

Aggregations

CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)1 BinaryConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression)1 ConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression)1 InExpression (org.apache.carbondata.core.scan.expression.conditional.InExpression)1 ConditionalFilterResolverImpl (org.apache.carbondata.core.scan.filter.resolver.ConditionalFilterResolverImpl)1 RowLevelFilterResolverImpl (org.apache.carbondata.core.scan.filter.resolver.RowLevelFilterResolverImpl)1 RowLevelRangeFilterResolverImpl (org.apache.carbondata.core.scan.filter.resolver.RowLevelRangeFilterResolverImpl)1 FalseConditionalResolverImpl (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.FalseConditionalResolverImpl)1 TrueConditionalResolverImpl (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.TrueConditionalResolverImpl)1