AlenkaF commented on code in PR #41956:
URL: https://github.com/apache/arrow/pull/41956#discussion_r1633226265
##########
cpp/src/arrow/array/array_nested.cc:
##########
@@ -847,30 +847,32 @@ Result<std::shared_ptr<Array>>
MapArray::FromArraysInternal(
const auto& typed_offsets = checked_cast<const OffsetArrayType&>(*offsets);
BufferVector buffers;
- int64_t null_count;
- if (null_bitmap != nullptr) {
- buffers = BufferVector({std::move(null_bitmap), typed_offsets.values()});
- null_count = null_bitmap->size();
- } else {
- buffers = BufferVector({null_bitmap, typed_offsets.values()});
- null_count = 0;
+ buffers.resize(2);
+ int64_t null_count = 0;
+ if (null_bitmap) {
+ buffers[0] = std::move(null_bitmap);
+ null_count = kUnknownNullCount;
}
+ buffers[1] = typed_offsets.values();
return std::make_shared<MapArray>(type, offsets->length() - 1,
std::move(buffers), keys,
items, /*null_count=*/null_count,
offsets->offset());
}
-Result<std::shared_ptr<Array>> MapArray::FromArrays(
- const std::shared_ptr<Array>& offsets, const std::shared_ptr<Array>& keys,
- const std::shared_ptr<Array>& items, MemoryPool* pool,
- const std::shared_ptr<Buffer>& null_bitmap) {
+Result<std::shared_ptr<Array>> MapArray::FromArrays(const
std::shared_ptr<Array>& offsets,
+ const
std::shared_ptr<Array>& keys,
+ const
std::shared_ptr<Array>& items,
+ MemoryPool* pool,
+ std::shared_ptr<Buffer>
null_bitmap) {
return FromArraysInternal(std::make_shared<MapType>(keys->type(),
items->type()),
offsets, keys, items, pool, null_bitmap);
}
-Result<std::shared_ptr<Array>> MapArray::FromArrays(
- std::shared_ptr<DataType> type, const std::shared_ptr<Array>& offsets,
- const std::shared_ptr<Array>& keys, const std::shared_ptr<Array>& items,
- MemoryPool* pool, const std::shared_ptr<Buffer>& null_bitmap) {
+Result<std::shared_ptr<Array>> MapArray::FromArrays(std::shared_ptr<DataType>
type,
+ const
std::shared_ptr<Array>& offsets,
+ const
std::shared_ptr<Array>& keys,
+ const
std::shared_ptr<Array>& items,
+ MemoryPool* pool,
+ std::shared_ptr<Buffer>
null_bitmap) {
Review Comment:
I am not proficient in C++ but I would think it is enough to move it once?
That is done in `FromArraysInternal` method (line 853 of this PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]