From 31157b5d4c8fb108c85b5e645c4c482426b557e7 Mon Sep 17 00:00:00 2001 From: LucasG0 Date: Wed, 3 Jan 2024 19:31:44 +0100 Subject: [PATCH] Add null_count parameter to FixedSizeListArray::FromArrays C++ methods --- cpp/src/arrow/array/array_nested.cc | 21 +++++++++------------ cpp/src/arrow/array/array_nested.h | 6 ++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/cpp/src/arrow/array/array_nested.cc b/cpp/src/arrow/array/array_nested.cc index fa22704b51def..0b0e340a67d4e 100644 --- a/cpp/src/arrow/array/array_nested.cc +++ b/cpp/src/arrow/array/array_nested.cc @@ -865,8 +865,7 @@ FixedSizeListArray::FixedSizeListArray(const std::shared_ptr& type, int64_t length, const std::shared_ptr& values, const std::shared_ptr& null_bitmap, - int64_t null_count, - int64_t offset) { + int64_t null_count, int64_t offset) { auto internal_data = ArrayData::Make(type, length, {null_bitmap}, null_count, offset); internal_data->child_data.emplace_back(values->data()); SetData(internal_data); @@ -895,10 +894,8 @@ const std::shared_ptr& FixedSizeListArray::value_type() const { const std::shared_ptr& FixedSizeListArray::values() const { return values_; } Result> FixedSizeListArray::FromArrays( - const std::shared_ptr& values, - int32_t list_size, - std::shared_ptr null_bitmap, - int64_t null_count) { + const std::shared_ptr& values, int32_t list_size, + std::shared_ptr null_bitmap, int64_t null_count) { if (list_size <= 0) { return Status::Invalid("list_size needs to be a strict positive integer"); } @@ -910,14 +907,13 @@ Result> FixedSizeListArray::FromArrays( int64_t length = values->length() / list_size; auto list_type = std::make_shared(values->type(), list_size); - return std::make_shared(list_type, length, values, null_bitmap, null_count); + return std::make_shared(list_type, length, values, null_bitmap, + null_count); } Result> FixedSizeListArray::FromArrays( - const std::shared_ptr& values, - std::shared_ptr type, - std::shared_ptr null_bitmap, - int64_t null_count) { + const std::shared_ptr& values, std::shared_ptr type, + std::shared_ptr null_bitmap, int64_t null_count) { if (type->id() != Type::FIXED_SIZE_LIST) { return Status::TypeError("Expected fixed size list type, got ", type->ToString()); } @@ -932,7 +928,8 @@ Result> FixedSizeListArray::FromArrays( } int64_t length = values->length() / list_type.list_size(); - return std::make_shared(type, length, values, null_bitmap, null_count); + return std::make_shared(type, length, values, null_bitmap, + null_count); } Result> FixedSizeListArray::Flatten( diff --git a/cpp/src/arrow/array/array_nested.h b/cpp/src/arrow/array/array_nested.h index 3f0d5fe7a8e13..6d3fdfde6482e 100644 --- a/cpp/src/arrow/array/array_nested.h +++ b/cpp/src/arrow/array/array_nested.h @@ -602,8 +602,7 @@ class ARROW_EXPORT FixedSizeListArray : public Array { /// \param[in] null_bitmap Optional validity bitmap /// \return Will have length equal to values.length() / list_size static Result> FromArrays( - const std::shared_ptr& values, - int32_t list_size, + const std::shared_ptr& values, int32_t list_size, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount); @@ -614,8 +613,7 @@ class ARROW_EXPORT FixedSizeListArray : public Array { /// \param[in] null_bitmap Optional validity bitmap /// \return Will have length equal to values.length() / type.list_size() static Result> FromArrays( - const std::shared_ptr& values, - std::shared_ptr type, + const std::shared_ptr& values, std::shared_ptr type, std::shared_ptr null_bitmap = NULLPTR, int64_t null_count = kUnknownNullCount);