Search in sources :

Example 1 with BinaryConditionalExpression

use of org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression in project carbondata by apache.

the class RowLevelRangeFilterResolverImpl method getDirectSurrogateValues.

private List<Integer> getDirectSurrogateValues(ColumnExpression columnExpression) throws FilterUnsupportedException {
    List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
    DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(columnExpression.getDimension().getDataType());
    if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
        listOfExpressionResults = ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
    }
    List<Integer> filterValuesList = new ArrayList<Integer>(20);
    try {
        // system can display inconsistent result.
        for (ExpressionResult result : listOfExpressionResults) {
            filterValuesList.add(directDictionaryGenerator.generateDirectSurrogateKey(result.getString(), CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
        }
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    return filterValuesList;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) DirectDictionaryGenerator(org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 2 with BinaryConditionalExpression

use of org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression in project carbondata by apache.

the class ConditionalFilterResolverImpl method resolve.

/**
 * This API will resolve the filter expression and generates the
 * dictionaries for executing/evaluating the filter expressions in the
 * executer layer.
 *
 * @throws FilterUnsupportedException
 */
@Override
public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier, TableProvider tableProvider) throws FilterUnsupportedException, IOException {
    FilterResolverMetadata metadata = new FilterResolverMetadata();
    metadata.setTableIdentifier(absoluteTableIdentifier);
    if ((!isExpressionResolve) && exp instanceof BinaryConditionalExpression) {
        BinaryConditionalExpression binaryConditionalExpression = (BinaryConditionalExpression) exp;
        Expression leftExp = binaryConditionalExpression.getLeft();
        Expression rightExp = binaryConditionalExpression.getRight();
        if (leftExp instanceof ColumnExpression) {
            ColumnExpression columnExpression = (ColumnExpression) leftExp;
            metadata.setColumnExpression(columnExpression);
            metadata.setExpression(rightExp);
            metadata.setIncludeFilter(isIncludeFilter);
            metadata.setTableProvider(tableProvider);
            // expression or not in depth.
            if (FilterUtil.checkIfExpressionContainsColumn(rightExp) || FilterUtil.isExpressionNeedsToResolved(rightExp, isIncludeFilter) && (((null != columnExpression.getDimension()) && (columnExpression.getDimension().hasEncoding(Encoding.DICTIONARY) && !columnExpression.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY))))) {
                isExpressionResolve = true;
            } else {
                // visitors.
                if (columnExpression.isMeasure()) {
                    msrColResolvedFilterInfo.setMeasure(columnExpression.getMeasure());
                    msrColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
                } else {
                    dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
                }
            }
        } else if (rightExp instanceof ColumnExpression) {
            ColumnExpression columnExpression = (ColumnExpression) rightExp;
            metadata.setColumnExpression(columnExpression);
            metadata.setExpression(leftExp);
            metadata.setIncludeFilter(isIncludeFilter);
            metadata.setTableProvider(tableProvider);
            if (columnExpression.getDataType().equals(DataTypes.TIMESTAMP) || columnExpression.getDataType().equals(DataTypes.DATE)) {
                isExpressionResolve = true;
            } else {
                // expression or not in depth.
                if (FilterUtil.checkIfExpressionContainsColumn(leftExp)) {
                    isExpressionResolve = true;
                } else {
                    if (columnExpression.isMeasure()) {
                        msrColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
                    } else {
                        dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
                    }
                }
            }
        } else {
            isExpressionResolve = true;
        }
    }
    if (isExpressionResolve && exp instanceof ConditionalExpression) {
        ConditionalExpression conditionalExpression = (ConditionalExpression) exp;
        List<ColumnExpression> columnList = conditionalExpression.getColumnList();
        metadata.setColumnExpression(columnList.get(0));
        metadata.setExpression(exp);
        metadata.setIncludeFilter(isIncludeFilter);
        metadata.setTableProvider(tableProvider);
        if ((null != columnList.get(0).getDimension()) && (!columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) || columnList.get(0).getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) || (exp instanceof RangeExpression)) {
            dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnList.get(0), exp), metadata);
        } else if ((null != columnList.get(0).getDimension()) && (columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) && !columnList.get(0).getDimension().getDataType().isComplexType())) {
            dimColResolvedFilterInfo.setFilterValues(FilterUtil.getFilterListForAllValues(absoluteTableIdentifier, exp, columnList.get(0), isIncludeFilter, tableProvider, isExpressionResolve));
            dimColResolvedFilterInfo.setColumnIndex(columnList.get(0).getDimension().getOrdinal());
            dimColResolvedFilterInfo.setDimension(columnList.get(0).getDimension());
        } else if (columnList.get(0).isMeasure()) {
            msrColResolvedFilterInfo.setMeasure(columnList.get(0).getMeasure());
            msrColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnList.get(0), exp), metadata);
            msrColResolvedFilterInfo.setCarbonColumn(columnList.get(0).getCarbonColumn());
            msrColResolvedFilterInfo.setColumnIndex(columnList.get(0).getCarbonColumn().getOrdinal());
            msrColResolvedFilterInfo.setType(columnList.get(0).getCarbonColumn().getDataType());
        }
    }
}
Also used : FilterResolverMetadata(org.apache.carbondata.core.scan.filter.resolver.metadata.FilterResolverMetadata) Expression(org.apache.carbondata.core.scan.expression.Expression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression)

