Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-41955: [C++] Follow up of adding null_bitmap to MapArray::FromArrays#41956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felipecrv
merged 11 commits into
apache:main
from
AlenkaF:gh-41955-post-map-array-correctionsJun 13, 2024
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5f18e7b
Update FromArraysInternal
AlenkaF 00d3634
Fix null_count
AlenkaF 55f127c
Restore null_count to -1, update tests and make them more readable
AlenkaF 2f20506
Make python tests a bit more specific regarding the null_count
AlenkaF 1067c03
Change -1 to kUnknownNullCount
AlenkaF 6fc5aa3
Change null_count with MayHaveNulls
AlenkaF 1ee19a0
Remove const from null_bitmap
AlenkaF 1a175eb
Fix C++ linter error
AlenkaF eacdc35
Update cpp/src/arrow/array/array_nested.cc
AlenkaF e0b9c36
Add std::move
AlenkaF 9621d54
Fix linter error
AlenkaF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -807,7 +807,7 @@ MapArray::MapArray(const std::shared_ptr<DataType>& type, int64_t length, | ||
| Result<std::shared_ptr<Array>> MapArray::FromArraysInternal( | ||
| 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) { | ||
| MemoryPool* pool, std::shared_ptr<Buffer> null_bitmap) { | ||
| using offset_type = typename MapType::offset_type; | ||
| using OffsetArrowType = typename CTypeTraits<offset_type>::ArrowType; | ||
| @@ -836,7 +836,7 @@ Result<std::shared_ptr<Array>> MapArray::FromArraysInternal( | ||
| return Status::NotImplemented("Null bitmap with offsets slice not supported."); | ||
| } | ||
| if (offsets->null_count() > 0) { | ||
| if (offsets->data()->MayHaveNulls()) { | ||
| ARROW_ASSIGN_OR_RAISE(auto buffers, | ||
| CleanListOffsets<MapType>(NULLPTR, *offsets, pool)); | ||
| return std::make_shared<MapArray>(type, offsets->length() - 1, std::move(buffers), | ||
| @@ -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); | ||
AlenkaF marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| 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); | ||
| offsets, keys, items, pool, std::move(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) { | ||
AlenkaF marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| if (type->id() != Type::MAP) { | ||
| return Status::TypeError("Expected map type, got ", type->ToString()); | ||
| } | ||
| @@ -881,7 +883,8 @@ Result<std::shared_ptr<Array>> MapArray::FromArrays( | ||
| if (!map_type.item_type()->Equals(items->type())) { | ||
| return Status::TypeError("Mismatching map items type"); | ||
| } | ||
| return FromArraysInternal(std::move(type), offsets, keys, items, pool, null_bitmap); | ||
| return FromArraysInternal(std::move(type), offsets, keys, items, pool, | ||
| std::move(null_bitmap)); | ||
| } | ||
| Status MapArray::ValidateChildData( | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.