use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.
the class AndExpressionTest method testEvaluate.
@Test
public void testEvaluate() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { false });
final ExpressionResult expressionResult = new ExpressionResult(DataType.BOOLEAN, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
ExpressionResult actualValue = andExpression.evaluate(rowImpl);
assertTrue(actualValue instanceof ExpressionResult);
}
use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.
the class AndExpressionTest method testEvaluateForDefault.
@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { true });
final ExpressionResult expressionResult = new ExpressionResult(DataType.STRING, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
andExpression.evaluate(rowImpl);
}
use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.
the class OrExpressionTest method testEvaluate.
@Test
public void testEvaluate() throws FilterIllegalMemberException, FilterUnsupportedException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { false });
final ExpressionResult expressionResult = new ExpressionResult(DataType.BOOLEAN, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) {
return expressionResult;
}
};
assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult);
}
use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.
the class OrExpressionTest method testEvaluateForDefault.
@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { true });
final ExpressionResult expressionResult = new ExpressionResult(DataType.STRING, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
orExpression.evaluate(rowImpl);
}
use of org.apache.carbondata.core.scan.filter.intf.RowIntf in project carbondata by apache.
the class FilterUtil method getFilterListForAllMembersRS.
/**
* This method will get the member based on filter expression evaluation from the
* forward dictionary cache, this method will be basically used in restructure.
*
* @param expression
* @param columnExpression
* @param defaultValues
* @param defaultSurrogate
* @param isIncludeFilter
* @return
* @throws FilterUnsupportedException
*/
public static DimColumnFilterInfo getFilterListForAllMembersRS(Expression expression, ColumnExpression columnExpression, String defaultValues, int defaultSurrogate, boolean isIncludeFilter) throws FilterUnsupportedException {
List<Integer> filterValuesList = new ArrayList<Integer>(20);
List<String> evaluateResultListFinal = new ArrayList<String>(20);
DimColumnFilterInfo columnFilterInfo = null;
// KeyGeneratorFactory.getKeyGenerator(new int[] { defaultSurrogate });
try {
RowIntf row = new RowImpl();
if (defaultValues.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
defaultValues = null;
}
row.setValues(new Object[] { DataTypeUtil.getDataBasedOnDataType(defaultValues, columnExpression.getCarbonColumn().getDataType()) });
Boolean rslt = expression.evaluate(row).getBoolean();
if (null != rslt && rslt == isIncludeFilter) {
if (null == defaultValues) {
evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
} else {
evaluateResultListFinal.add(defaultValues);
}
}
} catch (FilterIllegalMemberException e) {
LOGGER.audit(e.getMessage());
}
if (null == defaultValues) {
defaultValues = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
}
columnFilterInfo = new DimColumnFilterInfo();
for (int i = 0; i < evaluateResultListFinal.size(); i++) {
if (evaluateResultListFinal.get(i).equals(defaultValues)) {
filterValuesList.add(defaultSurrogate);
break;
}
}
columnFilterInfo.setFilterList(filterValuesList);
return columnFilterInfo;
}
Aggregations