You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by em...@apache.org on 2019/07/31 00:53:46 UTC

[arrow] branch master updated: ARROW-6073: [C++] Reset Decimal128Builder in Finish().

This is an automated email from the ASF dual-hosted git repository.

emkornfield pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 803dd89  ARROW-6073: [C++] Reset Decimal128Builder in Finish().
803dd89 is described below

commit 803dd89463cb6cfdeffb8ae4bb1555b75ca1b544
Author: Kenneth Jung <km...@google.com>
AuthorDate: Tue Jul 30 17:52:59 2019 -0700

    ARROW-6073: [C++] Reset Decimal128Builder in Finish().
    
    This change updates the FinishInternal implementation in Decimal128Builder to reset the internal state at finish time, honoring the contract for array builders.
    
    Closes #4970 from kmjung/arrow-6073 and squashes the following commits:
    
    32fdb8f9d <Kenneth Jung>  Reset Decimal128Builder in Finish().
    
    Authored-by: Kenneth Jung <km...@google.com>
    Signed-off-by: Micah Kornfield <em...@gmail.com>
---
 cpp/src/arrow/array-test.cc            | 1 +
 cpp/src/arrow/array/builder_decimal.cc | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index df8b852..b968ea8 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -1755,6 +1755,7 @@ class DecimalTest : public ::testing::TestWithParam<int> {
 
     std::shared_ptr<Array> out;
     FinishAndCheckPadding(builder.get(), &out);
+    ASSERT_EQ(builder->length(), 0);
 
     std::vector<uint8_t> raw_bytes;
 
diff --git a/cpp/src/arrow/array/builder_decimal.cc b/cpp/src/arrow/array/builder_decimal.cc
index 1c5d538..5ecec53 100644
--- a/cpp/src/arrow/array/builder_decimal.cc
+++ b/cpp/src/arrow/array/builder_decimal.cc
@@ -69,7 +69,7 @@ Status Decimal128Builder::FinishInternal(std::shared_ptr<ArrayData>* out) {
   RETURN_NOT_OK(null_bitmap_builder_.Finish(&null_bitmap));
 
   *out = ArrayData::Make(type_, length_, {null_bitmap, data}, null_count_);
-
+  capacity_ = length_ = null_count_ = 0;
   return Status::OK();
 }