drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [2/3] drill git commit: DRILL-1931: byte_substr() does not set the 'start' field of output holder correctly
Date Wed, 07 Jan 2015 11:07:43 GMT
DRILL-1931: byte_substr() does not set the 'start' field of output holder correctly


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/eced8bbd
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/eced8bbd
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/eced8bbd

Branch: refs/heads/master
Commit: eced8bbdbd6f8f6a7d884a6ff00d09e8e888d319
Parents: 8a9f02a
Author: Aditya Kishore <adi@apache.org>
Authored: Mon Jan 5 14:39:31 2015 -0800
Committer: Aditya Kishore <adi@apache.org>
Committed: Wed Jan 7 02:30:20 2015 -0800

----------------------------------------------------------------------
 .../drill/exec/expr/fn/impl/ByteSubstring.java     | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/eced8bbd/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteSubstring.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteSubstring.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteSubstring.java
index 55dc35a..8831d98 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteSubstring.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteSubstring.java
@@ -46,7 +46,7 @@ import org.apache.drill.exec.record.RecordBatch;
                   nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
 public class ByteSubstring implements DrillSimpleFunc {
 
-  @Param VarBinaryHolder string;
+  @Param VarBinaryHolder in;
   @Param BigIntHolder offset;
   @Param BigIntHolder length;
   @Output VarBinaryHolder out;
@@ -56,30 +56,25 @@ public class ByteSubstring implements DrillSimpleFunc {
 
   @Override
   public void eval() {
-    out.buffer = string.buffer;
+    out.buffer = in.buffer;
 
     // handle invalid values; e.g. SUBSTRING(value, 0, x) or SUBSTRING(value, x, 0)
     if (offset.value == 0 || length.value <= 0) {
-
       out.start = 0;
       out.end = 0;
-
     } else {
-
       // handle negative and positive offset values
       if (offset.value < 0) {
-        out.start = string.end + (int)offset.value;
+        out.start = in.end + (int)offset.value;
       } else {
-        out.start = (int)offset.value - 1;
+        out.start = in.start + (int)offset.value - 1;
       }
-
       // calculate end position from length and truncate to upper value bounds
-      if (out.start + length.value > string.end) {
-        out.end = string.end;
+      if (out.start + length.value > in.end) {
+        out.end = in.end;
       } else {
         out.end = out.start + (int)length.value;
       }
-
     }
   }
 


Mime
View raw message