Search in sources :

Example 6 with BinaryConditionalExpression

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

the class RowLevelRangeFilterResolverImpl method getNoDictionaryRangeValues.

private List<byte[]> getNoDictionaryRangeValues() {
    List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
    if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
        listOfExpressionResults = ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
    }
    List<byte[]> filterValuesList = new ArrayList<byte[]>(20);
    boolean invalidRowsPresent = false;
    String timeFormat = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
    for (ExpressionResult result : listOfExpressionResults) {
        try {
            if (result.getString() == null) {
                if (result.getDataType() == DataTypes.STRING) {
                    filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY);
                } else {
                    filterValuesList.add(CarbonCommonConstants.EMPTY_BYTE_ARRAY);
                }
                continue;
            }
            filterValuesList.add(DataTypeUtil.getBytesBasedOnDataTypeForNoDictionaryColumn(result.getString(), result.getDataType(), timeFormat));
        } catch (FilterIllegalMemberException e) {
            // Any invalid member while evaluation shall be ignored, system will log the
            // error only once since all rows the evaluation happens so inorder to avoid
            // too much log inforation only once the log will be printed.
            FilterUtil.logError(e, invalidRowsPresent);
        }
    }
    Comparator<byte[]> filterNoDictValueComaparator = new Comparator<byte[]>() {

        @Override
        public int compare(byte[] filterMember1, byte[] filterMember2) {
            return ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterMember1, filterMember2);
        }
    };
    Collections.sort(filterValuesList, filterNoDictValueComaparator);
    return filterValuesList;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException) Comparator(java.util.Comparator)

Example 7 with BinaryConditionalExpression

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

the class RowLevelRangeFilterResolverImpl method getMeasureRangeValues.

private List<Object> getMeasureRangeValues(CarbonMeasure carbonMeasure) {
    List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
    if (this.getFilterExpression() instanceof BinaryConditionalExpression) {
        listOfExpressionResults = ((BinaryConditionalExpression) this.getFilterExpression()).getLiterals();
    }
    List<Object> filterValuesList = new ArrayList<>(20);
    boolean invalidRowsPresent = false;
    for (ExpressionResult result : listOfExpressionResults) {
        try {
            if (result.getString() == null) {
                filterValuesList.add(null);
                continue;
            }
            filterValuesList.add(DataTypeUtil.getMeasureValueBasedOnDataType(result.getString(), result.getDataType(), carbonMeasure));
        } catch (FilterIllegalMemberException e) {
            // Any invalid member while evaluation shall be ignored, system will log the
            // error only once since all rows the evaluation happens so inorder to avoid
            // too much log inforation only once the log will be printed.
            FilterUtil.logError(e, invalidRowsPresent);
        }
    }
    Collections.sort(filterValuesList, org.apache.carbondata.core.util.comparator.Comparator.getComparatorByDataTypeForMeasure(carbonMeasure.getDataType()));
    return filterValuesList;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) BinaryConditionalExpression(org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

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