drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h.@apache.org
Subject drill git commit: DRILL-4180: When clear() is called on BitVector, ensure valueCount is set to zero
Date Wed, 09 Dec 2015 23:53:51 GMT
Repository: drill
Updated Branches:
  refs/heads/master e822f9f59 -> 539cbba56


DRILL-4180: When clear() is called on BitVector, ensure valueCount is set to zero


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

Branch: refs/heads/master
Commit: 539cbba564db8542f72eb353f139c4d3d134b7cc
Parents: e822f9f
Author: Hsuan-Yi Chu <hsuanyi@usc.edu>
Authored: Tue Dec 8 15:57:39 2015 -0800
Committer: Hsuan-Yi Chu <hsuanyi@usc.edu>
Committed: Wed Dec 9 10:17:02 2015 -0800

----------------------------------------------------------------------
 .../drill/exec/memory/TestAllocators.java       | 24 ++++++++++++++++++++
 .../org/apache/drill/exec/vector/BitVector.java |  5 ++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/539cbba5/exec/java-exec/src/test/java/org/apache/drill/exec/memory/TestAllocators.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/memory/TestAllocators.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/memory/TestAllocators.java
index 350e02b..aa0919a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/memory/TestAllocators.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/memory/TestAllocators.java
@@ -49,6 +49,7 @@ import org.apache.drill.exec.server.Drillbit;
 import org.apache.drill.exec.server.DrillbitContext;
 import org.apache.drill.exec.server.RemoteServiceSet;
 import org.apache.drill.exec.store.StoragePluginRegistry;
+import org.apache.drill.exec.vector.BitVector;
 import org.apache.drill.exec.vector.IntVector;
 import org.apache.drill.test.DrillTest;
 import org.junit.Test;
@@ -126,6 +127,29 @@ public class TestAllocators extends DrillTest {
   }
 
   @Test
+  public void testClearBitVector() {
+    final Properties props = new Properties() {
+      {
+        put(TopLevelAllocator.TOP_LEVEL_MAX_ALLOC, "1000000");
+        put(TopLevelAllocator.ERROR_ON_MEMORY_LEAK, "true");
+      }
+    };
+    final DrillConfig config = DrillConfig.create(props);
+
+    final BufferAllocator allc = RootAllocatorFactory.newRoot(config);
+    final TypeProtos.MajorType.Builder builder = TypeProtos.MajorType.newBuilder();
+    builder.setMinorType(TypeProtos.MinorType.BIT);
+    builder.setMode(TypeProtos.DataMode.REQUIRED);
+
+    final BitVector bv = new BitVector(MaterializedField.create("Field", builder.build()),
allc);
+    bv.getMutator().setValueCount(1);
+    assertEquals(bv.getAccessor().getValueCount(), 1);
+
+    bv.clear();
+    assertEquals(bv.getAccessor().getValueCount(), 0);
+  }
+
+  @Test
   public void testTransfer() throws Exception {
     final Properties props = new Properties() {
       {

http://git-wip-us.apache.org/repos/asf/drill/blob/539cbba5/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java b/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java
index 856393d..c1504c6 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/BitVector.java
@@ -445,4 +445,9 @@ public final class BitVector extends BaseDataValueVector implements FixedWidthVe
 
   }
 
+  @Override
+  public void clear() {
+    this.valueCount = 0;
+    super.clear();
+  }
 }


Mime
View raw message