You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by fs...@apache.org on 2020/06/07 11:53:42 UTC
[arrow] branch master updated: ARROW-9037: [C++] C-ABI: do not
error out when importing array with null_count == -1
This is an automated email from the ASF dual-hosted git repository.
fsaintjacques 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 7328658 ARROW-9037: [C++] C-ABI: do not error out when importing array with null_count == -1
7328658 is described below
commit 7328658fa897ab9fbefba66344dae89a77e9c12f
Author: Zhuo Peng <18...@users.noreply.github.com>
AuthorDate: Sun Jun 7 07:53:12 2020 -0400
ARROW-9037: [C++] C-ABI: do not error out when importing array with null_count == -1
Also when exporting an array, force compute the null count. This way future version will be able to import an array exported by 0.17, and vice versa.
Closes #7353 from brills/c_api_fix
Authored-by: Zhuo Peng <18...@users.noreply.github.com>
Signed-off-by: François Saint-Jacques <fs...@gmail.com>
---
cpp/src/arrow/c/bridge.cc | 4 +++-
cpp/src/arrow/c/bridge_test.cc | 12 ++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/cpp/src/arrow/c/bridge.cc b/cpp/src/arrow/c/bridge.cc
index c13b7a9..e6549d7 100644
--- a/cpp/src/arrow/c/bridge.cc
+++ b/cpp/src/arrow/c/bridge.cc
@@ -503,6 +503,8 @@ void ReleaseExportedArray(struct ArrowArray* array) {
struct ArrayExporter {
Status Export(const std::shared_ptr<ArrayData>& data) {
+ // Force computing null count.
+ data->GetNullCount();
// Store buffer pointers
export_.buffers_.resize(data->buffers.size());
std::transform(data->buffers.begin(), data->buffers.end(), export_.buffers_.begin(),
@@ -1401,7 +1403,7 @@ struct ArrayImporter {
Status ImportNullBitmap(int32_t buffer_id = 0) {
RETURN_NOT_OK(ImportBitsBuffer(buffer_id));
- if (data_->null_count != 0 && data_->buffers[buffer_id] == nullptr) {
+ if (data_->null_count > 0 && data_->buffers[buffer_id] == nullptr) {
return Status::Invalid(
"ArrowArray struct has null bitmap buffer but non-zero null_count ",
data_->null_count);
diff --git a/cpp/src/arrow/c/bridge_test.cc b/cpp/src/arrow/c/bridge_test.cc
index 53e4ac1..33d49cc 100644
--- a/cpp/src/arrow/c/bridge_test.cc
+++ b/cpp/src/arrow/c/bridge_test.cc
@@ -2574,6 +2574,18 @@ TEST_F(TestArrayRoundtrip, Primitive) {
TestWithJSONSliced(int32(), "[4, 5, 6, null]");
}
+TEST_F(TestArrayRoundtrip, UnknownNullCount) {
+ TestWithArrayFactory([](std::shared_ptr<Array>* arr) -> Status {
+ *arr = ArrayFromJSON(int32(), "[0, 1, 2]");
+ if ((*arr)->null_bitmap()) {
+ return Status::Invalid("Failed precondition: "
+ "the array shouldn't have a null bitmap.");
+ }
+ (*arr)->data()->SetNullCount(kUnknownNullCount);
+ return Status::OK();
+ });
+}
+
TEST_F(TestArrayRoundtrip, Nested) {
TestWithJSON(list(int32()), "[]");
TestWithJSON(list(int32()), "[[4, 5], [6, null], null]");