arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1185: [C++] Status class cleanup, warn_unused_result attribute and Clang warning fixes
Date Wed, 05 Jul 2017 21:46:46 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 7d86c28e0 -> 00a7d55cc


ARROW-1185: [C++] Status class cleanup, warn_unused_result attribute and Clang warning fixes

This was tedious, but overdue. The Status class in Arrow as originally imported from Apache Kudu, which had been modified from standard use in Google projects. I simplified the implementation to bring it more in line with the Status implementation used in TensorFlow.

This also addresses ARROW-111 by providing an attribute to warn in Clang if a Status is ignored

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #814 from wesm/status-cleaning and squashes the following commits:

7b7e6517 [Wes McKinney] Bring Status implementation somewhat more in line with TensorFlow and other Google codebases, remove unused posix code. Add warn_unused_result attribute and fix clang warnings


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

Branch: refs/heads/master
Commit: 00a7d55cc06ab54af860be38fea701169b8f8aa3
Parents: 7d86c28
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Wed Jul 5 17:46:41 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Wed Jul 5 17:46:41 2017 -0400

----------------------------------------------------------------------
 LICENSE.txt                                   |  18 ++
 cpp/src/arrow/array-decimal-test.cc           |  24 +-
 cpp/src/arrow/array-test.cc                   | 249 +++++++++++----------
 cpp/src/arrow/builder-benchmark.cc            |   6 -
 cpp/src/arrow/builder.cc                      |   2 +-
 cpp/src/arrow/column-benchmark.cc             |  13 +-
 cpp/src/arrow/io/file.cc                      |   7 +-
 cpp/src/arrow/io/hdfs.cc                      |   5 +-
 cpp/src/arrow/io/io-file-test.cc              |  16 +-
 cpp/src/arrow/io/io-hdfs-test.cc              |   7 +-
 cpp/src/arrow/io/io-memory-benchmark.cc       |  12 +-
 cpp/src/arrow/io/io-memory-test.cc            |   6 +-
 cpp/src/arrow/io/memory.cc                    |   2 +-
 cpp/src/arrow/ipc/feather-test.cc             |  20 +-
 cpp/src/arrow/ipc/feather.cc                  |   5 +-
 cpp/src/arrow/ipc/ipc-json-test.cc            |   4 +-
 cpp/src/arrow/ipc/ipc-read-write-benchmark.cc |  14 +-
 cpp/src/arrow/ipc/json-internal.cc            |  10 +-
 cpp/src/arrow/ipc/test-common.h               |  14 +-
 cpp/src/arrow/pretty_print-test.cc            |   8 +-
 cpp/src/arrow/python/builtin_convert.cc       |  13 +-
 cpp/src/arrow/python/pandas_convert.cc        |  10 +-
 cpp/src/arrow/python/python-test.cc           |   2 +-
 cpp/src/arrow/status.cc                       |  38 ++--
 cpp/src/arrow/status.h                        |  77 +++----
 cpp/src/arrow/test-util.h                     |  14 +-
 cpp/src/arrow/type-test.cc                    |   2 +-
 cpp/src/arrow/util/bit-util.cc                |   4 +-
 cpp/src/arrow/util/bit-util.h                 |   2 +-
 cpp/src/arrow/util/decimal-test.cc            |   6 +-
 cpp/src/arrow/util/decimal.h                  |   2 +-
 cpp/src/arrow/util/macros.h                   |   8 +
 cpp/src/plasma/store.cc                       |   6 +-
 33 files changed, 328 insertions(+), 298 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
index 55823cb..34879f6 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -341,3 +341,21 @@ Copyright: 2013 Daniel Lemire
 Home page: http://lemire.me/en/
 Project page: https://github.com/lemire/FrameOfReference
 License: Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
+
+--------------------------------------------------------------------------------
+
+This project includes code from the TensorFlow project
+
+Copyright 2015 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/array-decimal-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-decimal-test.cc b/cpp/src/arrow/array-decimal-test.cc
index 2a3d0a9..0959d68 100644
--- a/cpp/src/arrow/array-decimal-test.cc
+++ b/cpp/src/arrow/array-decimal-test.cc
@@ -41,25 +41,27 @@ class DecimalTestBase {
     size_t null_count = 0;
 
     size_t size = draw.size();
-    builder->Reserve(size);
+    ASSERT_OK(builder->Reserve(size));
 
     for (size_t i = 0; i < size; ++i) {
       if (valid_bytes[i]) {
-        builder->Append(draw[i]);
+        ASSERT_OK(builder->Append(draw[i]));
       } else {
-        builder->AppendNull();
+        ASSERT_OK(builder->AppendNull());
         ++null_count;
       }
     }
 
     std::shared_ptr<Buffer> expected_sign_bitmap;
     if (!sign_bitmap.empty()) {
-      BitUtil::BytesToBits(sign_bitmap, &expected_sign_bitmap);
+      ASSERT_OK(BitUtil::BytesToBits(sign_bitmap, &expected_sign_bitmap));
     }
 
     auto raw_bytes = data(draw, byte_width);
     auto expected_data = std::make_shared<Buffer>(raw_bytes.data(), size * byte_width);
-    auto expected_null_bitmap = test::bytes_to_null_buffer(valid_bytes);
+    std::shared_ptr<Buffer> expected_null_bitmap;
+    ASSERT_OK(BitUtil::BytesToBits(valid_bytes, &expected_null_bitmap));
+
     int64_t expected_null_count = test::null_count(valid_bytes);
     auto expected = std::make_shared<DecimalArray>(type, size, expected_data,
         expected_null_bitmap, expected_null_count, offset, expected_sign_bitmap);
@@ -170,14 +172,14 @@ TEST_P(Decimal128BuilderTest, WithNulls) {
 }
 
 INSTANTIATE_TEST_CASE_P(Decimal32BuilderTest, Decimal32BuilderTest,
-    ::testing::Range(DecimalPrecision<int32_t>::minimum,
-                            DecimalPrecision<int32_t>::maximum));
+    ::testing::Range(
+        DecimalPrecision<int32_t>::minimum, DecimalPrecision<int32_t>::maximum));
 INSTANTIATE_TEST_CASE_P(Decimal64BuilderTest, Decimal64BuilderTest,
-    ::testing::Range(DecimalPrecision<int64_t>::minimum,
-                            DecimalPrecision<int64_t>::maximum));
+    ::testing::Range(
+        DecimalPrecision<int64_t>::minimum, DecimalPrecision<int64_t>::maximum));
 INSTANTIATE_TEST_CASE_P(Decimal128BuilderTest, Decimal128BuilderTest,
-    ::testing::Range(DecimalPrecision<int128_t>::minimum,
-                            DecimalPrecision<int128_t>::maximum));
+    ::testing::Range(
+        DecimalPrecision<int128_t>::minimum, DecimalPrecision<int128_t>::maximum));
 
 }  // namespace decimal
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/array-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 76d6bbe..64672d4 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -64,25 +64,29 @@ TEST_F(TestArray, TestLength) {
   ASSERT_EQ(arr->length(), 100);
 }
 
