Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9D98A200D01 for ; Fri, 8 Sep 2017 03:48:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9C177160FC4; Fri, 8 Sep 2017 01:48:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E14E3160C9B for ; Fri, 8 Sep 2017 03:48:32 +0200 (CEST) Received: (qmail 19709 invoked by uid 500); 8 Sep 2017 01:48:32 -0000 Mailing-List: contact commits-help@arrow.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@arrow.apache.org Delivered-To: mailing list commits@arrow.apache.org Received: (qmail 19699 invoked by uid 99); 8 Sep 2017 01:48:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Sep 2017 01:48:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CF13BF55CA; Fri, 8 Sep 2017 01:48:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: wesm@apache.org To: commits@arrow.apache.org Message-Id: <8d63686d5a724bbb97ad18996cb7ccf9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: =?utf-8?q?arrow_git_commit=3A_ARROW-1467=3A_=5BJAVA=5D_Fix_reset?= =?utf-8?q?=28=29_and_allocateNew=28=29_in_Nullable_Value_Vectors_t=E2=80=A6?= Date: Fri, 8 Sep 2017 01:48:30 +0000 (UTC) archived-at: Fri, 08 Sep 2017 01:48:33 -0000 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 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 Authored: Thu Sep 7 21:48:25 2017 -0400 Committer: Wes McKinney 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} */