use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class RangeExpression method getLiteralsResult.
private void getLiteralsResult(Expression expression, List<ExpressionResult> listOfExp) {
for (Expression child : expression.getChildren()) {
if (child instanceof LiteralExpression) {
ExpressionResult colExp = ((LiteralExpression) child).getExpressionResult();
listOfExp.add(colExp);
} else {
getLiteralsResult(child, listOfExp);
}
}
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class RangeExpression method evaluate.
@Override
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
ExpressionResult resultLeft = left.evaluate(value);
ExpressionResult resultRight = right.evaluate(value);
switch(resultLeft.getDataType()) {
case BOOLEAN:
resultLeft.set(DataType.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
break;
default:
throw new FilterUnsupportedException("Incompatible datatype for applying RANGE Expression Filter");
}
return resultLeft;
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class EqualToExpression method evaluate.
@Override
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
ExpressionResult elRes = left.evaluate(value);
ExpressionResult erRes = right.evaluate(value);
boolean result = false;
ExpressionResult val1 = elRes;
ExpressionResult val2 = erRes;
if (elRes.isNull() || erRes.isNull()) {
if (isNull) {
elRes.set(DataType.BOOLEAN, elRes.isNull() == erRes.isNull());
} else {
elRes.set(DataType.BOOLEAN, false);
}
return elRes;
}
//default implementation if the data types are different for the resultsets
if (elRes.getDataType() != erRes.getDataType()) {
if (elRes.getDataType().getPrecedenceOrder() < erRes.getDataType().getPrecedenceOrder()) {
val2 = elRes;
val1 = erRes;
}
}
switch(val1.getDataType()) {
case STRING:
result = val1.getString().equals(val2.getString());
break;
case SHORT:
result = val1.getShort().equals(val2.getShort());
break;
case INT:
result = val1.getInt().equals(val2.getInt());
break;
case DOUBLE:
result = FilterUtil.nanSafeEqualsDoubles(val1.getDouble(), val2.getDouble());
break;
case DATE:
case TIMESTAMP:
result = val1.getTime().equals(val2.getTime());
break;
case LONG:
result = val1.getLong().equals(val2.getLong());
break;
case DECIMAL:
result = val1.getDecimal().compareTo(val2.getDecimal()) == 0;
break;
default:
throw new FilterUnsupportedException("DataType: " + val1.getDataType() + " not supported for the filter expression");
}
val1.set(DataType.BOOLEAN, result);
return val1;
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult 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;
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class BinaryLogicalExpression method getExpressionResultList.
private void getExpressionResultList(Expression binaryConditionalExpression, List<ExpressionResult> listOfExp) {
if (binaryConditionalExpression instanceof LiteralExpression) {
ExpressionResult colExp = ((LiteralExpression) binaryConditionalExpression).getExpressionResult();
listOfExp.add(colExp);
}
for (Expression child : binaryConditionalExpression.getChildren()) {
getExpressionResultList(child, listOfExp);
}
}
Aggregations