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 2018/12/26 19:44:57 UTC
[arrow] branch master updated: ARROW-4115: [Gandiva] zero-init
boolean data bufs
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 2849f46 ARROW-4115: [Gandiva] zero-init boolean data bufs
2849f46 is described below
commit 2849f46fcc203e4c9c5e09b3065ffb92cd133dce
Author: Pindikura Ravindra <ra...@dremio.com>
AuthorDate: Wed Dec 26 13:44:49 2018 -0600
ARROW-4115: [Gandiva] zero-init boolean data bufs
Author: Pindikura Ravindra <ra...@dremio.com>
Closes #3263 from pravindra/arrow-4115 and squashes the following commits:
d6b7834e3 <Pindikura Ravindra> ARROW-4115: zero-init boolean data bufs
---
cpp/src/gandiva/projector.cc | 6 +++---
cpp/src/gandiva/tests/projector_test.cc | 9 +++++----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/cpp/src/gandiva/projector.cc b/cpp/src/gandiva/projector.cc
index d5902fc..4cb352f 100644
--- a/cpp/src/gandiva/projector.cc
+++ b/cpp/src/gandiva/projector.cc
@@ -155,10 +155,10 @@ Status Projector::AllocArrayData(const DataTypePtr& type, int64_t num_records,
int64_t data_len = arrow::BitUtil::BytesForBits(num_records * fw_type.bit_width());
ARROW_RETURN_NOT_OK(arrow::AllocateBuffer(pool, data_len, &data));
- // Valgrind detects unitialized memory at byte level. Boolean types use bits
- // and can leave buffer memory uninitialized in the last byte.
+ // This is not strictly required but valgrind gets confused and detects this
+ // as uninitialized memory access. See arrow::util::SetBitTo().
if (type->id() == arrow::Type::BOOL) {
- data->mutable_data()[data_len - 1] = 0;
+ memset(data->mutable_data(), 0, data_len);
}
*array_data = arrow::ArrayData::Make(type, num_records, {null_bitmap, data});
diff --git a/cpp/src/gandiva/tests/projector_test.cc b/cpp/src/gandiva/tests/projector_test.cc
index 1aeb43b..33cdce0 100644
--- a/cpp/src/gandiva/tests/projector_test.cc
+++ b/cpp/src/gandiva/tests/projector_test.cc
@@ -227,10 +227,11 @@ static void TestArithmeticOpsForType(arrow::MemoryPool* pool) {
EXPECT_TRUE(status.ok());
// Create a row-batch with some sample data
- int num_records = 4;
- std::vector<C_TYPE> input0 = {1, 2, 53, 84};
- std::vector<C_TYPE> input1 = {10, 15, 23, 84};
- std::vector<bool> validity = {true, true, true, true};
+ int num_records = 12;
+ std::vector<C_TYPE> input0 = {1, 2, 53, 84, 5, 15, 0, 1, 52, 83, 4, 120};
+ std::vector<C_TYPE> input1 = {10, 15, 23, 84, 4, 51, 68, 9, 16, 18, 19, 37};
+ std::vector<bool> validity = {true, true, true, true, true, true,
+ true, true, true, true, true, true};
auto array0 = MakeArrowArray<TYPE, C_TYPE>(input0, validity);
auto array1 = MakeArrowArray<TYPE, C_TYPE>(input1, validity);