Example 3 with BinaryConditionalExpression

use of org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression in project carbondata by apache.

the class ConditionalFilterResolverImpl method resolve.

/**
   * This API will resolve the filter expression and generates the
   * dictionaries for executing/evaluating the filter expressions in the
   * executer layer.
   *
   * @throws FilterUnsupportedException
   */
@Override
public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier) throws FilterUnsupportedException, IOException {
    FilterResolverMetadata metadata = new FilterResolverMetadata();
    metadata.setTableIdentifier(absoluteTableIdentifier);
    if ((!isExpressionResolve) && exp instanceof BinaryConditionalExpression) {
        BinaryConditionalExpression binaryConditionalExpression = (BinaryConditionalExpression) exp;
        Expression leftExp = binaryConditionalExpression.getLeft();
        Expression rightExp = binaryConditionalExpression.getRight();
        if (leftExp instanceof ColumnExpression) {
            ColumnExpression columnExpression = (ColumnExpression) leftExp;
            metadata.setColumnExpression(columnExpression);
            metadata.setExpression(rightExp);
            metadata.setIncludeFilter(isIncludeFilter);
            // If imei=imei comes in filter condition then we need to
            // skip processing of right expression.
            // This flow has reached here assuming that this is a single
            // column expression.
            // we need to check if the other expression contains column
            // expression or not in depth.
            CarbonDimension dimension = columnExpression.getDimension();
            if (FilterUtil.checkIfExpressionContainsColumn(rightExp) || FilterUtil.isExpressionNeedsToResolved(rightExp, isIncludeFilter) && dimension.hasEncoding(Encoding.DICTIONARY) && !dimension.hasEncoding(Encoding.DIRECT_DICTIONARY)) {
                isExpressionResolve = true;
            } else {
                //Visitor pattern is been used in this scenario inorder to populate the
                // dimColResolvedFilterInfo
                //visitable object with filter member values based on the visitor type, currently there
                //3 types of visitors custom,direct and no dictionary, all types of visitor populate
                //the visitable instance as per its buisness logic which is different for all the
                // visitors.
                dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
            }
        } else if (rightExp instanceof ColumnExpression) {
            ColumnExpression columnExpression = (ColumnExpression) rightExp;
            metadata.setColumnExpression(columnExpression);
            metadata.setExpression(leftExp);
            metadata.setIncludeFilter(isIncludeFilter);
            if (columnExpression.getDataType().equals(DataType.TIMESTAMP) || columnExpression.getDataType().equals(DataType.DATE)) {
                isExpressionResolve = true;
            } else {
                // expression or not in depth.
                if (FilterUtil.checkIfExpressionContainsColumn(leftExp)) {
                    isExpressionResolve = true;
                } else {
                    dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnExpression, exp), metadata);
                }
            }
        } else {
            isExpressionResolve = true;
        }
    }
    if (isExpressionResolve && exp instanceof ConditionalExpression) {
        ConditionalExpression conditionalExpression = (ConditionalExpression) exp;
        List<ColumnExpression> columnList = conditionalExpression.getColumnList();
        metadata.setColumnExpression(columnList.get(0));
        metadata.setExpression(exp);
        metadata.setIncludeFilter(isIncludeFilter);
        if (!columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) || columnList.get(0).getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY) || (exp instanceof RangeExpression)) {
            dimColResolvedFilterInfo.populateFilterInfoBasedOnColumnType(FilterInfoTypeVisitorFactory.getResolvedFilterInfoVisitor(columnList.get(0), exp), metadata);
        } else if (columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) && !(columnList.get(0).getDimension().getDataType() == org.apache.carbondata.core.metadata.datatype.DataType.STRUCT || columnList.get(0).getDimension().getDataType() == org.apache.carbondata.core.metadata.datatype.DataType.ARRAY)) {
            dimColResolvedFilterInfo.setFilterValues(FilterUtil.getFilterListForAllValues(absoluteTableIdentifier, exp, columnList.get(0), isIncludeFilter));
            dimColResolvedFilterInfo.setColumnIndex(columnList.get(0).getDimension().getOrdinal());
            dimColResolvedFilterInfo.setDimension(columnList.get(0).getDimension());
        }
    }
}
Also used : FilterResolverMetadata(org.apache.carbondata.core.scan.filter.resolver.metadata.FilterResolverMetadata) Expression(org.apache.carbondata.core.scan.expression.Expression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 4 with BinaryConditionalExpression

use of org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression 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)

