use of org.apache.carbondata.core.scan.filter.ColumnFilterInfo in project carbondata by apache.
the class RestructureEvaluatorImpl method isMeasureDefaultValuePresentInFilterValues.
/**
* This method will check whether a default value for the non-existing column is present
* in the filter values list
*
* @param measureColumnResolvedFilterInfo
* @return
*/
protected boolean isMeasureDefaultValuePresentInFilterValues(MeasureColumnResolvedFilterInfo measureColumnResolvedFilterInfo) {
boolean isDefaultValuePresentInFilterValues = false;
ColumnFilterInfo filterValues = measureColumnResolvedFilterInfo.getFilterValues();
CarbonMeasure measure = measureColumnResolvedFilterInfo.getMeasure();
SerializableComparator comparator = Comparator.getComparatorByDataTypeForMeasure(measure.getDataType());
Object defaultValue = null;
if (null != measure.getDefaultValue()) {
// default value for case where user gives is Null condition
defaultValue = DataTypeUtil.getMeasureObjectFromDataType(measure.getDefaultValue(), measure.getDataType());
}
List<Object> measureFilterValuesList = filterValues.getMeasuresFilterValuesList();
for (Object filterValue : measureFilterValuesList) {
int compare = comparator.compare(defaultValue, filterValue);
if (compare == 0) {
isDefaultValuePresentInFilterValues = true;
break;
}
}
return isDefaultValuePresentInFilterValues;
}
use of org.apache.carbondata.core.scan.filter.ColumnFilterInfo in project carbondata by apache.
the class RowLevelRangeFilterResolverImpl method resolve.
/**
* Method which will resolve the filter expression by converting the filter
* member to its assigned dictionary values.
*/
public void resolve(AbsoluteTableIdentifier absoluteTableIdentifier, TableProvider tableProvider) throws FilterUnsupportedException {
DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = null;
MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = null;
int index = 0;
if (exp instanceof BinaryLogicalExpression) {
BinaryLogicalExpression conditionalExpression = (BinaryLogicalExpression) exp;
List<ColumnExpression> columnList = conditionalExpression.getColumnList();
for (ColumnExpression columnExpression : columnList) {
if (columnExpression.isDimension()) {
dimColumnEvaluatorInfo = new DimColumnResolvedFilterInfo();
ColumnFilterInfo filterInfo = new ColumnFilterInfo();
dimColumnEvaluatorInfo.setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
dimColumnEvaluatorInfo.setRowIndex(index++);
dimColumnEvaluatorInfo.setDimension(columnExpression.getDimension());
dimColumnEvaluatorInfo.setDimensionExistsInCurrentSilce(false);
if (columnExpression.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
if (!isIncludeFilter) {
filterInfo.setExcludeFilterList(getDirectSurrogateValues(columnExpression));
} else {
filterInfo.setFilterList(getDirectSurrogateValues(columnExpression));
}
} else {
filterInfo.setFilterListForNoDictionaryCols(getNoDictionaryRangeValues());
}
filterInfo.setIncludeFilter(isIncludeFilter);
dimColumnEvaluatorInfo.setFilterValues(filterInfo);
dimColumnEvaluatorInfo.addDimensionResolvedFilterInstance(columnExpression.getDimension(), filterInfo);
dimColEvaluatorInfoList.add(dimColumnEvaluatorInfo);
} else {
msrColumnEvalutorInfo = new MeasureColumnResolvedFilterInfo();
ColumnFilterInfo filterInfo = new ColumnFilterInfo();
msrColumnEvalutorInfo.setMeasure(columnExpression.getMeasure());
msrColumnEvalutorInfo.setRowIndex(index++);
msrColumnEvalutorInfo.setCarbonColumn(columnExpression.getCarbonColumn());
msrColumnEvalutorInfo.setColumnIndex(columnExpression.getCarbonColumn().getOrdinal());
msrColumnEvalutorInfo.setType(columnExpression.getCarbonColumn().getDataType());
msrColumnEvalutorInfo.setMeasureExistsInCurrentSilce(false);
filterInfo.setMeasuresFilterValuesList(getMeasureRangeValues(columnExpression.getMeasure()));
filterInfo.setIncludeFilter(isIncludeFilter);
msrColumnEvalutorInfo.setFilterValues(filterInfo);
msrColumnEvalutorInfo.addMeasureResolvedFilterInstance(columnExpression.getMeasure(), filterInfo);
msrColEvalutorInfoList.add(msrColumnEvalutorInfo);
}
}
}
}
use of org.apache.carbondata.core.scan.filter.ColumnFilterInfo 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(ColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException, IOException {
if (visitableObj instanceof DimColumnResolvedFilterInfo) {
DimColumnResolvedFilterInfo resolveDimension = (DimColumnResolvedFilterInfo) visitableObj;
ColumnFilterInfo resolvedFilterObject = null;
resolvedFilterObject = FilterUtil.getFilterListForAllValues(metadata.getTableIdentifier(), metadata.getExpression(), metadata.getColumnExpression(), metadata.isIncludeFilter(), metadata.getTableProvider(), true);
if (!metadata.isIncludeFilter() && null != resolvedFilterObject) {
// displaying the report as per hive compatibility.
if (!resolvedFilterObject.getExcludeFilterList().contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY)) {
resolvedFilterObject.getExcludeFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
Collections.sort(resolvedFilterObject.getFilterList());
}
}
resolveDimension.setFilterValues(resolvedFilterObject);
}
}
use of org.apache.carbondata.core.scan.filter.ColumnFilterInfo 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(ColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
if (visitableObj instanceof DimColumnResolvedFilterInfo) {
DimColumnResolvedFilterInfo resolveDimension = (DimColumnResolvedFilterInfo) visitableObj;
ColumnFilterInfo resolvedFilterObject = null;
List<ExpressionResult> listOfExpressionResults = null;
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.getExcludeFilterList().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.getExcludeFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
Collections.sort(resolvedFilterObject.getExcludeFilterList());
}
resolveDimension.setFilterValues(resolvedFilterObject);
}
}
use of org.apache.carbondata.core.scan.filter.ColumnFilterInfo 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(ColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
ColumnFilterInfo resolvedFilterObject = null;
if (visitableObj instanceof DimColumnResolvedFilterInfo) {
DimColumnResolvedFilterInfo resolveDimension = (DimColumnResolvedFilterInfo) visitableObj;
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.getExcludeFilterList().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.getExcludeFilterList().add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
Collections.sort(resolvedFilterObject.getExcludeFilterList());
}
resolveDimension.setFilterValues(resolvedFilterObject);
}
}
Aggregations