carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvram...@apache.org
Subject [1/2] carbondata git commit: Test Case Mismatch Fix
Date Fri, 19 May 2017 11:58:20 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master 873ae0274 -> 4c02589af


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/06555f03
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/06555f03
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/06555f03

Branch: refs/heads/master
Commit: 06555f039e24a0fb3b247068b98fa187069c395a
Parents: 873ae02
Author: sounakr <sounakr@gmail.com>
Authored: Fri May 19 14:34:41 2017 +0530
Committer: sounakr <sounakr@gmail.com>
Committed: Fri May 19 16:26:42 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/06555f03/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 baf4648..2f8c907 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/06555f03/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/06555f03/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 bfe4ed1..47ddfc4 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) {


Mime
View raw message