drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [3/6] drill git commit: DRILL-1822: Update direct memory access operations to always be protected by bounds checking unless specifically disabled using the system property -Dbounds=false and Java assertions are also disabled.
Date Mon, 08 Dec 2014 15:55:36 GMT
DRILL-1822: Update direct memory access operations to always be protected by bounds checking
unless specifically disabled using the system property -Dbounds=false and Java assertions
are also disabled.


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

Branch: refs/heads/master
Commit: dcc9bb2d52953b3b9e59b7bea55f9a66af4c7855
Parents: d092ae7
Author: Jacques Nadeau <jacques@apache.org>
Authored: Sun Dec 7 15:57:39 2014 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Dec 7 22:37:17 2014 -0800

----------------------------------------------------------------------
 .../main/codegen/templates/CastVarCharDate.java |  2 +-
 .../codegen/templates/ComparisonFunctions.java  |  4 +-
 .../templates/VarCharAggrFunctions1.java        |  2 +-
 .../src/main/java/io/netty/buffer/DrillBuf.java | 32 +++++++++----
 .../exec/expr/fn/impl/ByteFunctionHelpers.java  | 48 ++++++++++++++++----
 .../exec/expr/fn/impl/CastVarBinaryToDate.java  |  2 +-
 .../expr/fn/impl/SimpleRepeatedFunctions.java   |  3 +-
 .../expr/fn/impl/StringFunctionHelpers.java     | 13 +++++-
 .../apache/drill/exec/expr/fn/impl/XXHash.java  | 13 +++++-
 .../apache/drill/exec/util/AssertionUtil.java   |  6 ++-
 .../fn/impl/TestByteComparisonFunctions.java    | 20 ++++----
 11 files changed, 107 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