Example 5 with BinaryConditionalExpression

use of org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression in project carbondata by apache.

the class FilterExpressionProcessor method createFilterResolverTree.

/**
 * Pattern used : Visitor Pattern
 * Method will create filter resolver tree based on the filter expression tree,
 * in this algorithm based on the expression instance the resolvers will created
 *
 * @param expressionTree
 * @param tableIdentifier
 * @return
 */
private FilterResolverIntf createFilterResolverTree(Expression expressionTree, AbsoluteTableIdentifier tableIdentifier) {
    ExpressionType filterExpressionType = expressionTree.getFilterExpressionType();
    BinaryExpression currentExpression = null;
    switch(filterExpressionType) {
        case OR:
        case AND:
            currentExpression = (BinaryExpression) expressionTree;
            return new LogicalFilterResolverImpl(createFilterResolverTree(currentExpression.getLeft(), tableIdentifier), createFilterResolverTree(currentExpression.getRight(), tableIdentifier), currentExpression);
        case RANGE:
            return getFilterResolverBasedOnExpressionType(ExpressionType.RANGE, true, expressionTree, tableIdentifier, expressionTree);
        case EQUALS:
        case IN:
            return getFilterResolverBasedOnExpressionType(ExpressionType.EQUALS, ((BinaryConditionalExpression) expressionTree).isNull, expressionTree, tableIdentifier, expressionTree);
        case GREATERTHAN:
        case GREATERTHAN_EQUALTO:
        case LESSTHAN:
        case LESSTHAN_EQUALTO:
            return getFilterResolverBasedOnExpressionType(ExpressionType.EQUALS, true, expressionTree, tableIdentifier, expressionTree);
        case STARTSWITH:
            assert (expressionTree instanceof StartsWithExpression);
            currentExpression = (StartsWithExpression) expressionTree;
            Expression re = currentExpression.getRight();
            assert (re instanceof LiteralExpression);
            LiteralExpression literal = (LiteralExpression) re;
            String value = literal.getLiteralExpValue().toString();
            Expression left = new GreaterThanEqualToExpression(currentExpression.getLeft(), literal);
            String maxValueLimit = value.substring(0, value.length() - 1) + (char) (((int) value.charAt(value.length() - 1)) + 1);
            Expression right = new LessThanExpression(currentExpression.getLeft(), new LiteralExpression(maxValueLimit, literal.getLiteralExpDataType()));
            currentExpression = new AndExpression(left, right);
            return new LogicalFilterResolverImpl(createFilterResolverTree(currentExpression.getLeft(), tableIdentifier), createFilterResolverTree(currentExpression.getRight(), tableIdentifier), currentExpression);
        case NOT_EQUALS:
        case NOT_IN:
            return getFilterResolverBasedOnExpressionType(ExpressionType.NOT_EQUALS, false, expressionTree, tableIdentifier, expressionTree);
        case FALSE:
            return getFilterResolverBasedOnExpressionType(ExpressionType.FALSE, false, expressionTree, tableIdentifier, expressionTree);
        case TRUE:
            return getFilterResolverBasedOnExpressionType(ExpressionType.TRUE, false, expressionTree, tableIdentifier, expressionTree);
        default:
            return getFilterResolverBasedOnExpressionType(ExpressionType.UNKNOWN, false, expressionTree, tableIdentifier, expressionTree);
    }
}
Also used : LogicalFilterResolverImpl(org.apache.carbondata.core.scan.filter.resolver.LogicalFilterResolverImpl) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) BinaryExpression(org.apache.carbondata.core.scan.expression.BinaryExpression) LessThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression) BinaryExpression(org.apache.carbondata.core.scan.expression.BinaryExpression) GreaterThanExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression) ConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression) StartsWithExpression(org.apache.carbondata.core.scan.expression.conditional.StartsWithExpression) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) InExpression(org.apache.carbondata.core.scan.expression.conditional.InExpression) LessThanExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) StartsWithExpression(org.apache.carbondata.core.scan.expression.conditional.StartsWithExpression) ExpressionType(org.apache.carbondata.core.scan.filter.intf.ExpressionType) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) LessThanExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanExpression)

Aggregations

BinaryConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression)7 ConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.ConditionalExpression)4 ArrayList (java.util.ArrayList)3 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)3 Expression (org.apache.carbondata.core.scan.expression.Expression)3 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)3 FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)3 InExpression (org.apache.carbondata.core.scan.expression.conditional.InExpression)2 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)2 FilterResolverMetadata (org.apache.carbondata.core.scan.filter.resolver.metadata.FilterResolverMetadata)2 Comparator (java.util.Comparator)1 DirectDictionaryGenerator (org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)1 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)1 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1 BinaryExpression (org.apache.carbondata.core.scan.expression.BinaryExpression)1 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)1 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)1 GreaterThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression)1 GreaterThanExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression)1 LessThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression)1