Search in sources :

Example 6 with DimColumnFilterInfo

use of org.apache.carbondata.core.scan.filter.DimColumnFilterInfo in project carbondata by apache.

the class CustomTypeDictionaryVisitor method getDirectDictionaryValKeyMemberForFilter.

protected DimColumnFilterInfo getDirectDictionaryValKeyMemberForFilter(ColumnExpression columnExpression, List<String> evaluateResultListFinal, boolean isIncludeFilter, DataType dataType) {
    List<Integer> surrogates = new ArrayList<Integer>(20);
    DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(columnExpression.getDimension().getDataType());
    // Reading the dictionary value direct
    getSurrogateValuesForDictionary(evaluateResultListFinal, surrogates, directDictionaryGenerator, dataType);
    Collections.sort(surrogates);
    DimColumnFilterInfo columnFilterInfo = null;
    if (surrogates.size() > 0) {
        columnFilterInfo = new DimColumnFilterInfo();
        columnFilterInfo.setIncludeFilter(isIncludeFilter);
        columnFilterInfo.setFilterList(surrogates);
    }
    return columnFilterInfo;
}
Also used : DimColumnFilterInfo(org.apache.carbondata.core.scan.filter.DimColumnFilterInfo) ArrayList(java.util.ArrayList) DirectDictionaryGenerator(org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)

Example 7 with DimColumnFilterInfo

use of org.apache.carbondata.core.scan.filter.DimColumnFilterInfo in project carbondata by apache.

the class DictionaryColumnVisitor 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 IOException
   * @throws FilterUnsupportedException
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException, IOException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<String> evaluateResultListFinal;
    try {
        evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    resolvedFilterObject = FilterUtil.getFilterValues(metadata.getTableIdentifier(), metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter());
    if (!metadata.isIncludeFilter() && null != resolvedFilterObject) {
        // this is because two times it will flip the same bit
        if (!resolvedFilterObject.getFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
            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 8 with DimColumnFilterInfo

use of org.apache.carbondata.core.scan.filter.DimColumnFilterInfo in project carbondata by apache.

the class NoDictionaryTypeVisitor 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<String> evaluateResultListFinal = null;
    try {
        // handling for is null case scenarios
        if (metadata.getExpression() instanceof EqualToExpression) {
            EqualToExpression expression = (EqualToExpression) metadata.getExpression();
            if (expression.isNull) {
                evaluateResultListFinal = new ArrayList<>(1);
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
            }
        } else {
            evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
        }
        // displaying the report as per hive compatibility.
        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 : EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) 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 9 with DimColumnFilterInfo

use of org.apache.carbondata.core.scan.filter.DimColumnFilterInfo in project carbondata by apache.

the class RangeDictionaryColumnVisitor 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 IOException
   * @throws FilterUnsupportedException
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException, IOException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<String> evaluateResultListFinal;
    resolvedFilterObject = FilterUtil.getFilterListForAllValues(metadata.getTableIdentifier(), metadata.getExpression(), metadata.getColumnExpression(), metadata.isIncludeFilter());
    if (!metadata.isIncludeFilter() && null != resolvedFilterObject) {
        // 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)

Aggregations

DimColumnFilterInfo (org.apache.carbondata.core.scan.filter.DimColumnFilterInfo)9 FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)5 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)5 ArrayList (java.util.ArrayList)3 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)2 DirectDictionaryGenerator (org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)1 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)1 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)1 BinaryLogicalExpression (org.apache.carbondata.core.scan.expression.logical.BinaryLogicalExpression)1 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)1 DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)1 MeasureColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo)1