You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ra...@apache.org on 2017/06/15 11:50:16 UTC
[11/42] carbondata git commit: Test Case Mismatch Fix
Test Case Mismatch Fix
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/211c23bb
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/211c23bb
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/211c23bb
Branch: refs/heads/branch-1.1
Commit: 211c23bb1c3f213d296d1658cb0c584214025997
Parents: 59d5545
Author: sounakr <so...@gmail.com>
Authored: Fri May 19 14:34:41 2017 +0530
Committer: ravipesala <ra...@gmail.com>
Committed: Thu Jun 15 12:45:38 2017 +0530
----------------------------------------------------------------------
.../core/scan/expression/ExpressionResult.java | 17 +++++++++-
.../expression/conditional/NotInExpression.java | 34 ++++++++++++++------
.../RowLevelRangeLessThanFiterExecuterImpl.java | 13 +++++---
3 files changed, 48 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/211c23bb/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
index e61ab3a..8a0cbe3 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
@@ -470,8 +470,23 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
if (this.value == objToCompare.value) {
return true;
}
+
+ if (this.isNull() || objToCompare.isNull()) {
+ return false;
+ }
+
+ // make the comparison against the data type whose precedence is higher like
+ // LONG precedence is higher than INT, so from int value we should get the long value
+ // and then compare both the values. If done vice versa exception will be thrown
+ // and comparison will fail
+ DataType dataType = null;
+ if (objToCompare.getDataType().getPrecedenceOrder() < this.getDataType().getPrecedenceOrder()) {
+ dataType = this.getDataType();
+ } else {
+ dataType = objToCompare.getDataType();
+ }
try {
- switch (this.getDataType()) {
+ switch (dataType) {
case STRING:
result = this.getString().equals(objToCompare.getString());
break;
http://git-wip-us.apache.org/repos/asf/carbondata/blob/211c23bb/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
index 67e3a50..9f385ec 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
@@ -31,6 +31,7 @@ import org.apache.carbondata.core.scan.filter.intf.RowIntf;
public class NotInExpression extends BinaryConditionalExpression {
private static final long serialVersionUID = -6835841923752118034L;
protected transient Set<ExpressionResult> setOfExprResult;
+ protected transient ExpressionResult nullValuePresent = null;
public NotInExpression(Expression left, Expression right) {
super(left, right);
@@ -38,23 +39,34 @@ public class NotInExpression extends BinaryConditionalExpression {
@Override public ExpressionResult evaluate(RowIntf value)
throws FilterUnsupportedException, FilterIllegalMemberException {
+
+ // Both left and right result need to be checked for null because NotInExpression is basically
+ // an And Operation on the list of predicates that are provided.
+ // Example: x in (1,2,null) would be converted to x=1 AND x=2 AND x=null.
+ // If any of the predicates is null then the result is unknown for all the predicates thus
+ // we will return false for each of them.
+ if (nullValuePresent != null) {
+ return nullValuePresent;
+ }
+
ExpressionResult leftRsult = left.evaluate(value);
+ if (leftRsult.isNull()) {
+ leftRsult.set(DataType.BOOLEAN, false);
+ return leftRsult;
+ }
+
if (setOfExprResult == null) {
ExpressionResult val = null;
ExpressionResult rightRsult = right.evaluate(value);
- // Both left and right result need to be checked for null because NotInExpression is basically
- // an And Operation on the list of predicates that are provided.
- // Example: x in (1,2,null) would be converted to x=1 AND x=2 AND x=null.
- // If any of the predicates is null then the result is unknown for all the predicates thus
- // we will return false for each of them.
- for (ExpressionResult expressionResult: rightRsult.getList()) {
- if (expressionResult.isNull() || leftRsult.isNull()) {
+ setOfExprResult = new HashSet<ExpressionResult>(10);
+ for (ExpressionResult exprResVal : rightRsult.getList()) {
+
+ if (exprResVal.isNull()) {
+ nullValuePresent = new ExpressionResult(DataType.BOOLEAN, false);
leftRsult.set(DataType.BOOLEAN, false);
return leftRsult;
}
- }
- setOfExprResult = new HashSet<ExpressionResult>(10);
- for (ExpressionResult exprResVal : rightRsult.getList()) {
+
if (exprResVal.getDataType().getPrecedenceOrder() < leftRsult.getDataType()
.getPrecedenceOrder()) {
val = leftRsult;
@@ -88,9 +100,11 @@ public class NotInExpression extends BinaryConditionalExpression {
throw new FilterUnsupportedException(
"DataType: " + val.getDataType() + " not supported for the filter expression");
}
+
setOfExprResult.add(val);
}
}
+
leftRsult.set(DataType.BOOLEAN, !setOfExprResult.contains(leftRsult));
return leftRsult;
}
http://git-wip-us.apache.org/repos/asf/carbondata/blob/211c23bb/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
index 1883607..5bdf315 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
@@ -203,11 +203,14 @@ public class RowLevelRangeLessThanFiterExecuterImpl extends RowLevelFilterExecut
start = CarbonUtil
.getFirstIndexUsingBinarySearch(dimensionColumnDataChunk, startIndex, numerOfRows - 1,
filterValues[i], false);
- // Logic will handle the case where the range filter member is not present in block
- // in this case the binary search will return the index from where the bit sets will be
- // set inorder to apply filters. this is Lesser than filter so the range will be taken
- // from the prev element which is Lesser than filter member.
- start = CarbonUtil.nextLesserValueToTarget(start, dimensionColumnDataChunk, filterValues[i]);
+ if (start >= 0) {
+ // Logic will handle the case where the range filter member is not present in block
+ // in this case the binary search will return the index from where the bit sets will be
+ // set inorder to apply filters. this is Lesser than filter so the range will be taken
+ // from the prev element which is Lesser than filter member.
+ start =
+ CarbonUtil.nextLesserValueToTarget(start, dimensionColumnDataChunk, filterValues[i]);
+ }
if (start < 0) {
start = -(start + 1);
if (start >= numerOfRows) {