index cf3ae90..7358f72 100644
--- a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
+++ b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
@@ -63,7 +63,7 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc {
       </#if>  
       
       <#if type.to == "Date">
-      out.value = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getDate(in.buffer.memoryAddress(),
in.start, in.end);
+      out.value = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getDate(in.buffer,
in.start, in.end);
 
       <#elseif type.to == "TimeStamp">
       org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getDateTimeFormatter();

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/codegen/templates/ComparisonFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/ComparisonFunctions.java b/exec/java-exec/src/main/codegen/templates/ComparisonFunctions.java
index 12f45b2..628277c 100644
--- a/exec/java-exec/src/main/codegen/templates/ComparisonFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/ComparisonFunctions.java
@@ -53,7 +53,7 @@ outside:{
     </#if>
     
     <#if mode == "var">
-      ${output} = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(left.buffer.memoryAddress(),
left.start, left.end, right.buffer.memoryAddress(), right.start, right.end);
+      ${output} = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(left.buffer,
left.start, left.end, right.buffer, right.start, right.end);
     <#elseif mode == "fixed">
       ${output} = left.value < right.value ? -1 : ((left.value == right.value)? 0 : 1);
     </#if>    
@@ -203,7 +203,7 @@ public class GCompare${left}${right}{
 
       public void eval() {
           <#if type.mode == "var" >
-          out.value = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.equal(left.buffer.memoryAddress(),
left.start, left.end, right.buffer.memoryAddress(), right.start, right.end);
+          out.value = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.equal(left.buffer,
left.start, left.end, right.buffer, right.start, right.end);
           <#else>
           out.value = left.value == right.value ? 1 : 0;
           </#if>

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java b/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java
index ea56624..01b5565 100644
--- a/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java
+++ b/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java
@@ -103,7 +103,7 @@ public static class ${type.inputType}${aggrtype.className} implements
DrillAggFu
       swap = true;
     } else {
       // Compare the bytes
-      cmp = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(in.buffer.memoryAddress(),
in.start, in.end, tmp.getBytes(), 0, tmp.getLength());
+      cmp = org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(in.buffer, in.start,
in.end, tmp.getBytes(), 0, tmp.getLength());
 
 
       <#if aggrtype.className == "Min">

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/io/netty/buffer/DrillBuf.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/io/netty/buffer/DrillBuf.java b/exec/java-exec/src/main/java/io/netty/buffer/DrillBuf.java
index 2f9154d..8e9d395 100644
--- a/exec/java-exec/src/main/java/io/netty/buffer/DrillBuf.java
+++ b/exec/java-exec/src/main/java/io/netty/buffer/DrillBuf.java
@@ -37,6 +37,8 @@ import org.apache.drill.exec.util.AssertionUtil;
 public final class DrillBuf extends AbstractByteBuf {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillBuf.class);
 
+  private static final boolean BOUNDS_CHECKING_ENABLED = AssertionUtil.BOUNDS_CHECKING_ENABLED;
+
   private final ByteBuf b;
   private final long addr;
   private final int offset;
@@ -45,7 +47,7 @@ public final class DrillBuf extends AbstractByteBuf {
   private volatile BufferAllocator allocator;
   private volatile Accountor acct;
   private volatile int length;
-  private final boolean emptyBuffer;
+
   private OperatorContext context;
   private FragmentContext fContext;
 
@@ -59,7 +61,6 @@ public final class DrillBuf extends AbstractByteBuf {
     this.offset = 0;
     this.rootBuffer = true;
     this.allocator = allocator;
-    this.emptyBuffer = false;
   }
 
   private DrillBuf(ByteBuffer bb) {
@@ -69,7 +70,6 @@ public final class DrillBuf extends AbstractByteBuf {
     this.addr = bytebuf.memoryAddress();
     this.allocator = FakeAllocator.FAKE_ALLOCATOR;
     this.b = bytebuf;
-    this.emptyBuffer = false;
     this.length = bytebuf.capacity();
     this.offset = 0;
     this.rootBuffer = true;
@@ -85,7 +85,6 @@ public final class DrillBuf extends AbstractByteBuf {
     this.addr = 0;
     this.rootBuffer = true;
     this.offset = 0;
-    this.emptyBuffer = true;
   }
 
   private DrillBuf(DrillBuf buffer, int index, int length) {
@@ -93,7 +92,7 @@ public final class DrillBuf extends AbstractByteBuf {
     if (index < 0 || index > buffer.capacity() - length) {
       throw new IndexOutOfBoundsException(buffer.toString() + ".slice(" + index + ", " +
length + ')');
     }
-    this.emptyBuffer = false;
+
     this.length = length;
     writerIndex(length);
 
@@ -159,20 +158,35 @@ public final class DrillBuf extends AbstractByteBuf {
     }
   }
 
+  /**
+   * Allows a function to determine whether not reading a particular string of bytes is valid.
+   *
+   * Will throw an exception if the memory is not readable for some reason.  Only doesn't
something in the
+   * case that AssertionUtil.BOUNDS_CHECKING_ENABLED is true.
+   *
+   * @param start The starting position of the bytes to be read.
+   * @param end The exclusive endpoint of the bytes to be read.
+   */
+  public void checkBytes(int start, int end){
+    if (BOUNDS_CHECKING_ENABLED) {
+      checkIndexD(start, end - start);
+    }
+  }
+
   private void chk(int index, int width) {
-    if (AssertionUtil.isAssertionsEnabled()) {
+    if (BOUNDS_CHECKING_ENABLED) {
       checkIndexD(index, width);
     }
   }
 
   private void chk(int index) {
-    if (AssertionUtil.isAssertionsEnabled()) {
+    if (BOUNDS_CHECKING_ENABLED) {
       checkIndexD(index);
     }
   }
 
   private void ensure(int width) {
-    if (AssertionUtil.isAssertionsEnabled()) {
+    if (BOUNDS_CHECKING_ENABLED) {
       ensureWritable(width);
     }
   }
@@ -551,6 +565,7 @@ public final class DrillBuf extends AbstractByteBuf {
 
   @Override
   public ByteBuf setByte(int index, int value) {
+    chk(index, 1);
     PlatformDependent.putByte(addr(index), (byte) value);
     return this;
   }
@@ -655,6 +670,7 @@ public final class DrillBuf extends AbstractByteBuf {
 
   @Override
   public byte getByte(int index) {
+    chk(index, 1);
     return PlatformDependent.getByte(addr(index));
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteFunctionHelpers.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteFunctionHelpers.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteFunctionHelpers.java
index d21add1..191b459 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteFunctionHelpers.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ByteFunctionHelpers.java
@@ -18,8 +18,10 @@
  ******************************************************************************/
 package org.apache.drill.exec.expr.fn.impl;
 
+import io.netty.buffer.DrillBuf;
 import io.netty.util.internal.PlatformDependent;
 
+import org.apache.drill.exec.util.AssertionUtil;
 import org.apache.drill.exec.util.DecimalUtility;
 
 import com.google.common.primitives.UnsignedLongs;
@@ -27,18 +29,28 @@ import com.google.common.primitives.UnsignedLongs;
 public class ByteFunctionHelpers {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ByteFunctionHelpers.class);
 
+  private static final boolean BOUNDS_CHECKING_ENABLED = AssertionUtil.BOUNDS_CHECKING_ENABLED;
+
   /**
    * Helper function to check for equality of bytes in two DrillBuffers
    *
-   * @param laddr start address of the DrillBuf
+   * @param left Left DrillBuf for comparison
    * @param lStart start offset in the buffer
    * @param lEnd end offset in the buffer
-   * @param raddr start address of the DrillBuf
+   * @param right Right DrillBuf for comparison
    * @param rStart start offset in the buffer
    * @param rEnd end offset in the buffer
    * @return 1 if left input is greater, -1 if left input is smaller, 0 otherwise
    */
-  public static final int equal(final long laddr, int lStart, int lEnd, final long raddr,
int rStart,
+  public static final int equal(final DrillBuf left, int lStart, int lEnd, final DrillBuf
right, int rStart, int rEnd){
+    if(BOUNDS_CHECKING_ENABLED){
+      left.checkBytes(lStart, lEnd);
+      right.checkBytes(rStart, rEnd);
+    }
+    return memEqual(left.memoryAddress(), lStart, lEnd, right.memoryAddress(), rStart, rEnd);
+  }
+
+  private static final int memEqual(final long laddr, int lStart, int lEnd, final long raddr,
int rStart,
       final int rEnd) {
 
     int n = lEnd - lStart;
@@ -72,17 +84,27 @@ public class ByteFunctionHelpers {
   }
 
   /**
-   * Helper function to compare a set of bytes in two DrillBuffers
+   * Helper function to compare a set of bytes in two DrillBuffers.
+   *
+   * Function will check data before completing in the case that
    *
-   * @param laddr start address of the DrillBuf
+   * @param left Left DrillBuf to compare
    * @param lStart start offset in the buffer
    * @param lEnd end offset in the buffer
-   * @param raddr start address of the DrillBuf
+   * @param right Right DrillBuf to compare
    * @param rStart start offset in the buffer
    * @param rEnd end offset in the buffer
    * @return 1 if left input is greater, -1 if left input is smaller, 0 otherwise
    */
-  public static final int compare(final long laddr, int lStart, int lEnd, final long raddr,
int rStart, final int rEnd) {
+  public static final int compare(final DrillBuf left, int lStart, int lEnd, final DrillBuf
right, int rStart, int rEnd){
+    if(BOUNDS_CHECKING_ENABLED){
+      left.checkBytes(lStart, lEnd);
+      right.checkBytes(rStart, rEnd);
+    }
+    return memcmp(left.memoryAddress(), lStart, lEnd, right.memoryAddress(), rStart, rEnd);
+  }
+
+  private static final int memcmp(final long laddr, int lStart, int lEnd, final long raddr,
int rStart, final int rEnd) {
     int lLen = lEnd - lStart;
     int rLen = rEnd - rStart;
     int n = Math.min(rLen, lLen);
@@ -121,7 +143,7 @@ public class ByteFunctionHelpers {
   /**
    * Helper function to compare a set of bytes in DrillBuf to a ByteArray.
    *
-   * @param laddr start address of the DrillBuf
+   * @param left Left DrillBuf for comparison purposes
    * @param lStart start offset in the buffer
    * @param lEnd end offset in the buffer
    * @param right second input to be compared
@@ -129,7 +151,15 @@ public class ByteFunctionHelpers {
    * @param rEnd end offset in the byte array
    * @return 1 if left input is greater, -1 if left input is smaller, 0 otherwise
    */
-  public static final int compare(final long laddr, int lStart, int lEnd, final byte[] right,
int rStart, final int rEnd) {
+  public static final int compare(final DrillBuf left, int lStart, int lEnd, final byte[]
right, int rStart, final int rEnd) {
+    if(BOUNDS_CHECKING_ENABLED){
+      left.checkBytes(lStart, lEnd);
+    }
+    return memcmp(left.memoryAddress(), lStart, lEnd, right, rStart, rEnd);
+  }
+
+
+  private static final int memcmp(final long laddr, int lStart, int lEnd, final byte[] right,
int rStart, final int rEnd) {
     int lLen = lEnd - lStart;
     int rLen = rEnd - rStart;
     int n = Math.min(rLen, lLen);

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarBinaryToDate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarBinaryToDate.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarBinaryToDate.java
index 2161bfd..e45192e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarBinaryToDate.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarBinaryToDate.java
@@ -38,6 +38,6 @@ public class CastVarBinaryToDate implements DrillSimpleFunc {
     }
 
     public void eval() {
-        out.value = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getDate(in.buffer.memoryAddress(),
in.start, in.end);
+        out.value = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getDate(in.buffer,
in.start, in.end);
     }
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
index b1bfa1d..f7f0e91 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
@@ -64,7 +64,6 @@ public class SimpleRepeatedFunctions {
       out.value = input.end - input.start;
     }
   }
-
   @FunctionTemplate(name = "repeated_count", scope = FunctionTemplate.FunctionScope.SIMPLE)
   public static class RepeatedLengthTinyInt implements DrillSimpleFunc {
 
@@ -342,7 +341,7 @@ public class SimpleRepeatedFunctions {
         out.value = 0;
         listToSearch.vector.getAccessor().get(i, currVal);
         if (org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(
-            currVal.buffer.memoryAddress(), currVal.start, currVal.end, targetValue.buffer.memoryAddress(),
targetValue.start, targetValue.end) == 0 ) {
+            currVal.buffer, currVal.start, currVal.end, targetValue.buffer, targetValue.start,
targetValue.end) == 0 ) {
           out.value = 1;
           break;
         }

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
index c746b7f..3b1d7ef 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctionHelpers.java
@@ -21,6 +21,7 @@ package org.apache.drill.exec.expr.fn.impl;
 import io.netty.buffer.DrillBuf;
 import io.netty.util.internal.PlatformDependent;
 
+import org.apache.drill.exec.util.AssertionUtil;
 import org.joda.time.chrono.ISOChronology;
 
 import com.google.common.base.Charsets;
@@ -28,6 +29,8 @@ import com.google.common.base.Charsets;
 public class StringFunctionHelpers {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StringFunctionHelpers.class);
 
+  private static final boolean BOUNDS_CHECKING_ENABLED = AssertionUtil.BOUNDS_CHECKING_ENABLED;
+
   static final int RADIX = 10;
   static final long MAX_LONG = -Long.MAX_VALUE / RADIX;
   static final int MAX_INT = -Integer.MAX_VALUE / RADIX;
@@ -193,7 +196,15 @@ public class StringFunctionHelpers {
 
   private static final ISOChronology CHRONOLOGY = org.joda.time.chrono.ISOChronology.getInstanceUTC();
 
-  public static long getDate(long memoryAddress, int start, int end){
+  public static long getDate(DrillBuf buf, int start, int end){
+    if(BOUNDS_CHECKING_ENABLED){
+      buf.checkBytes(start, end);
+    }
+    return memGetDate(buf.memoryAddress(), start, end);
+  }
+
+
+  private static long memGetDate(long memoryAddress, int start, int end){
     long index = memoryAddress + start;
     final long endIndex = memoryAddress + end;
     int digit = 0;

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/XXHash.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/XXHash.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/XXHash.java
index a8a6484..8ad9611 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/XXHash.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/XXHash.java
@@ -17,6 +17,8 @@
  */
 package org.apache.drill.exec.expr.fn.impl;
 
+import org.apache.drill.exec.util.AssertionUtil;
+
 import io.netty.buffer.DrillBuf;
 import io.netty.util.internal.PlatformDependent;
 
@@ -25,13 +27,15 @@ import com.google.common.primitives.UnsignedLongs;
 public final class XXHash {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(XXHash.class);
 
+  private static final boolean BOUNDS_CHECKING_ENABLED = AssertionUtil.BOUNDS_CHECKING_ENABLED;
+
   static final long PRIME64_1 = UnsignedLongs.decode("11400714785074694791");
   static final long PRIME64_2 = UnsignedLongs.decode("14029467366897019727");
   static final long PRIME64_3 = UnsignedLongs.decode("1609587929392839161");
   static final long PRIME64_4 = UnsignedLongs.decode("9650029242287828579");
   static final long PRIME64_5 = UnsignedLongs.decode("2870177450012600261");
 
-  public static long hash64(long start, long bEnd, long seed) {
+  private static long hash64(long start, long bEnd, long seed) {
     long len = bEnd - start;
     long h64;
     long p = start;
@@ -126,8 +130,13 @@ public final class XXHash {
   }
 
   public static int hash32(int start, int end, DrillBuf buffer){
+    if(BOUNDS_CHECKING_ENABLED){
+      buffer.checkBytes(start, end);
+    }
+
     long s = buffer.memoryAddress() + start;
     long e = buffer.memoryAddress() + end;
+
     return hash32(s, e, 0);
   }
 
@@ -158,7 +167,7 @@ public final class XXHash {
     return (int) applyFinalHashComputation(h64);
   }
 
-  public static int hash32(long start, long bEnd, long seed){
+  private static int hash32(long start, long bEnd, long seed){
     return (int) hash64(start, bEnd, seed);
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/main/java/org/apache/drill/exec/util/AssertionUtil.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/util/AssertionUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/util/AssertionUtil.java
index e035e6b..20c2f8e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/util/AssertionUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/util/AssertionUtil.java
@@ -21,15 +21,19 @@ public class AssertionUtil {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AssertionUtil.class);
 
 
-  private static final boolean ASSERT_ENABLED;
+  public static final boolean ASSERT_ENABLED;
+  public static final boolean BOUNDS_CHECKING_ENABLED;
 
   static{
     boolean isAssertEnabled = false;
     assert isAssertEnabled = true;
     ASSERT_ENABLED = isAssertEnabled;
+    BOUNDS_CHECKING_ENABLED = ASSERT_ENABLED || !"false".equals(System.getProperty("bounds"));
   }
 
   public static boolean isAssertionsEnabled(){
     return ASSERT_ENABLED;
   }
+
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/dcc9bb2d/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestByteComparisonFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestByteComparisonFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestByteComparisonFunctions.java
index 5ec162d..1e9a47c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestByteComparisonFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestByteComparisonFunctions.java
@@ -61,69 +61,69 @@ public class TestByteComparisonFunctions extends ExecTest{
   public void testAfter(){
     VarCharHolder left = hello;
     VarCharHolder right = goodbye;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 1);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 1);
   }
 
   @Test
   public void testBefore(){
     VarCharHolder left = goodbye;
     VarCharHolder right = hello;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == -1);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == -1);
   }
 
   @Test
   public void testEqualCompare(){
     VarCharHolder left = hello;
     VarCharHolder right = hello;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 0);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 0);
   }
 
   @Test
   public void testEqual(){
     VarCharHolder left = hello;
     VarCharHolder right = hello;
-    assertTrue(ByteFunctionHelpers.equal(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 1);
+    assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 1);
   }
 
   @Test
   public void testNotEqual(){
     VarCharHolder left = hello;
     VarCharHolder right = goodbye;
-    assertTrue(ByteFunctionHelpers.equal(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 0);
+    assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 0);
   }
 
   @Test
   public void testAfterLong(){
     VarCharHolder left = helloLong;
     VarCharHolder right = goodbyeLong;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 1);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 1);
   }
 
   @Test
   public void testBeforeLong(){
     VarCharHolder left = goodbyeLong;
     VarCharHolder right = helloLong;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == -1);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == -1);
   }
 
   @Test
   public void testEqualCompareLong(){
     VarCharHolder left = helloLong;
     VarCharHolder right = helloLong;
-    assertTrue(ByteFunctionHelpers.compare(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 0);
+    assertTrue(ByteFunctionHelpers.compare(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 0);
   }
 
   @Test
   public void testEqualLong(){
     VarCharHolder left = helloLong;
     VarCharHolder right = helloLong;
-    assertTrue(ByteFunctionHelpers.equal(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 1);
+    assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 1);
   }
 
   @Test
   public void testNotEqualLong(){
     VarCharHolder left = helloLong;
     VarCharHolder right = goodbyeLong;
-    assertTrue(ByteFunctionHelpers.equal(left.buffer.memoryAddress(), left.start, left.end,
right.buffer.memoryAddress(), right.start, right.end) == 0);
+    assertTrue(ByteFunctionHelpers.equal(left.buffer, left.start, left.end, right.buffer,
right.start, right.end) == 0);
   }
 }


Mime
View raw message