Skip to content

Commit

Permalink
Add null_count parameter to FixedSizeListArray::FromArrays C++ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasG0 committed Jan 3, 2024
1 parent 889439b commit 31157b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 9 additions & 12 deletions cpp/src/arrow/array/array_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,7 @@ FixedSizeListArray::FixedSizeListArray(const std::shared_ptr<DataType>& type,
int64_t length,
const std::shared_ptr<Array>& values,
const std::shared_ptr<Buffer>& 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);
Expand Down Expand Up @@ -895,10 +894,8 @@ const std::shared_ptr<DataType>& FixedSizeListArray::value_type() const {
const std::shared_ptr<Array>& FixedSizeListArray::values() const { return values_; }

Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
const std::shared_ptr<Array>& values,
int32_t list_size,
std::shared_ptr<Buffer> null_bitmap,
int64_t null_count) {
const std::shared_ptr<Array>& values, int32_t list_size,
std::shared_ptr<Buffer> null_bitmap, int64_t null_count) {
if (list_size <= 0) {
return Status::Invalid("list_size needs to be a strict positive integer");
}
Expand All @@ -910,14 +907,13 @@ Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
int64_t length = values->length() / list_size;
auto list_type = std::make_shared<FixedSizeListType>(values->type(), list_size);

return std::make_shared<FixedSizeListArray>(list_type, length, values, null_bitmap, null_count);
return std::make_shared<FixedSizeListArray>(list_type, length, values, null_bitmap,
null_count);
}

Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
const std::shared_ptr<Array>& values,
std::shared_ptr<DataType> type,
std::shared_ptr<Buffer> null_bitmap,
int64_t null_count) {
const std::shared_ptr<Array>& values, std::shared_ptr<DataType> type,
std::shared_ptr<Buffer> null_bitmap, int64_t null_count) {
if (type->id() != Type::FIXED_SIZE_LIST) {
return Status::TypeError("Expected fixed size list type, got ", type->ToString());
}
Expand All @@ -932,7 +928,8 @@ Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
}
int64_t length = values->length() / list_type.list_size();

return std::make_shared<FixedSizeListArray>(type, length, values, null_bitmap, null_count);
return std::make_shared<FixedSizeListArray>(type, length, values, null_bitmap,
null_count);
}

Result<std::shared_ptr<Array>> FixedSizeListArray::Flatten(
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/arrow/array/array_nested.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::shared_ptr<Array>> FromArrays(
const std::shared_ptr<Array>& values,
int32_t list_size,
const std::shared_ptr<Array>& values, int32_t list_size,
std::shared_ptr<Buffer> null_bitmap = NULLPTR,
int64_t null_count = kUnknownNullCount);

Expand All @@ -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<std::shared_ptr<Array>> FromArrays(
const std::shared_ptr<Array>& values,
std::shared_ptr<DataType> type,
const std::shared_ptr<Array>& values, std::shared_ptr<DataType> type,
std::shared_ptr<Buffer> null_bitmap = NULLPTR,
int64_t null_count = kUnknownNullCount);

Expand Down

0 comments on commit 31157b5

Please sign in to comment.