-std::shared_ptr<Array> MakeArrayFromValidBytes(
-    const vector<uint8_t>& v, MemoryPool* pool) {
+Status MakeArrayFromValidBytes(
+    const vector<uint8_t>& v, MemoryPool* pool, std::shared_ptr<Array>* out) {
   int64_t null_count = v.size() - std::accumulate(v.begin(), v.end(), 0);
-  std::shared_ptr<Buffer> null_buf = test::bytes_to_null_buffer(v);
+
+  std::shared_ptr<Buffer> null_buf;
+  RETURN_NOT_OK(BitUtil::BytesToBits(v, &null_buf));
 
   BufferBuilder value_builder(pool);
   for (size_t i = 0; i < v.size(); ++i) {
-    value_builder.Append<int32_t>(0);
+    RETURN_NOT_OK(value_builder.Append<int32_t>(0));
   }
 
-  std::shared_ptr<Array> arr(
-      new Int32Array(v.size(), value_builder.Finish(), null_buf, null_count));
-  return arr;
+  *out = std::make_shared<Int32Array>(
+      v.size(), value_builder.Finish(), null_buf, null_count);
+  return Status::OK();
 }
 
 TEST_F(TestArray, TestEquality) {
-  auto array = MakeArrayFromValidBytes({1, 0, 1, 1, 0, 1, 0, 0}, pool_);
-  auto equal_array = MakeArrayFromValidBytes({1, 0, 1, 1, 0, 1, 0, 0}, pool_);
-  auto unequal_array = MakeArrayFromValidBytes({1, 1, 1, 1, 0, 1, 0, 0}, pool_);
+  std::shared_ptr<Array> array, equal_array, unequal_array;
+
+  ASSERT_OK(MakeArrayFromValidBytes({1, 0, 1, 1, 0, 1, 0, 0}, pool_, &array));
+  ASSERT_OK(MakeArrayFromValidBytes({1, 0, 1, 1, 0, 1, 0, 0}, pool_, &equal_array));
+  ASSERT_OK(MakeArrayFromValidBytes({1, 1, 1, 1, 0, 1, 0, 0}, pool_, &unequal_array));
 
   EXPECT_TRUE(array->Equals(array));
   EXPECT_TRUE(array->Equals(equal_array));
@@ -108,7 +112,8 @@ TEST_F(TestArray, TestNullArrayEquality) {
 TEST_F(TestArray, SliceRecomputeNullCount) {
   vector<uint8_t> valid_bytes = {1, 0, 1, 1, 0, 1, 0, 0, 0};
 
-  auto array = MakeArrayFromValidBytes(valid_bytes, pool_);
+  std::shared_ptr<Array> array;
+  ASSERT_OK(MakeArrayFromValidBytes(valid_bytes, pool_, &array));
 
   ASSERT_EQ(5, array->null_count());
 
@@ -144,7 +149,9 @@ TEST_F(TestArray, TestIsNull) {
     if (x == 0) { ++null_count; }
   }
 
-  std::shared_ptr<Buffer> null_buf = test::bytes_to_null_buffer(null_bitmap);
+  std::shared_ptr<Buffer> null_buf;
+  ASSERT_OK(BitUtil::BytesToBits(null_bitmap, &null_buf));
+
   std::unique_ptr<Array> arr;
   arr.reset(new Int32Array(null_bitmap.size(), nullptr, null_buf, null_count));
 
@@ -177,10 +184,10 @@ TEST_F(TestArray, TestCopy) {}
 // Primitive type tests
 
 TEST_F(TestBuilder, TestReserve) {
-  builder_->Init(10);
+  ASSERT_OK(builder_->Init(10));
   ASSERT_EQ(2, builder_->null_bitmap()->size());
 
-  builder_->Reserve(30);
+  ASSERT_OK(builder_->Reserve(30));
   ASSERT_EQ(4, builder_->null_bitmap()->size());
 }
 
@@ -222,7 +229,7 @@ class TestPrimitiveBuilder : public TestBuilder {
     int64_t ex_null_count = 0;
 
     if (nullable) {
-      ex_null_bitmap = test::bytes_to_null_buffer(valid_bytes_);
+      ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, &ex_null_bitmap));
       ex_null_count = test::null_count(valid_bytes_);
     } else {
       ex_null_bitmap = nullptr;
@@ -312,13 +319,14 @@ void TestPrimitiveBuilder<PBoolean>::Check(
     const std::unique_ptr<BooleanBuilder>& builder, bool nullable) {
   int64_t size = builder->length();
 
-  auto ex_data = test::bytes_to_null_buffer(draws_);
+  std::shared_ptr<Buffer> ex_data;
+  ASSERT_OK(BitUtil::BytesToBits(draws_, &ex_data));
 
   std::shared_ptr<Buffer> ex_null_bitmap;
   int64_t ex_null_count = 0;
 
   if (nullable) {
-    ex_null_bitmap = test::bytes_to_null_buffer(valid_bytes_);
+    ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, &ex_null_bitmap));
     ex_null_count = test::null_count(valid_bytes_);
   } else {
     ex_null_bitmap = nullptr;
@@ -399,15 +407,14 @@ TYPED_TEST(TestPrimitiveBuilder, TestArrayDtorDealloc) {
   int64_t memory_before = this->pool_->bytes_allocated();
 
   this->RandomData(size);
-
-  this->builder_->Reserve(size);
+  ASSERT_OK(this->builder_->Reserve(size));
 
   int64_t i;
   for (i = 0; i < size; ++i) {
     if (valid_bytes[i] > 0) {
-      this->builder_->Append(draws[i]);
+      ASSERT_OK(this->builder_->Append(draws[i]));
     } else {
-      this->builder_->AppendNull();
+      ASSERT_OK(this->builder_->AppendNull());
     }
   }
 
@@ -499,19 +506,19 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendScalar) {
 
   this->RandomData(size);
 
-  this->builder_->Reserve(1000);
-  this->builder_nn_->Reserve(1000);
+  ASSERT_OK(this->builder_->Reserve(1000));
+  ASSERT_OK(this->builder_nn_->Reserve(1000));
 
   int64_t null_count = 0;
   // Append the first 1000
   for (size_t i = 0; i < 1000; ++i) {
     if (valid_bytes[i] > 0) {
-      this->builder_->Append(draws[i]);
+      ASSERT_OK(this->builder_->Append(draws[i]));
     } else {
-      this->builder_->AppendNull();
+      ASSERT_OK(this->builder_->AppendNull());
       ++null_count;
     }
-    this->builder_nn_->Append(draws[i]);
+    ASSERT_OK(this->builder_nn_->Append(draws[i]));
   }
 
   ASSERT_EQ(null_count, this->builder_->null_count());
@@ -522,17 +529,17 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendScalar) {
   ASSERT_EQ(1000, this->builder_nn_->length());
   ASSERT_EQ(1024, this->builder_nn_->capacity());
 
-  this->builder_->Reserve(size - 1000);
-  this->builder_nn_->Reserve(size - 1000);
+  ASSERT_OK(this->builder_->Reserve(size - 1000));
+  ASSERT_OK(this->builder_nn_->Reserve(size - 1000));
 
   // Append the next 9000
   for (size_t i = 1000; i < size; ++i) {
     if (valid_bytes[i] > 0) {
-      this->builder_->Append(draws[i]);
+      ASSERT_OK(this->builder_->Append(draws[i]));
     } else {
-      this->builder_->AppendNull();
+      ASSERT_OK(this->builder_->AppendNull());
     }
-    this->builder_nn_->Append(draws[i]);
+    ASSERT_OK(this->builder_nn_->Append(draws[i]));
   }
 
   ASSERT_EQ(size, this->builder_->length());
@@ -668,7 +675,7 @@ class TestStringArray : public ::testing::Test {
     length_ = static_cast<int64_t>(offsets_.size()) - 1;
     value_buf_ = test::GetBufferFromVector(chars_);
     offsets_buf_ = test::GetBufferFromVector(offsets_);
-    null_bitmap_ = test::bytes_to_null_buffer(valid_bytes_);
+    ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, &null_bitmap_));
     null_count_ = test::null_count(valid_bytes_);
 
     strings_ = std::make_shared<StringArray>(
@@ -746,19 +753,19 @@ TEST_F(TestStringArray, CompareNullByteSlots) {
   StringBuilder builder2(default_memory_pool());
   StringBuilder builder3(default_memory_pool());
 
-  builder.Append("foo");
-  builder2.Append("foo");
-  builder3.Append("foo");
+  ASSERT_OK(builder.Append("foo"));
+  ASSERT_OK(builder2.Append("foo"));
+  ASSERT_OK(builder3.Append("foo"));
 
-  builder.Append("bar");
-  builder2.AppendNull();
+  ASSERT_OK(builder.Append("bar"));
+  ASSERT_OK(builder2.AppendNull());
 
   // same length, but different
-  builder3.Append("xyz");
+  ASSERT_OK(builder3.Append("xyz"));
 
-  builder.Append("baz");
-  builder2.Append("baz");
-  builder3.Append("baz");
+  ASSERT_OK(builder.Append("baz"));
+  ASSERT_OK(builder2.Append("baz"));
+  ASSERT_OK(builder3.Append("baz"));
 
   std::shared_ptr<Array> array, array2, array3;
   ASSERT_OK(builder.Finish(&array));
@@ -785,9 +792,9 @@ TEST_F(TestStringArray, CompareNullByteSlots) {
 TEST_F(TestStringArray, TestSliceGetString) {
   StringBuilder builder(default_memory_pool());
 
-  builder.Append("a");
-  builder.Append("b");
-  builder.Append("c");
+  ASSERT_OK(builder.Append("a"));
+  ASSERT_OK(builder.Append("b"));
+  ASSERT_OK(builder.Append("c"));
 
   std::shared_ptr<Array> array;
   ASSERT_OK(builder.Finish(&array));
@@ -829,9 +836,9 @@ TEST_F(TestStringBuilder, TestScalarAppend) {
   for (int j = 0; j < reps; ++j) {
     for (int i = 0; i < N; ++i) {
       if (is_null[i]) {
-        builder_->AppendNull();
+        ASSERT_OK(builder_->AppendNull());
       } else {
-        builder_->Append(strings[i]);
+        ASSERT_OK(builder_->Append(strings[i]));
       }
     }
   }
@@ -882,7 +889,7 @@ class TestBinaryArray : public ::testing::Test {
     value_buf_ = test::GetBufferFromVector(chars_);
     offsets_buf_ = test::GetBufferFromVector(offsets_);
 
-    null_bitmap_ = test::bytes_to_null_buffer(valid_bytes_);
+    ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, &null_bitmap_));
     null_count_ = test::null_count(valid_bytes_);
 
     strings_ = std::make_shared<BinaryArray>(
@@ -949,12 +956,9 @@ TEST_F(TestBinaryArray, TestEqualsEmptyStrings) {
   BinaryBuilder builder(default_memory_pool(), arrow::binary());
 
   string empty_string("");
-
-  builder.Append(empty_string);
-  builder.Append(empty_string);
-  builder.Append(empty_string);
-  builder.Append(empty_string);
-  builder.Append(empty_string);
+  for (int i = 0; i < 5; ++i) {
+    ASSERT_OK(builder.Append(empty_string));
+  }
 
   std::shared_ptr<Array> left_arr;
   ASSERT_OK(builder.Finish(&left_arr));
@@ -997,9 +1001,9 @@ TEST_F(TestBinaryBuilder, TestScalarAppend) {
   for (int j = 0; j < reps; ++j) {
     for (int i = 0; i < N; ++i) {
       if (is_null[i]) {
-        builder_->AppendNull();
+        ASSERT_OK(builder_->AppendNull());
       } else {
-        builder_->Append(strings[i]);
+        ASSERT_OK(builder_->Append(strings[i]));
       }
     }
   }
@@ -1046,9 +1050,9 @@ void CheckSliceEquality() {
   for (int j = 0; j < reps; ++j) {
     for (int i = 0; i < N; ++i) {
       if (is_null[i]) {
-        builder.AppendNull();
+        ASSERT_OK(builder.AppendNull());
       } else {
-        builder.Append(strings[i]);
+        ASSERT_OK(builder.Append(strings[i]));
       }
     }
   }
@@ -1142,9 +1146,9 @@ TEST_F(TestFWBinaryArray, Builder) {
   InitBuilder(byte_width);
   for (int64_t i = 0; i < length; ++i) {
     if (is_valid[i]) {
-      builder_->Append(raw_data + byte_width * i);
+      ASSERT_OK(builder_->Append(raw_data + byte_width * i));
     } else {
-      builder_->AppendNull();
+      ASSERT_OK(builder_->AppendNull());
     }
   }
 
@@ -1165,10 +1169,10 @@ TEST_F(TestFWBinaryArray, Builder) {
   InitBuilder(byte_width);
   for (int64_t i = 0; i < length; ++i) {
     if (is_valid[i]) {
-      builder_->Append(
-          string(reinterpret_cast<const char*>(raw_data + byte_width * i), byte_width));
+      ASSERT_OK(builder_->Append(
+          string(reinterpret_cast<const char*>(raw_data + byte_width * i), byte_width)));
     } else {
-      builder_->AppendNull();
+      ASSERT_OK(builder_->AppendNull());
     }
   }
 
@@ -1236,9 +1240,9 @@ TEST_F(TestFWBinaryArray, Slice) {
 
   for (int i = 0; i < 5; ++i) {
     if (is_null[i]) {
-      builder.AppendNull();
+      ASSERT_OK(builder.AppendNull());
     } else {
-      builder.Append(strings[i]);
+      ASSERT_OK(builder.Append(strings[i]));
     }
   }
 
@@ -1287,9 +1291,9 @@ class TestAdaptiveIntBuilder : public TestBuilder {
 };
 
 TEST_F(TestAdaptiveIntBuilder, TestInt8) {
-  builder_->Append(0);
-  builder_->Append(127);
-  builder_->Append(-128);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(builder_->Append(127));
+  ASSERT_OK(builder_->Append(-128));
 
   Done();
 
@@ -1299,8 +1303,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt8) {
 }
 
 TEST_F(TestAdaptiveIntBuilder, TestInt16) {
-  builder_->Append(0);
-  builder_->Append(128);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(builder_->Append(128));
   Done();
 
   std::vector<int16_t> expected_values({0, 128});
@@ -1308,7 +1312,7 @@ TEST_F(TestAdaptiveIntBuilder, TestInt16) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(-129);
+  ASSERT_OK(builder_->Append(-129));
   expected_values = {-129};
   Done();
 
@@ -1316,8 +1320,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt16) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<int16_t>::max());
-  builder_->Append(std::numeric_limits<int16_t>::min());
+  ASSERT_OK(builder_->Append(std::numeric_limits<int16_t>::max()));
+  ASSERT_OK(builder_->Append(std::numeric_limits<int16_t>::min()));
   expected_values = {
       std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min()};
   Done();
@@ -1327,8 +1331,9 @@ TEST_F(TestAdaptiveIntBuilder, TestInt16) {
 }
 
 TEST_F(TestAdaptiveIntBuilder, TestInt32) {
-  builder_->Append(0);
-  builder_->Append(static_cast<int64_t>(std::numeric_limits<int16_t>::max()) + 1);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(
+      builder_->Append(static_cast<int64_t>(std::numeric_limits<int16_t>::max()) + 1));
   Done();
 
   std::vector<int32_t> expected_values(
@@ -1337,7 +1342,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt32) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(static_cast<int64_t>(std::numeric_limits<int16_t>::min()) - 1);
+  ASSERT_OK(
+      builder_->Append(static_cast<int64_t>(std::numeric_limits<int16_t>::min()) - 1));
   expected_values = {static_cast<int32_t>(std::numeric_limits<int16_t>::min()) - 1};
   Done();
 
@@ -1345,8 +1351,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt32) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<int32_t>::max());
-  builder_->Append(std::numeric_limits<int32_t>::min());
+  ASSERT_OK(builder_->Append(std::numeric_limits<int32_t>::max()));
+  ASSERT_OK(builder_->Append(std::numeric_limits<int32_t>::min()));
   expected_values = {
       std::numeric_limits<int32_t>::max(), std::numeric_limits<int32_t>::min()};
   Done();
@@ -1356,8 +1362,9 @@ TEST_F(TestAdaptiveIntBuilder, TestInt32) {
 }
 
 TEST_F(TestAdaptiveIntBuilder, TestInt64) {
-  builder_->Append(0);
-  builder_->Append(static_cast<int64_t>(std::numeric_limits<int32_t>::max()) + 1);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(
+      builder_->Append(static_cast<int64_t>(std::numeric_limits<int32_t>::max()) + 1));
   Done();
 
   std::vector<int64_t> expected_values(
@@ -1366,7 +1373,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt64) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(static_cast<int64_t>(std::numeric_limits<int32_t>::min()) - 1);
+  ASSERT_OK(
+      builder_->Append(static_cast<int64_t>(std::numeric_limits<int32_t>::min()) - 1));
   expected_values = {static_cast<int64_t>(std::numeric_limits<int32_t>::min()) - 1};
   Done();
 
@@ -1374,8 +1382,8 @@ TEST_F(TestAdaptiveIntBuilder, TestInt64) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<int64_t>::max());
-  builder_->Append(std::numeric_limits<int64_t>::min());
+  ASSERT_OK(builder_->Append(std::numeric_limits<int64_t>::max()));
+  ASSERT_OK(builder_->Append(std::numeric_limits<int64_t>::min()));
   expected_values = {
       std::numeric_limits<int64_t>::max(), std::numeric_limits<int64_t>::min()};
   Done();
@@ -1387,7 +1395,7 @@ TEST_F(TestAdaptiveIntBuilder, TestInt64) {
 TEST_F(TestAdaptiveIntBuilder, TestAppendVector) {
   std::vector<int64_t> expected_values(
       {0, static_cast<int64_t>(std::numeric_limits<int32_t>::max()) + 1});
-  builder_->Append(expected_values.data(), expected_values.size());
+  ASSERT_OK(builder_->Append(expected_values.data(), expected_values.size()));
   Done();
 
   ArrayFromVector<Int64Type, int64_t>(expected_values, &expected_);
@@ -1411,8 +1419,8 @@ class TestAdaptiveUIntBuilder : public TestBuilder {
 };
 
 TEST_F(TestAdaptiveUIntBuilder, TestUInt8) {
-  builder_->Append(0);
-  builder_->Append(255);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(builder_->Append(255));
 
   Done();
 
@@ -1422,8 +1430,8 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt8) {
 }
 
 TEST_F(TestAdaptiveUIntBuilder, TestUInt16) {
-  builder_->Append(0);
-  builder_->Append(256);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(builder_->Append(256));
   Done();
 
   std::vector<uint16_t> expected_values({0, 256});
@@ -1431,7 +1439,7 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt16) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<uint16_t>::max());
+  ASSERT_OK(builder_->Append(std::numeric_limits<uint16_t>::max()));
   expected_values = {std::numeric_limits<uint16_t>::max()};
   Done();
 
@@ -1440,8 +1448,9 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt16) {
 }
 
 TEST_F(TestAdaptiveUIntBuilder, TestUInt32) {
-  builder_->Append(0);
-  builder_->Append(static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(
+      builder_->Append(static_cast<uint64_t>(std::numeric_limits<uint16_t>::max()) + 1));
   Done();
 
   std::vector<uint32_t> expected_values(
@@ -1450,7 +1459,7 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt32) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<uint32_t>::max());
+  ASSERT_OK(builder_->Append(std::numeric_limits<uint32_t>::max()));
   expected_values = {std::numeric_limits<uint32_t>::max()};
   Done();
 
@@ -1459,8 +1468,9 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt32) {
 }
 
 TEST_F(TestAdaptiveUIntBuilder, TestUInt64) {
-  builder_->Append(0);
-  builder_->Append(static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) + 1);
+  ASSERT_OK(builder_->Append(0));
+  ASSERT_OK(
+      builder_->Append(static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) + 1));
   Done();
 
   std::vector<uint64_t> expected_values(
@@ -1469,7 +1479,7 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt64) {
   ASSERT_TRUE(expected_->Equals(result_));
 
   SetUp();
-  builder_->Append(std::numeric_limits<uint64_t>::max());
+  ASSERT_OK(builder_->Append(std::numeric_limits<uint64_t>::max()));
   expected_values = {std::numeric_limits<uint64_t>::max()};
   Done();
 
@@ -1480,7 +1490,7 @@ TEST_F(TestAdaptiveUIntBuilder, TestUInt64) {
 TEST_F(TestAdaptiveUIntBuilder, TestAppendVector) {
   std::vector<uint64_t> expected_values(
       {0, static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) + 1});
-  builder_->Append(expected_values.data(), expected_values.size());
+  ASSERT_OK(builder_->Append(expected_values.data(), expected_values.size()));
   Done();
 
   ArrayFromVector<UInt64Type, uint64_t>(expected_values, &expected_);
@@ -1779,7 +1789,7 @@ TEST_F(TestListBuilder, TestBasics) {
   for (size_t i = 0; i < lengths.size(); ++i) {
     ASSERT_OK(builder_->Append(is_valid[i] > 0));
     for (int j = 0; j < lengths[i]; ++j) {
-      vb->Append(values[pos++]);
+      ASSERT_OK(vb->Append(values[pos++]));
     }
   }
 
@@ -1796,9 +1806,9 @@ TEST_F(TestListBuilder, BulkAppend) {
   Int32Builder* vb = static_cast<Int32Builder*>(builder_->value_builder());
   ASSERT_OK(vb->Reserve(values.size()));
 
-  builder_->Append(offsets.data(), offsets.size(), is_valid.data());
+  ASSERT_OK(builder_->Append(offsets.data(), offsets.size(), is_valid.data()));
   for (int32_t value : values) {
-    vb->Append(value);
+    ASSERT_OK(vb->Append(value));
   }
   Done();
   ValidateBasicListArray(result_.get(), values, is_valid);
@@ -1814,10 +1824,10 @@ TEST_F(TestListBuilder, BulkAppendInvalid) {
   Int32Builder* vb = static_cast<Int32Builder*>(builder_->value_builder());
   ASSERT_OK(vb->Reserve(values.size()));
 
-  builder_->Append(offsets.data(), offsets.size(), is_valid.data());
-  builder_->Append(offsets.data(), offsets.size(), is_valid.data());
+  ASSERT_OK(builder_->Append(offsets.data(), offsets.size(), is_valid.data()));
+  ASSERT_OK(builder_->Append(offsets.data(), offsets.size(), is_valid.data()));
   for (int32_t value : values) {
-    vb->Append(value);
+    ASSERT_OK(vb->Append(value));
   }
 
   Done();
@@ -2109,9 +2119,10 @@ TEST_F(TestStructBuilder, BulkAppend) {
   ASSERT_OK(char_vb->Resize(list_values.size()));
   ASSERT_OK(int_vb->Resize(int_values.size()));
 
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
 
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2140,9 +2151,10 @@ TEST_F(TestStructBuilder, BulkAppendInvalid) {
   ASSERT_OK(char_vb->Reserve(list_values.size()));
   ASSERT_OK(int_vb->Reserve(int_values.size()));
 
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
 
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2181,8 +2193,9 @@ TEST_F(TestStructBuilder, TestEquality) {
   ASSERT_OK(int_vb->Reserve(int_values.size()));
 
   // setup two equal arrays, one of which takes an unequal bitmap
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2196,8 +2209,9 @@ TEST_F(TestStructBuilder, TestEquality) {
   ASSERT_OK(char_vb->Resize(list_values.size()));
   ASSERT_OK(int_vb->Resize(int_values.size()));
 
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2212,8 +2226,10 @@ TEST_F(TestStructBuilder, TestEquality) {
   ASSERT_OK(int_vb->Resize(int_values.size()));
 
   // setup an unequal one with the unequal bitmap
-  builder_->Append(unequal_struct_is_valid.size(), unequal_struct_is_valid.data());
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(
+      builder_->Append(unequal_struct_is_valid.size(), unequal_struct_is_valid.data()));
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2228,9 +2244,9 @@ TEST_F(TestStructBuilder, TestEquality) {
   ASSERT_OK(int_vb->Resize(int_values.size()));
 
   // setup an unequal one with unequal offsets
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
-  list_vb->Append(unequal_list_offsets.data(), unequal_list_offsets.size(),
-      unequal_list_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
+  ASSERT_OK(list_vb->Append(unequal_list_offsets.data(), unequal_list_offsets.size(),
+      unequal_list_is_valid.data()));
   for (int8_t value : list_values) {
     char_vb->UnsafeAppend(value);
   }
@@ -2245,8 +2261,9 @@ TEST_F(TestStructBuilder, TestEquality) {
   ASSERT_OK(int_vb->Resize(int_values.size()));
 
   // setup anunequal one with unequal values
-  builder_->Append(struct_is_valid.size(), struct_is_valid.data());
-  list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data());
+  ASSERT_OK(builder_->Append(struct_is_valid.size(), struct_is_valid.data()));
+  ASSERT_OK(
+      list_vb->Append(list_offsets.data(), list_offsets.size(), list_is_valid.data()));
   for (int8_t value : unequal_list_values) {
     char_vb->UnsafeAppend(value);
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/builder-benchmark.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/builder-benchmark.cc b/cpp/src/arrow/builder-benchmark.cc
index 5eae9ab..7ca7bb4 100644
--- a/cpp/src/arrow/builder-benchmark.cc
+++ b/cpp/src/arrow/builder-benchmark.cc
@@ -25,12 +25,6 @@ namespace arrow {
 
 constexpr int64_t kFinalSize = 256;
 
-#define ABORT_NOT_OK(s)                              \
-  do {                                               \
-    ::arrow::Status _s = (s);                        \
-    if (ARROW_PREDICT_FALSE(!_s.ok())) { exit(-1); } \
-  } while (0);
-
 static void BM_BuildPrimitiveArrayNoNulls(
     benchmark::State& state) {  // NOLINT non-const reference
   // 2 MiB block

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/builder.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc
index f3ba2dd..16f252c 100644
--- a/cpp/src/arrow/builder.cc
+++ b/cpp/src/arrow/builder.cc
@@ -897,7 +897,7 @@ ARROW_EXPORT Status DecimalBuilder::Append(const decimal::Decimal128& value) {
 Status DecimalBuilder::Init(int64_t capacity) {
   RETURN_NOT_OK(FixedSizeBinaryBuilder::Init(capacity));
   if (byte_width_ == 16) {
-    AllocateResizableBuffer(pool_, null_bitmap_->size(), &sign_bitmap_);
+    RETURN_NOT_OK(AllocateResizableBuffer(pool_, null_bitmap_->size(), &sign_bitmap_));
     sign_bitmap_data_ = sign_bitmap_->mutable_data();
     memset(sign_bitmap_data_, 0, static_cast<size_t>(sign_bitmap_->capacity()));
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/column-benchmark.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/column-benchmark.cc b/cpp/src/arrow/column-benchmark.cc
index 13076a4..e50ddf6 100644
--- a/cpp/src/arrow/column-benchmark.cc
+++ b/cpp/src/arrow/column-benchmark.cc
@@ -24,13 +24,14 @@
 namespace arrow {
 namespace {
 template <typename ArrayType>
-std::shared_ptr<Array> MakePrimitive(int64_t length, int64_t null_count = 0) {
+Status MakePrimitive(int64_t length, int64_t null_count, std::shared_ptr<Array>* out) {
   auto pool = default_memory_pool();
   auto data = std::make_shared<PoolBuffer>(pool);
   auto null_bitmap = std::make_shared<PoolBuffer>(pool);
-  data->Resize(length * sizeof(typename ArrayType::value_type));
-  null_bitmap->Resize(BitUtil::BytesForBits(length));
-  return std::make_shared<ArrayType>(length, data, null_bitmap, 10);
+  RETURN_NOT_OK(data->Resize(length * sizeof(typename ArrayType::value_type)));
+  RETURN_NOT_OK(null_bitmap->Resize(BitUtil::BytesForBits(length)));
+  *out = std::make_shared<ArrayType>(length, data, null_bitmap, null_count);
+  return Status::OK();
 }
 }  // anonymous namespace
 
@@ -38,7 +39,9 @@ static void BM_BuildInt32ColumnByChunk(
     benchmark::State& state) {  // NOLINT non-const reference
   ArrayVector arrays;
   for (int chunk_n = 0; chunk_n < state.range(0); ++chunk_n) {
-    arrays.push_back(MakePrimitive<Int32Array>(100, 10));
+    std::shared_ptr<Array> array;
+    ABORT_NOT_OK(MakePrimitive<Int32Array>(100, 10, &array));
+    arrays.push_back(array);
   }
   const auto INT32 = std::make_shared<Int32Type>();
   const auto field = std::make_shared<Field>("c0", INT32);

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/file.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/file.cc b/cpp/src/arrow/io/file.cc
index b2b8801..936655f 100644
--- a/cpp/src/arrow/io/file.cc
+++ b/cpp/src/arrow/io/file.cc
@@ -111,6 +111,7 @@
 #include "arrow/buffer.h"
 #include "arrow/memory_pool.h"
 #include "arrow/status.h"
+#include "arrow/util/logging.h"
 
 namespace arrow {
 namespace io {
@@ -434,7 +435,7 @@ ReadableFile::ReadableFile(MemoryPool* pool) {
 }
 
 ReadableFile::~ReadableFile() {
-  impl_->Close();
+  DCHECK(impl_->Close().ok());
 }
 
 Status ReadableFile::Open(const std::string& path, std::shared_ptr<ReadableFile>* file) {
@@ -497,7 +498,7 @@ FileOutputStream::FileOutputStream() {
 
 FileOutputStream::~FileOutputStream() {
   // This can fail; better to explicitly call close
-  impl_->Close();
+  DCHECK(impl_->Close().ok());
 }
 
 Status FileOutputStream::Open(
@@ -538,7 +539,7 @@ class MemoryMappedFile::MemoryMap : public MutableBuffer {
   ~MemoryMap() {
     if (file_->is_open()) {
       munmap(mutable_data_, static_cast<size_t>(size_));
-      file_->Close();
+      DCHECK(file_->Close().ok());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/hdfs.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.cc b/cpp/src/arrow/io/hdfs.cc
index ba9c2c2..9ded9bc 100644
--- a/cpp/src/arrow/io/hdfs.cc
+++ b/cpp/src/arrow/io/hdfs.cc
@@ -27,6 +27,7 @@
 #include "arrow/io/hdfs.h"
 #include "arrow/memory_pool.h"
 #include "arrow/status.h"
+#include "arrow/util/logging.h"
 
 namespace arrow {
 namespace io {
@@ -191,7 +192,7 @@ HdfsReadableFile::HdfsReadableFile(MemoryPool* pool) {
 }
 
 HdfsReadableFile::~HdfsReadableFile() {
-  impl_->Close();
+  DCHECK(impl_->Close().ok());
 }
 
 Status HdfsReadableFile::Close() {
@@ -271,7 +272,7 @@ HdfsOutputStream::HdfsOutputStream() {
 }
 
 HdfsOutputStream::~HdfsOutputStream() {
-  impl_->Close();
+  DCHECK(impl_->Close().ok());
 }
 
 Status HdfsOutputStream::Close() {

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/io-file-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-file-test.cc b/cpp/src/arrow/io/io-file-test.cc
index 6550c74..a077f8c 100644
--- a/cpp/src/arrow/io/io-file-test.cc
+++ b/cpp/src/arrow/io/io-file-test.cc
@@ -125,12 +125,12 @@ TEST_F(TestFileOutputStream, Close) {
   ASSERT_OK(file_->Write(reinterpret_cast<const uint8_t*>(data), strlen(data)));
 
   int fd = file_->file_descriptor();
-  file_->Close();
+  ASSERT_OK(file_->Close());
 
   ASSERT_TRUE(FileIsClosed(fd));
 
   // Idempotent
-  file_->Close();
+  ASSERT_OK(file_->Close());
 
   std::shared_ptr<ReadableFile> rd_file;
   ASSERT_OK(ReadableFile::Open(path_, &rd_file));
@@ -215,12 +215,12 @@ TEST_F(TestReadableFile, Close) {
   OpenFile();
 
   int fd = file_->file_descriptor();
-  file_->Close();
+  ASSERT_OK(file_->Close());
 
   ASSERT_TRUE(FileIsClosed(fd));
 
   // Idempotent
-  file_->Close();
+  ASSERT_OK(file_->Close());
 }
 
 TEST_F(TestReadableFile, SeekTellSize) {
@@ -446,7 +446,7 @@ TEST_F(TestMemoryMappedFile, ReadOnly) {
     ASSERT_OK(rwmmap->Write(buffer.data(), buffer_size));
     position += buffer_size;
   }
-  rwmmap->Close();
+  ASSERT_OK(rwmmap->Close());
 
   std::shared_ptr<MemoryMappedFile> rommap;
   ASSERT_OK(MemoryMappedFile::Open(path, FileMode::READ, &rommap));
@@ -459,7 +459,7 @@ TEST_F(TestMemoryMappedFile, ReadOnly) {
     ASSERT_EQ(0, memcmp(out_buffer->data(), buffer.data(), buffer_size));
     position += buffer_size;
   }
-  rommap->Close();
+  ASSERT_OK(rommap->Close());
 }
 
 TEST_F(TestMemoryMappedFile, DISABLED_ReadWriteOver4GbFile) {
@@ -481,7 +481,7 @@ TEST_F(TestMemoryMappedFile, DISABLED_ReadWriteOver4GbFile) {
     ASSERT_OK(rwmmap->Write(buffer.data(), buffer_size));
     position += buffer_size;
   }
-  rwmmap->Close();
+  ASSERT_OK(rwmmap->Close());
 
   std::shared_ptr<MemoryMappedFile> rommap;
   ASSERT_OK(MemoryMappedFile::Open(path, FileMode::READ, &rommap));
@@ -494,7 +494,7 @@ TEST_F(TestMemoryMappedFile, DISABLED_ReadWriteOver4GbFile) {
     ASSERT_EQ(0, memcmp(out_buffer->data(), buffer.data(), buffer_size));
     position += buffer_size;
   }
-  rommap->Close();
+  ASSERT_OK(rommap->Close());
 }
 
 TEST_F(TestMemoryMappedFile, RetainMemoryMapReference) {

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/io-hdfs-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-hdfs-test.cc b/cpp/src/arrow/io/io-hdfs-test.cc
index b8203f0..74f8042 100644
--- a/cpp/src/arrow/io/io-hdfs-test.cc
+++ b/cpp/src/arrow/io/io-hdfs-test.cc
@@ -87,10 +87,9 @@ class TestHdfsClient : public ::testing::Test {
     LibHdfsShim* driver_shim;
 
     client_ = nullptr;
-    scratch_dir_ =
-        boost::filesystem::unique_path(
-            boost::filesystem::temp_directory_path() / "arrow-hdfs/scratch-%%%%")
-            .string();
+    scratch_dir_ = boost::filesystem::unique_path(
+        boost::filesystem::temp_directory_path() / "arrow-hdfs/scratch-%%%%")
+                       .string();
 
     loaded_driver_ = false;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/io-memory-benchmark.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-memory-benchmark.cc b/cpp/src/arrow/io/io-memory-benchmark.cc
index 6aa9577..45cf427 100644
--- a/cpp/src/arrow/io/io-memory-benchmark.cc
+++ b/cpp/src/arrow/io/io-memory-benchmark.cc
@@ -29,15 +29,15 @@ static void BM_SerialMemcopy(benchmark::State& state) {  // NOLINT non-const ref
   constexpr int64_t kTotalSize = 100 * 1024 * 1024;      // 100MB
 
   auto buffer1 = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer1->Resize(kTotalSize);
+  ABORT_NOT_OK(buffer1->Resize(kTotalSize));
 
   auto buffer2 = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer2->Resize(kTotalSize);
+  ABORT_NOT_OK(buffer2->Resize(kTotalSize));
   test::random_bytes(kTotalSize, 0, buffer2->mutable_data());
 
   while (state.KeepRunning()) {
     io::FixedSizeBufferWriter writer(buffer1);
-    writer.Write(buffer2->data(), buffer2->size());
+    ABORT_NOT_OK(writer.Write(buffer2->data(), buffer2->size()));
   }
   state.SetBytesProcessed(int64_t(state.iterations()) * kTotalSize);
 }
@@ -46,16 +46,16 @@ static void BM_ParallelMemcopy(benchmark::State& state) {  // NOLINT non-const r
   constexpr int64_t kTotalSize = 100 * 1024 * 1024;        // 100MB
 
   auto buffer1 = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer1->Resize(kTotalSize);
+  ABORT_NOT_OK(buffer1->Resize(kTotalSize));
 
   auto buffer2 = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer2->Resize(kTotalSize);
+  ABORT_NOT_OK(buffer2->Resize(kTotalSize));
   test::random_bytes(kTotalSize, 0, buffer2->mutable_data());
 
   while (state.KeepRunning()) {
     io::FixedSizeBufferWriter writer(buffer1);
     writer.set_memcopy_threads(4);
-    writer.Write(buffer2->data(), buffer2->size());
+    ABORT_NOT_OK(writer.Write(buffer2->data(), buffer2->size()));
   }
   state.SetBytesProcessed(int64_t(state.iterations()) * kTotalSize);
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/io-memory-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-memory-test.cc b/cpp/src/arrow/io/io-memory-test.cc
index 33249cb..75365df 100644
--- a/cpp/src/arrow/io/io-memory-test.cc
+++ b/cpp/src/arrow/io/io-memory-test.cc
@@ -121,16 +121,16 @@ TEST(TestMemcopy, ParallelMemcopy) {
     int64_t total_size = 3 * 1024 * 1024 + std::rand() % 100;
 
     auto buffer1 = std::make_shared<PoolBuffer>(default_memory_pool());
-    buffer1->Resize(total_size);
+    ASSERT_OK(buffer1->Resize(total_size));
 
     auto buffer2 = std::make_shared<PoolBuffer>(default_memory_pool());
-    buffer2->Resize(total_size);
+    ASSERT_OK(buffer2->Resize(total_size));
     test::random_bytes(total_size, 0, buffer2->mutable_data());
 
     io::FixedSizeBufferWriter writer(buffer1);
     writer.set_memcopy_threads(4);
     writer.set_memcopy_threshold(1024 * 1024);
-    writer.Write(buffer2->data(), buffer2->size());
+    ASSERT_OK(writer.Write(buffer2->data(), buffer2->size()));
 
     ASSERT_EQ(0, memcmp(buffer1->data(), buffer2->data(), buffer1->size()));
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/io/memory.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/memory.cc b/cpp/src/arrow/io/memory.cc
index faf02d2..22721f1 100644
--- a/cpp/src/arrow/io/memory.cc
+++ b/cpp/src/arrow/io/memory.cc
@@ -55,7 +55,7 @@ Status BufferOutputStream::Create(int64_t initial_capacity, MemoryPool* pool,
 
 BufferOutputStream::~BufferOutputStream() {
   // This can fail, better to explicitly call close
-  if (buffer_) { Close(); }
+  if (buffer_) { DCHECK(Close().ok()); }
 }
 
 Status BufferOutputStream::Close() {

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/feather-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/feather-test.cc b/cpp/src/arrow/ipc/feather-test.cc
index fb26df6..807ea4e 100644
--- a/cpp/src/arrow/ipc/feather-test.cc
+++ b/cpp/src/arrow/ipc/feather-test.cc
@@ -50,7 +50,7 @@ class TestTableBuilder : public ::testing::Test {
   void SetUp() { tb_.reset(new TableBuilder(1000)); }
 
   virtual void Finish() {
-    tb_->Finish();
+    ASSERT_OK(tb_->Finish());
 
     table_.reset(new TableMetadata());
     ASSERT_OK(table_->Open(tb_->GetBuffer()));
@@ -107,7 +107,7 @@ TEST_F(TestTableBuilder, AddPrimitiveColumn) {
   std::string user_meta = "as you wish";
   cb->SetUserMetadata(user_meta);
 
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   cb = tb_->AddColumn("f1");
 
@@ -118,7 +118,7 @@ TEST_F(TestTableBuilder, AddPrimitiveColumn) {
   values2.total_bytes = 10000;
 
   cb->SetValues(values2);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   Finish();
 
@@ -148,12 +148,12 @@ TEST_F(TestTableBuilder, AddCategoryColumn) {
   std::unique_ptr<ColumnBuilder> cb = tb_->AddColumn("c0");
   cb->SetValues(values1);
   cb->SetCategory(levels);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   cb = tb_->AddColumn("c1");
   cb->SetValues(values1);
   cb->SetCategory(levels, true);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   Finish();
 
@@ -182,7 +182,7 @@ TEST_F(TestTableBuilder, AddTimestampColumn) {
   std::unique_ptr<ColumnBuilder> cb = tb_->AddColumn("c0");
   cb->SetValues(values1);
   cb->SetTimestamp(TimeUnit::MILLI);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   cb = tb_->AddColumn("c1");
 
@@ -190,7 +190,7 @@ TEST_F(TestTableBuilder, AddTimestampColumn) {
 
   cb->SetValues(values1);
   cb->SetTimestamp(TimeUnit::SECOND, tz);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   Finish();
 
@@ -216,7 +216,7 @@ TEST_F(TestTableBuilder, AddDateColumn) {
   std::unique_ptr<ColumnBuilder> cb = tb_->AddColumn("d0");
   cb->SetValues(values1);
   cb->SetDate();
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
 
   Finish();
 
@@ -233,7 +233,7 @@ TEST_F(TestTableBuilder, AddTimeColumn) {
   std::unique_ptr<ColumnBuilder> cb = tb_->AddColumn("c0");
   cb->SetValues(values1);
   cb->SetTime(TimeUnit::SECOND);
-  cb->Finish();
+  ASSERT_OK(cb->Finish());
   Finish();
 
   auto col = table_->column(0);
@@ -379,7 +379,7 @@ TEST_F(TestTableWriter, TimeTypes) {
 
   for (int i = 1; i < schema->num_fields(); ++i) {
     std::shared_ptr<Array> arr;
-    LoadArray(schema->field(i)->type(), fields, buffers, &arr);
+    ASSERT_OK(LoadArray(schema->field(i)->type(), fields, buffers, &arr));
     arrays.push_back(arr);
   }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/feather.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/feather.cc b/cpp/src/arrow/ipc/feather.cc
index 023e7ec..7f577a0 100644
--- a/cpp/src/arrow/ipc/feather.cc
+++ b/cpp/src/arrow/ipc/feather.cc
@@ -498,7 +498,7 @@ class TableWriter::TableWriterImpl : public ArrayVisitor {
 
   Status Finalize() {
     RETURN_NOT_OK(CheckStarted());
-    metadata_.Finish();
+    RETURN_NOT_OK(metadata_.Finish());
 
     auto buffer = metadata_.GetBuffer();
 
@@ -655,8 +655,7 @@ class TableWriter::TableWriterImpl : public ArrayVisitor {
   Status Append(const std::string& name, const Array& values) {
     current_column_ = metadata_.AddColumn(name);
     RETURN_NOT_OK(values.Accept(this));
-    current_column_->Finish();
-    return Status::OK();
+    return current_column_->Finish();
   }
 
  private:

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/ipc-json-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/ipc-json-test.cc b/cpp/src/arrow/ipc/ipc-json-test.cc
index e06af9f..9297146 100644
--- a/cpp/src/arrow/ipc/ipc-json-test.cc
+++ b/cpp/src/arrow/ipc/ipc-json-test.cc
@@ -224,10 +224,10 @@ void MakeBatchArrays(const std::shared_ptr<Schema>& schema, const int num_rows,
   StringBuilder string_builder(default_memory_pool());
   for (int i = 0; i < num_rows; ++i) {
     if (!is_valid[i]) {
-      string_builder.AppendNull();
+      ASSERT_OK(string_builder.AppendNull());
     } else {
       test::random_ascii(kBufferSize, seed++, buffer);
-      string_builder.Append(buffer, kBufferSize);
+      ASSERT_OK(string_builder.Append(buffer, kBufferSize));
     }
   }
   std::shared_ptr<Array> v3;

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/ipc-read-write-benchmark.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/ipc-read-write-benchmark.cc b/cpp/src/arrow/ipc/ipc-read-write-benchmark.cc
index 1aecdbc..c890d82 100644
--- a/cpp/src/arrow/ipc/ipc-read-write-benchmark.cc
+++ b/cpp/src/arrow/ipc/ipc-read-write-benchmark.cc
@@ -46,13 +46,13 @@ std::shared_ptr<RecordBatch> MakeRecordBatch(int64_t total_size, int64_t num_fie
   typename TypeTraits<TYPE>::BuilderType builder(pool, type);
   for (size_t i = 0; i < values.size(); ++i) {
     if (is_valid[i]) {
-      builder.Append(values[i]);
+      ABORT_NOT_OK(builder.Append(values[i]));
     } else {
-      builder.AppendNull();
+      ABORT_NOT_OK(builder.AppendNull());
     }
   }
   std::shared_ptr<Array> array;
-  builder.Finish(&array);
+  ABORT_NOT_OK(builder.Finish(&array));
 
   ArrayVector arrays;
   std::vector<std::shared_ptr<Field>> fields;
@@ -72,7 +72,7 @@ static void BM_WriteRecordBatch(benchmark::State& state) {  // NOLINT non-const
   constexpr int64_t kTotalSize = 1 << 20;
 
   auto buffer = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer->Resize(kTotalSize & 2);
+  ABORT_NOT_OK(buffer->Resize(kTotalSize & 2));
   auto record_batch = MakeRecordBatch<Int64Type>(kTotalSize, state.range(0));
 
   while (state.KeepRunning()) {
@@ -80,7 +80,7 @@ static void BM_WriteRecordBatch(benchmark::State& state) {  // NOLINT non-const
     int32_t metadata_length;
     int64_t body_length;
     if (!ipc::WriteRecordBatch(*record_batch, 0, &stream, &metadata_length, &body_length,
-             default_memory_pool())
+            default_memory_pool())
              .ok()) {
       state.SkipWithError("Failed to write!");
     }
@@ -93,7 +93,7 @@ static void BM_ReadRecordBatch(benchmark::State& state) {  // NOLINT non-const r
   constexpr int64_t kTotalSize = 1 << 20;
 
   auto buffer = std::make_shared<PoolBuffer>(default_memory_pool());
-  buffer->Resize(kTotalSize & 2);
+  ABORT_NOT_OK(buffer->Resize(kTotalSize & 2));
   auto record_batch = MakeRecordBatch<Int64Type>(kTotalSize, state.range(0));
 
   io::BufferOutputStream stream(buffer);
@@ -101,7 +101,7 @@ static void BM_ReadRecordBatch(benchmark::State& state) {  // NOLINT non-const r
   int32_t metadata_length;
   int64_t body_length;
   if (!ipc::WriteRecordBatch(*record_batch, 0, &stream, &metadata_length, &body_length,
-           default_memory_pool())
+          default_memory_pool())
            .ok()) {
     state.SkipWithError("Failed to write!");
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/json-internal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json-internal.cc b/cpp/src/arrow/ipc/json-internal.cc
index bf2c194..beebb4f 100644
--- a/cpp/src/arrow/ipc/json-internal.cc
+++ b/cpp/src/arrow/ipc/json-internal.cc
@@ -974,12 +974,12 @@ class ArrayReader {
     DCHECK_EQ(static_cast<int32_t>(json_data_arr.Size()), length_);
     for (int i = 0; i < length_; ++i) {
       if (!is_valid_[i]) {
-        builder.AppendNull();
+        RETURN_NOT_OK(builder.AppendNull());
         continue;
       }
 
       const rj::Value& val = json_data_arr[i];
-      builder.Append(UnboxValue<T>(val));
+      RETURN_NOT_OK(builder.Append(UnboxValue<T>(val)));
     }
 
     return builder.Finish(&result_);
@@ -1000,14 +1000,14 @@ class ArrayReader {
     auto byte_buffer = std::make_shared<PoolBuffer>(pool_);
     for (int i = 0; i < length_; ++i) {
       if (!is_valid_[i]) {
-        builder.AppendNull();
+        RETURN_NOT_OK(builder.AppendNull());
         continue;
       }
 
       const rj::Value& val = json_data_arr[i];
       DCHECK(val.IsString());
       if (std::is_base_of<StringType, T>::value) {
-        builder.Append(val.GetString());
+        RETURN_NOT_OK(builder.Append(val.GetString()));
       } else {
         std::string hex_string = val.GetString();
 
@@ -1048,7 +1048,7 @@ class ArrayReader {
 
     for (int i = 0; i < length_; ++i) {
       if (!is_valid_[i]) {
-        builder.AppendNull();
+        RETURN_NOT_OK(builder.AppendNull());
         continue;
       }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/ipc/test-common.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/test-common.h b/cpp/src/arrow/ipc/test-common.h
index deaeb59..747aca0 100644
--- a/cpp/src/arrow/ipc/test-common.h
+++ b/cpp/src/arrow/ipc/test-common.h
@@ -96,11 +96,11 @@ const auto kListListInt32 = list(kListInt32);
 Status MakeRandomInt32Array(
     int64_t length, bool include_nulls, MemoryPool* pool, std::shared_ptr<Array>* out) {
   std::shared_ptr<PoolBuffer> data;
-  test::MakeRandomInt32PoolBuffer(length, pool, &data);
+  RETURN_NOT_OK(test::MakeRandomInt32PoolBuffer(length, pool, &data));
   Int32Builder builder(pool, int32());
   if (include_nulls) {
     std::shared_ptr<PoolBuffer> valid_bytes;
-    test::MakeRandomBytePoolBuffer(length, pool, &valid_bytes);
+    RETURN_NOT_OK(test::MakeRandomBytePoolBuffer(length, pool, &valid_bytes));
     RETURN_NOT_OK(builder.Append(
         reinterpret_cast<const int32_t*>(data->data()), length, valid_bytes->data()));
     return builder.Finish(out);
@@ -149,11 +149,13 @@ Status MakeRandomBooleanArray(
     const int length, bool include_nulls, std::shared_ptr<Array>* out) {
   std::vector<uint8_t> values(length);
   test::random_null_bytes(length, 0.5, values.data());
-  auto data = test::bytes_to_null_buffer(values);
+  std::shared_ptr<Buffer> data;
+  RETURN_NOT_OK(BitUtil::BytesToBits(values, &data));
 
   if (include_nulls) {
     std::vector<uint8_t> valid_bytes(length);
-    auto null_bitmap = test::bytes_to_null_buffer(valid_bytes);
+    std::shared_ptr<Buffer> null_bitmap;
+    RETURN_NOT_OK(BitUtil::BytesToBits(valid_bytes, &null_bitmap));
     test::random_null_bytes(length, 0.1, valid_bytes.data());
     *out = std::make_shared<BooleanArray>(length, data, null_bitmap, -1);
   } else {
@@ -611,9 +613,9 @@ void AppendValues(const std::vector<bool>& is_valid, const std::vector<T>& value
     BuilderType* builder) {
   for (size_t i = 0; i < values.size(); ++i) {
     if (is_valid[i]) {
-      builder->Append(values[i]);
+      ASSERT_OK(builder->Append(values[i]));
     } else {
-      builder->AppendNull();
+      ASSERT_OK(builder->AppendNull());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/pretty_print-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/pretty_print-test.cc b/cpp/src/arrow/pretty_print-test.cc
index 80cd9cf..72bd0a8 100644
--- a/cpp/src/arrow/pretty_print-test.cc
+++ b/cpp/src/arrow/pretty_print-test.cc
@@ -87,10 +87,10 @@ TEST_F(TestPrettyPrint, FixedSizeBinaryType) {
   auto type = fixed_size_binary(3);
   FixedSizeBinaryBuilder builder(default_memory_pool(), type);
 
-  builder.Append(values[0]);
-  builder.Append(values[1]);
-  builder.Append(values[2]);
-  builder.Finish(&array);
+  ASSERT_OK(builder.Append(values[0]));
+  ASSERT_OK(builder.Append(values[1]));
+  ASSERT_OK(builder.Append(values[2]));
+  ASSERT_OK(builder.Finish(&array));
 
   CheckArray(*array, 0, ex);
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/python/builtin_convert.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/python/builtin_convert.cc b/cpp/src/arrow/python/builtin_convert.cc
index c7af567..11114b0 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -464,9 +464,8 @@ class FixedWidthBytesConverter
   inline Status AppendItem(const OwnedRef& item) {
     PyObject* bytes_obj;
     OwnedRef tmp;
-    Py_ssize_t expected_length =
-        std::dynamic_pointer_cast<FixedSizeBinaryType>(typed_builder_->type())
-            ->byte_width();
+    Py_ssize_t expected_length = std::dynamic_pointer_cast<FixedSizeBinaryType>(
+        typed_builder_->type())->byte_width();
     if (item.obj() == Py_None) {
       RETURN_NOT_OK(typed_builder_->AppendNull());
       return Status::OK();
@@ -518,7 +517,7 @@ class ListConverter : public TypedConverterVisitor<ListBuilder, ListConverter> {
     if (item.obj() == Py_None) {
       return typed_builder_->AppendNull();
     } else {
-      typed_builder_->Append();
+      RETURN_NOT_OK(typed_builder_->Append());
       PyObject* item_obj = item.obj();
       int64_t list_size = static_cast<int64_t>(PySequence_Size(item_obj));
       return value_converter_->AppendData(item_obj, list_size);
@@ -607,8 +606,7 @@ Status ListConverter::Init(ArrayBuilder* builder) {
     return Status::NotImplemented("value type not implemented");
   }
 
-  value_converter_->Init(typed_builder_->value_builder());
-  return Status::OK();
+  return value_converter_->Init(typed_builder_->value_builder());
 }
 
 Status AppendPySequence(PyObject* obj, int64_t size,
@@ -620,8 +618,7 @@ Status AppendPySequence(PyObject* obj, int64_t size,
     ss << "No type converter implemented for " << type->ToString();
     return Status::NotImplemented(ss.str());
   }
-  converter->Init(builder);
-
+  RETURN_NOT_OK(converter->Init(builder));
   return converter->AppendData(obj, size);
 }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/python/pandas_convert.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/python/pandas_convert.cc b/cpp/src/arrow/python/pandas_convert.cc
index 0858d06..f75a2ba 100644
--- a/cpp/src/arrow/python/pandas_convert.cc
+++ b/cpp/src/arrow/python/pandas_convert.cc
@@ -537,9 +537,9 @@ Status PandasConverter::ConvertDates() {
   for (int64_t i = 0; i < length_; ++i) {
     obj = objects[i];
     if (PyDate_CheckExact(obj)) {
-      date_builder.Append(UnboxDate<ArrowType>::Unbox(obj));
+      RETURN_NOT_OK(date_builder.Append(UnboxDate<ArrowType>::Unbox(obj)));
     } else if (PandasObjectIsNull(obj)) {
-      date_builder.AppendNull();
+      RETURN_NOT_OK(date_builder.AppendNull());
     } else {
       return InvalidConversion(obj, "date");
     }
@@ -592,7 +592,7 @@ Status PandasConverter::ConvertDecimals() {
           break;
       }
     } else if (PandasObjectIsNull(object)) {
-      decimal_builder.AppendNull();
+      RETURN_NOT_OK(decimal_builder.AppendNull());
     } else {
       return InvalidConversion(object, "decimal.Decimal");
     }
@@ -939,7 +939,7 @@ inline Status PandasConverter::ConvertTypedLists(const std::shared_ptr<DataType>
       int64_t size = PyArray_DIM(numpy_array, 0);
       auto data = reinterpret_cast<const T*>(PyArray_DATA(numpy_array));
       if (traits::supports_nulls) {
-        null_bitmap_->Resize(size, false);
+        RETURN_NOT_OK(null_bitmap_->Resize(size, false));
         // TODO(uwe): A bitmap would be more space-efficient but the Builder API doesn't
         // currently support this.
         // ValuesToBitmap<ITEM_TYPE>(data, size, null_bitmap_->mutable_data());
@@ -2423,7 +2423,7 @@ class ArrowDeserializer {
   }
 
   Status Visit(const StructType& type) {
-    AllocateOutput(NPY_OBJECT);
+    RETURN_NOT_OK(AllocateOutput(NPY_OBJECT));
     auto out_values = reinterpret_cast<PyObject**>(PyArray_DATA(arr_));
     return ConvertStruct(data_, out_values);
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/python/python-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/python/python-test.cc b/cpp/src/arrow/python/python-test.cc
index 43c7f60..592a5e6 100644
--- a/cpp/src/arrow/python/python-test.cc
+++ b/cpp/src/arrow/python/python-test.cc
@@ -77,7 +77,7 @@ TEST(PandasConversionTest, TestObjectBlockWriteFails) {
   const char value[] = {'\xf1', '\0'};
 
   for (int i = 0; i < 1000; ++i) {
-    builder.Append(value, static_cast<int32_t>(strlen(value)));
+    ASSERT_OK(builder.Append(value, static_cast<int32_t>(strlen(value))));
   }
 
   std::shared_ptr<Array> arr;

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/status.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc
index 3a39c84..77ecb93 100644
--- a/cpp/src/arrow/status.cc
+++ b/cpp/src/arrow/status.cc
@@ -16,23 +16,25 @@
 
 namespace arrow {
 
-Status::Status(StatusCode code, const std::string& msg, int16_t posix_code) {
+Status::Status(StatusCode code, const std::string& msg) {
   assert(code != StatusCode::OK);
-  const uint32_t size = static_cast<uint32_t>(msg.size());
-  char* result = new char[size + 7];
-  memcpy(result, &size, sizeof(size));
-  result[4] = static_cast<char>(code);
-  memcpy(result + 5, &posix_code, sizeof(posix_code));
-  memcpy(result + 7, msg.c_str(), msg.size());
-  state_ = result;
+  state_ = new State;
+  state_->code = code;
+  state_->msg = msg;
 }
 
-const char* Status::CopyState(const char* state) {
-  uint32_t size;
-  memcpy(&size, state, sizeof(size));
-  char* result = new char[size + 7];
-  memcpy(result, state, size + 7);
-  return result;
+void Status::CopyFrom(const State* state) {
+  delete state_;
+  if (state == nullptr) {
+    state_ = nullptr;
+  } else {
+    state_ = new State(*state);
+  }
+}
+
+std::ostream& operator<<(std::ostream& os, const Status& x) {
+  os << x.ToString();
+  return os;
 }
 
 std::string Status::CodeAsString() const {
@@ -74,12 +76,8 @@ std::string Status::CodeAsString() const {
 std::string Status::ToString() const {
   std::string result(CodeAsString());
   if (state_ == NULL) { return result; }
-
-  result.append(": ");
-
-  uint32_t length;
-  memcpy(&length, state_, sizeof(length));
-  result.append(reinterpret_cast<const char*>(state_ + 7), length);
+  result += ": ";
+  result += state_->msg;
   return result;
 }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/status.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h
index bfb945c..448f4fa 100644
--- a/cpp/src/arrow/status.h
+++ b/cpp/src/arrow/status.h
@@ -10,7 +10,7 @@
 // non-const method, all threads accessing the same Status must use
 // external synchronization.
 
-// Adapted from Kudu github.com/apache/kudu
+// Adapted from Apache Kudu, TensorFlow
 
 #ifndef ARROW_STATUS_H_
 #define ARROW_STATUS_H_
@@ -72,13 +72,18 @@ enum class StatusCode : char {
   PlasmaStoreFull = 22
 };
 
+#if defined(__clang__)
+// Only clang supports warn_unused_result as a type annotation.
+class ARROW_MUST_USE_RESULT ARROW_EXPORT Status;
+#endif
+
 class ARROW_EXPORT Status {
  public:
   // Create a success status.
   Status() : state_(NULL) {}
-  ~Status() { delete[] state_; }
+  ~Status() { delete state_; }
 
-  Status(StatusCode code, const std::string& msg) : Status(code, msg, -1) {}
+  Status(StatusCode code, const std::string& msg);
 
   // Copy the specified status.
   Status(const Status& s);
@@ -88,44 +93,44 @@ class ARROW_EXPORT Status {
   static Status OK() { return Status(); }
 
   // Return error status of an appropriate type.
-  static Status OutOfMemory(const std::string& msg, int16_t posix_code = -1) {
-    return Status(StatusCode::OutOfMemory, msg, posix_code);
+  static Status OutOfMemory(const std::string& msg) {
+    return Status(StatusCode::OutOfMemory, msg);
   }
 
   static Status KeyError(const std::string& msg) {
-    return Status(StatusCode::KeyError, msg, -1);
+    return Status(StatusCode::KeyError, msg);
   }
 
   static Status TypeError(const std::string& msg) {
-    return Status(StatusCode::TypeError, msg, -1);
+    return Status(StatusCode::TypeError, msg);
   }
 
   static Status UnknownError(const std::string& msg) {
-    return Status(StatusCode::UnknownError, msg, -1);
+    return Status(StatusCode::UnknownError, msg);
   }
 
   static Status NotImplemented(const std::string& msg) {
-    return Status(StatusCode::NotImplemented, msg, -1);
+    return Status(StatusCode::NotImplemented, msg);
   }
 
   static Status Invalid(const std::string& msg) {
-    return Status(StatusCode::Invalid, msg, -1);
+    return Status(StatusCode::Invalid, msg);
   }
 
   static Status IOError(const std::string& msg) {
-    return Status(StatusCode::IOError, msg, -1);
+    return Status(StatusCode::IOError, msg);
   }
 
   static Status PlasmaObjectExists(const std::string& msg) {
-    return Status(StatusCode::PlasmaObjectExists, msg, -1);
+    return Status(StatusCode::PlasmaObjectExists, msg);
   }
 
   static Status PlasmaObjectNonexistent(const std::string& msg) {
-    return Status(StatusCode::PlasmaObjectNonexistent, msg, -1);
+    return Status(StatusCode::PlasmaObjectNonexistent, msg);
   }
 
   static Status PlasmaStoreFull(const std::string& msg) {
-    return Status(StatusCode::PlasmaStoreFull, msg, -1);
+    return Status(StatusCode::PlasmaStoreFull, msg);
   }
 
   // Returns true iff the status indicates success.
@@ -155,45 +160,31 @@ class ARROW_EXPORT Status {
   // text or posix code information.
   std::string CodeAsString() const;
 
-  // Get the POSIX code associated with this Status, or -1 if there is none.
-  int16_t posix_code() const;
+  StatusCode code() const { return ok() ? StatusCode::OK : state_->code; }
 
-  StatusCode code() const {
-    return ((state_ == NULL) ? StatusCode::OK : static_cast<StatusCode>(state_[4]));
-  }
+  std::string message() const { return ok() ? "" : state_->msg; }
 
-  std::string message() const {
-    uint32_t length;
-    memcpy(&length, state_, sizeof(length));
+ private:
+  struct State {
+    StatusCode code;
     std::string msg;
-    msg.append((state_ + 7), length);
-    return msg;
-  }
+  };
+  // OK status has a `NULL` state_.  Otherwise, `state_` points to
+  // a `State` structure containing the error code and message(s)
+  State* state_;
 
- private:
-  // OK status has a NULL state_.  Otherwise, state_ is a new[] array
-  // of the following form:
-  //    state_[0..3] == length of message
-  //    state_[4]    == code
-  //    state_[5..6] == posix_code
-  //    state_[7..]  == message
-  const char* state_;
-
-  Status(StatusCode code, const std::string& msg, int16_t posix_code);
-  static const char* CopyState(const char* s);
+  void CopyFrom(const State* s);
 };
 
-inline Status::Status(const Status& s) {
-  state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_);
-}
+std::ostream& operator<<(std::ostream& os, const Status& x);
+
+inline Status::Status(const Status& s)
+    : state_((s.state_ == NULL) ? NULL : new State(*s.state_)) {}
 
 inline void Status::operator=(const Status& s) {
   // The following condition catches both aliasing (when this == &s),
   // and the common case where both s and *this are ok.
-  if (state_ != s.state_) {
-    delete[] state_;
-    state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_);
-  }
+  if (state_ != s.state_) { CopyFrom(s.state_); }
 }
 
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/test-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/test-util.h b/cpp/src/arrow/test-util.h
index 94937b5..2cff97a 100644
--- a/cpp/src/arrow/test-util.h
+++ b/cpp/src/arrow/test-util.h
@@ -59,6 +59,12 @@
     EXPECT_TRUE(s.ok());        \
   } while (0)
 
+#define ABORT_NOT_OK(s)                              \
+  do {                                               \
+    ::arrow::Status _s = (s);                        \
+    if (ARROW_PREDICT_FALSE(!_s.ok())) { exit(-1); } \
+  } while (0);
+
 namespace arrow {
 
 using ArrayVector = std::vector<std::shared_ptr<Array>>;
@@ -176,14 +182,6 @@ static inline int64_t null_count(const std::vector<uint8_t>& valid_bytes) {
   return result;
 }
 
-std::shared_ptr<Buffer> bytes_to_null_buffer(const std::vector<uint8_t>& bytes) {
-  std::shared_ptr<Buffer> out;
-
-  // TODO(wesm): error checking
-  BitUtil::BytesToBits(bytes, &out);
-  return out;
-}
-
 Status MakeRandomInt32PoolBuffer(int64_t length, MemoryPool* pool,
     std::shared_ptr<PoolBuffer>* pool_buffer, uint32_t seed = 0) {
   DCHECK(pool);

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/type-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type-test.cc b/cpp/src/arrow/type-test.cc
index 1fbb683..7f3adef 100644
--- a/cpp/src/arrow/type-test.cc
+++ b/cpp/src/arrow/type-test.cc
@@ -188,7 +188,7 @@ TEST_F(TestSchema, TestAddMetadata) {
       new KeyValueMetadata({"foo", "bar"}, {"bizz", "buzz"}));
   auto schema = std::make_shared<Schema>(fields);
   std::shared_ptr<Schema> new_schema;
-  schema->AddMetadata(metadata, &new_schema);
+  ASSERT_OK(schema->AddMetadata(metadata, &new_schema));
   ASSERT_TRUE(metadata->Equals(*new_schema->metadata()));
 
   // Not copied

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/util/bit-util.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util.cc b/cpp/src/arrow/util/bit-util.cc
index ba0bfd7..5bbec6f 100644
--- a/cpp/src/arrow/util/bit-util.cc
+++ b/cpp/src/arrow/util/bit-util.cc
@@ -34,7 +34,7 @@
 
 namespace arrow {
 
-void BitUtil::BytesToBits(const std::vector<uint8_t>& bytes, uint8_t* bits) {
+void BitUtil::FillBitsFromBytes(const std::vector<uint8_t>& bytes, uint8_t* bits) {
   for (size_t i = 0; i < bytes.size(); ++i) {
     if (bytes[i] > 0) { SetBit(bits, i); }
   }
@@ -48,7 +48,7 @@ Status BitUtil::BytesToBits(
   RETURN_NOT_OK(AllocateBuffer(default_memory_pool(), bit_length, &buffer));
 
   memset(buffer->mutable_data(), 0, static_cast<size_t>(bit_length));
-  BytesToBits(bytes, buffer->mutable_data());
+  FillBitsFromBytes(bytes, buffer->mutable_data());
 
   *out = buffer;
   return Status::OK();

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/util/bit-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util.h b/cpp/src/arrow/util/bit-util.h
index bba9d2d..d055c75 100644
--- a/cpp/src/arrow/util/bit-util.h
+++ b/cpp/src/arrow/util/bit-util.h
@@ -441,7 +441,7 @@ static T ShiftRightLogical(T v, int shift) {
   return static_cast<typename make_unsigned<T>::type>(v) >> shift;
 }
 
-void BytesToBits(const std::vector<uint8_t>& bytes, uint8_t* bits);
+void FillBitsFromBytes(const std::vector<uint8_t>& bytes, uint8_t* bits);
 ARROW_EXPORT Status BytesToBits(const std::vector<uint8_t>&, std::shared_ptr<Buffer>*);
 
 }  // namespace BitUtil

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/util/decimal-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/decimal-test.cc b/cpp/src/arrow/util/decimal-test.cc
index 72107a2..e3fd480 100644
--- a/cpp/src/arrow/util/decimal-test.cc
+++ b/cpp/src/arrow/util/decimal-test.cc
@@ -249,7 +249,7 @@ TYPED_TEST(DecimalZerosTest, LeadingZerosNoDecimalPoint) {
   Decimal<TypeParam> d;
   int precision;
   int scale;
-  FromString(string_value, &d, &precision, &scale);
+  ASSERT_OK(FromString(string_value, &d, &precision, &scale));
   ASSERT_EQ(precision, 7);
   ASSERT_EQ(scale, 0);
   ASSERT_EQ(d.value, 0);
@@ -260,7 +260,7 @@ TYPED_TEST(DecimalZerosTest, LeadingZerosDecimalPoint) {
   Decimal<TypeParam> d;
   int precision;
   int scale;
-  FromString(string_value, &d, &precision, &scale);
+  ASSERT_OK(FromString(string_value, &d, &precision, &scale));
   // We explicitly do not support this for now, otherwise this would be ASSERT_EQ
   ASSERT_NE(precision, 7);
 
@@ -273,7 +273,7 @@ TYPED_TEST(DecimalZerosTest, NoLeadingZerosDecimalPoint) {
   Decimal<TypeParam> d;
   int precision;
   int scale;
-  FromString(string_value, &d, &precision, &scale);
+  ASSERT_OK(FromString(string_value, &d, &precision, &scale));
   ASSERT_EQ(precision, 5);
   ASSERT_EQ(scale, 5);
   ASSERT_EQ(d.value, 0);

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/util/decimal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/decimal.h b/cpp/src/arrow/util/decimal.h
index f113c33..0d84ba8 100644
--- a/cpp/src/arrow/util/decimal.h
+++ b/cpp/src/arrow/util/decimal.h
@@ -51,7 +51,7 @@ ARROW_EXPORT Status FromString(const std::string& s, Decimal<T>* out,
 template <typename T>
 struct ARROW_EXPORT Decimal {
   Decimal() : value() {}
-  explicit Decimal(const std::string& s) : value() { FromString(s, this); }
+  explicit Decimal(const std::string& s) : value() { DCHECK(FromString(s, this).ok()); }
   explicit Decimal(const char* s) : Decimal(std::string(s)) {}
   explicit Decimal(const T& value) : value(value) {}
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/arrow/util/macros.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/macros.h b/cpp/src/arrow/util/macros.h
index affe8bc..a2f704f 100644
--- a/cpp/src/arrow/util/macros.h
+++ b/cpp/src/arrow/util/macros.h
@@ -41,4 +41,12 @@
 #define ARROW_PREDICT_TRUE(x) x
 #endif
 
+#if (defined(__GNUC__) || defined(__APPLE__))
+#define ARROW_MUST_USE_RESULT __attribute__((warn_unused_result))
+#elif defined(_MSC_VER)
+#define ARROW_MUST_USE_RESULT
+#else
+#define ARROW_MUST_USE_RESULT
+#endif
+
 #endif  // ARROW_UTIL_MACROS_H

http://git-wip-us.apache.org/repos/asf/arrow/blob/00a7d55c/cpp/src/plasma/store.cc
----------------------------------------------------------------------
diff --git a/cpp/src/plasma/store.cc b/cpp/src/plasma/store.cc
index 5151a44..9394e3d 100644
--- a/cpp/src/plasma/store.cc
+++ b/cpp/src/plasma/store.cc
@@ -404,8 +404,10 @@ void PlasmaStore::connect_client(int listener_sock) {
   Client* client = new Client(client_fd);
   // Add a callback to handle events on this socket.
   // TODO(pcm): Check return value.
-  loop_->add_file_event(
-      client_fd, kEventLoopRead, [this, client](int events) { process_message(client); });
+  loop_->add_file_event(client_fd, kEventLoopRead, [this, client](int events) {
+    Status s = process_message(client);
+    if (!s.ok()) { ARROW_LOG(FATAL) << "Failed to process file event: " << s; }
+  });
   ARROW_LOG(DEBUG) << "New connection with fd " << client_fd;
 }
 


Mime
View raw message