Search in sources :

Example 1 with FilterIllegalMemberException

use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.

the class FilterUtil method getFilterListForRS.

/**
   * Method will prepare the  dimfilterinfo instance by resolving the filter
   * expression value to its respective surrogates in the scenario of restructure.
   *
   * @param expression
   * @param columnExpression
   * @param defaultValues
   * @param defaultSurrogate
   * @return
   * @throws FilterUnsupportedException
   */
public static DimColumnFilterInfo getFilterListForRS(Expression expression, ColumnExpression columnExpression, String defaultValues, int defaultSurrogate) throws FilterUnsupportedException {
    List<Integer> filterValuesList = new ArrayList<Integer>(20);
    DimColumnFilterInfo columnFilterInfo = null;
    // List<byte[]> filterValuesList = new ArrayList<byte[]>(20);
    List<String> evaluateResultListFinal = new ArrayList<String>(20);
    // KeyGeneratorFactory.getKeyGenerator(new int[] { defaultSurrogate });
    try {
        List<ExpressionResult> evaluateResultList = expression.evaluate(null).getList();
        for (ExpressionResult result : evaluateResultList) {
            if (result.getString() == null) {
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
                continue;
            }
            evaluateResultListFinal.add(result.getString());
        }
        for (int i = 0; i < evaluateResultListFinal.size(); i++) {
            if (evaluateResultListFinal.get(i).equals(defaultValues)) {
                filterValuesList.add(defaultSurrogate);
                break;
            }
        }
        if (filterValuesList.size() > 0) {
            columnFilterInfo = new DimColumnFilterInfo();
            columnFilterInfo.setFilterList(filterValuesList);
        }
    } catch (FilterIllegalMemberException e) {
        LOGGER.audit(e.getMessage());
    }
    return columnFilterInfo;
}
Also used : ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 2 with FilterIllegalMemberException

use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException 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 3 with FilterIllegalMemberException

use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.

the class CustomTypeDictionaryVisitor method populateFilterResolvedInfo.

/**
   * This Visitor method is been used to resolve or populate the filter details
   * by using custom type dictionary value, the filter membrers will be resolved using
   * custom type function which will generate dictionary for the direct column type filter members
   *
   * @param visitableObj
   * @param metadata
   * @throws FilterUnsupportedException,if exception occurs while evaluating
   *                                       filter models.
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<String> evaluateResultListFinal;
    try {
        evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    resolvedFilterObject = getDirectDictionaryValKeyMemberForFilter(metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDimension().getDataType());
    if (!metadata.isIncludeFilter() && null != resolvedFilterObject && !resolvedFilterObject.getFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
        // Adding default surrogate key of null member inorder to not display the same while
        // displaying the report as per hive compatibility.
        resolvedFilterObject.getFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
        Collections.sort(resolvedFilterObject.getFilterList());
    }
    visitableObj.setFilterValues(resolvedFilterObject);
}
Also used : DimColumnFilterInfo(org.apache.carbondata.core.scan.filter.DimColumnFilterInfo) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 4 with FilterIllegalMemberException

use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.

the class RangeDirectDictionaryVisitor method populateFilterResolvedInfo.

/**
   * This Visitor method is used to populate the visitableObj with direct dictionary filter details
   * where the filters values will be resolve using dictionary cache.
   *
   * @param visitableObj
   * @param metadata
   * @throws FilterUnsupportedException,if exception occurs while evaluating
   * filter models.
   * @throws FilterUnsupportedException
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
    List<String> evaluateResultListFinal = new ArrayList<String>();
    try {
        listOfExpressionResults = ((RangeExpression) metadata.getExpression()).getLiterals();
        for (ExpressionResult result : listOfExpressionResults) {
            if (result.getString() == null) {
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
                continue;
            }
            evaluateResultListFinal.add(result.getString());
        }
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    resolvedFilterObject = getDirectDictionaryValKeyMemberForFilter(metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDimension().getDataType());
    if (!metadata.isIncludeFilter() && null != resolvedFilterObject && !resolvedFilterObject.getFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
        // Adding default surrogate key of null member inorder to not display the same while
        // displaying the report as per hive compatibility.
        resolvedFilterObject.getFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
        Collections.sort(resolvedFilterObject.getFilterList());
    }
    visitableObj.setFilterValues(resolvedFilterObject);
}
Also used : DimColumnFilterInfo(org.apache.carbondata.core.scan.filter.DimColumnFilterInfo) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 5 with FilterIllegalMemberException

use of org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException in project carbondata by apache.

the class RangeNoDictionaryTypeVisitor method populateFilterResolvedInfo.

/**
   * Visitor Method will update the filter related details in visitableObj, For no dictionary
   * type columns the filter members will resolved directly, no need to look up in dictionary
   * since it will not be part of dictionary, directly the actual data can be converted as
   * byte[] and can be set. this type of encoding is effective when the particular column
   * is having very high cardinality.
   *
   * @param visitableObj
   * @param metadata
   * @throws FilterUnsupportedException,if exception occurs while evaluating
   * filter models.
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<ExpressionResult> listOfExpressionResults = new ArrayList<ExpressionResult>(20);
    List<String> evaluateResultListFinal = new ArrayList<String>();
    try {
        // Add The Range Filter Values.
        if (metadata.getExpression() instanceof RangeExpression) {
            listOfExpressionResults = ((RangeExpression) metadata.getExpression()).getLiterals();
        }
        for (ExpressionResult result : listOfExpressionResults) {
            if (result.getString() == null) {
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
                continue;
            }
            evaluateResultListFinal.add(result.getString());
        }
        // evaluateResultListFinal.add(metadata.getExpression().evaluate().getListAsString());
        if (!metadata.isIncludeFilter() && !evaluateResultListFinal.contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
            evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
        }
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    resolvedFilterObject = FilterUtil.getNoDictionaryValKeyMemberForFilter(evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDataType());
    visitableObj.setFilterValues(resolvedFilterObject);
}
Also used : DimColumnFilterInfo(org.apache.carbondata.core.scan.filter.DimColumnFilterInfo) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ArrayList(java.util.ArrayList) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Aggregations

FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)27 ArrayList (java.util.ArrayList)13 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)13 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)9 ColumnFilterInfo (org.apache.carbondata.core.scan.filter.ColumnFilterInfo)7 DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)6 DimColumnFilterInfo (org.apache.carbondata.core.scan.filter.DimColumnFilterInfo)5 RowImpl (org.apache.carbondata.core.scan.filter.intf.RowImpl)5 RowIntf (org.apache.carbondata.core.scan.filter.intf.RowIntf)5 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4 DataType (org.apache.carbondata.core.metadata.datatype.DataType)4 BinaryConditionalExpression (org.apache.carbondata.core.scan.expression.conditional.BinaryConditionalExpression)3 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)3 Timestamp (java.sql.Timestamp)2 BitSet (java.util.BitSet)2 DictionaryChunksWrapper (org.apache.carbondata.core.cache.dictionary.DictionaryChunksWrapper)2 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)2 BitSetGroup (org.apache.carbondata.core.util.BitSetGroup)2