Repository: arrow
Updated Branches:
  refs/heads/master b698227e9 -> 6f27a6447


ARROW-1467: [JAVA] Fix reset() and allocateNew() in Nullable Value Vectors t…

cc @jacques-n , @icexelloss , @BryanCutler

Things fixed:

1)

allocateNew() in NullableValueVectors allocates extra memory for the validity 
vector of fixed-width vectors. Instead of doing bits.allocateNew(valueCount + 
1), we should simply do bits.allocateNew(valueCount).

AFAIK, the only case where we need an additional valueCount is for the 
offsetVector and we already do that. Additional valueCount for the validity 
vector is not needed.

(2)

reset() method should call reset() on the underlying value vector to 
re-initialize the state (allocation monitor, reader index etc) and zero out the 
buffers. Right now we just reset the validity vector.

Author: siddharth <siddha...@dremio.com>

Closes #1052 from siddharthteotia/ARROW-1467 and squashes the following commits:

ac903884 [siddharth] addressed review comments
09f899af [siddharth] ARROW-1467: Fix reset() and allocateNew() in Nullable 
Value Vectors template


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

Branch: refs/heads/master
Commit: 6f27a6447171353427a129a5ce88dba181bd8af6
Parents: b698227
Author: siddharth <siddha...@dremio.com>
Authored: Thu Sep 7 21:48:25 2017 -0400
Committer: Wes McKinney <wes.mckin...@twosigma.com>
Committed: Thu Sep 7 21:48:25 2017 -0400

----------------------------------------------------------------------
 .../codegen/templates/NullableValueVectors.java | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/6f27a644/java/vector/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/NullableValueVectors.java 
b/java/vector/src/main/codegen/templates/NullableValueVectors.java
index 319c61c..122cd23 100644
--- a/java/vector/src/main/codegen/templates/NullableValueVectors.java
+++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java
@@ -267,6 +267,12 @@ protected final static byte[] emptyByteArray = new 
byte[]{};
     values.reAlloc();
   }
 
+  public void reset() {
+    bits.zeroVector();
+    mutator.reset();
+    accessor.reset();
+  }
+
   <#if type.major == "VarLen">
   @Override
   public void allocateNew(int totalBytes, int valueCount) {
@@ -282,12 +288,6 @@ protected final static byte[] emptyByteArray = new 
byte[]{};
     accessor.reset();
   }
 
-  public void reset() {
-    bits.zeroVector();
-    mutator.reset();
-    accessor.reset();
-  }
-
   @Override
   public int getByteCapacity(){
     return values.getByteCapacity();
@@ -303,7 +303,7 @@ protected final static byte[] emptyByteArray = new byte[]{};
   public void allocateNew(int valueCount) {
     try {
       values.allocateNew(valueCount);
-      bits.allocateNew(valueCount+1);
+      bits.allocateNew(valueCount);
     } catch(OutOfMemoryException e) {
       clear();
       throw e;
@@ -313,12 +313,6 @@ protected final static byte[] emptyByteArray = new 
byte[]{};
     accessor.reset();
   }
 
-  public void reset() {
-    bits.zeroVector();
-    mutator.reset();
-    accessor.reset();
-  }
-
   /**
    * {@inheritDoc}
    */

Reply via email to