You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/01/31 17:52:00 UTC
[arrow] branch master updated: ARROW-4430: [C++] Fix untested
TypedByteBuffer::Append method
This is an automated email from the ASF dual-hosted git repository.
wesm 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 e59bf77 ARROW-4430: [C++] Fix untested TypedByteBuffer<T>::Append method
e59bf77 is described below
commit e59bf777bb8babc2fbef4cc881370478acfb8f97
Author: Benjamin Kietzman <be...@gmail.com>
AuthorDate: Thu Jan 31 11:51:52 2019 -0600
ARROW-4430: [C++] Fix untested TypedByteBuffer<T>::Append method
Author: Benjamin Kietzman <be...@gmail.com>
Closes #3528 from bkietz/ARROW-4430-test-typedbufferbuilder-append-copies and squashes the following commits:
d70e71de <Benjamin Kietzman> explicitly cast from bool to TypeParam
f7397206 <Benjamin Kietzman> fixed format issue
2789a4d4 <Benjamin Kietzman> add test, fix append method
---
cpp/src/arrow/buffer-builder.h | 3 ++-
cpp/src/arrow/buffer-test.cc | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/cpp/src/arrow/buffer-builder.h b/cpp/src/arrow/buffer-builder.h
index 9344d5d..b27fbd8 100644
--- a/cpp/src/arrow/buffer-builder.h
+++ b/cpp/src/arrow/buffer-builder.h
@@ -196,7 +196,8 @@ class TypedBufferBuilder<T, typename std::enable_if<std::is_arithmetic<T>::value
}
Status Append(const int64_t num_copies, T value) {
- ARROW_RETURN_NOT_OK(Resize(GrowByFactor(num_copies + length()), false));
+ ARROW_RETURN_NOT_OK(
+ Resize(BufferBuilder::GrowByFactor(num_copies + length()), false));
UnsafeAppend(num_copies, value);
return Status::OK();
}
diff --git a/cpp/src/arrow/buffer-test.cc b/cpp/src/arrow/buffer-test.cc
index 8ff1174..0154892 100644
--- a/cpp/src/arrow/buffer-test.cc
+++ b/cpp/src/arrow/buffer-test.cc
@@ -310,6 +310,22 @@ TYPED_TEST(TypedTestBufferBuilder, BasicTypedBufferBuilderUsage) {
}
}
+TYPED_TEST(TypedTestBufferBuilder, AppendCopies) {
+ TypedBufferBuilder<TypeParam> builder;
+
+ ASSERT_OK(builder.Append(13, static_cast<TypeParam>(1)));
+ ASSERT_OK(builder.Append(17, static_cast<TypeParam>(0)));
+ ASSERT_EQ(builder.length(), 13 + 17);
+
+ std::shared_ptr<Buffer> built;
+ ASSERT_OK(builder.Finish(&built));
+
+ auto data = reinterpret_cast<const TypeParam*>(built->data());
+ for (int i = 0; i != 13 + 17; ++i, ++data) {
+ ASSERT_EQ(*data, static_cast<TypeParam>(i < 13)) << "index = " << i;
+ }
+}
+
TEST(TestBufferBuilder, BasicBoolBufferBuilderUsage) {
TypedBufferBuilder<bool> builder;