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;
}
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);
}
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);
}
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);
}
Aggregations