-
Notifications
You must be signed in to change notification settings - Fork 20
Implemented map layout #450
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
base: main
Are you sure you want to change the base?
Conversation
|
||
ArrowArray arr = make_arrow_array( | ||
static_cast<std::int64_t>(size), // length | ||
static_cast<int64_t>(null_count), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static_cast<int64_t>(null_count), | |
static_cast<std::int64_t>(null_count), |
std::string("+m"), // format | ||
name, // name | ||
metadata, // metadata | ||
std::nullopt, // flags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should handle https://arrow.apache.org/docs/dev/format/CDataInterface.html#c.ArrowSchema.flags
ARROW_FLAG_MAP_KEYS_SORTED
bool empty() const noexcept; | ||
size_type size() const noexcept; | ||
|
||
const_mapped_reference operator[](const key_type& key) const; | ||
|
||
const_iterator find(const key_type& key) const noexcept; | ||
|
||
const_iterator begin() const; | ||
const_iterator cbegin() const; | ||
|
||
const_iterator end() const; | ||
const_iterator cend() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool empty() const noexcept; | |
size_type size() const noexcept; | |
const_mapped_reference operator[](const key_type& key) const; | |
const_iterator find(const key_type& key) const noexcept; | |
const_iterator begin() const; | |
const_iterator cbegin() const; | |
const_iterator end() const; | |
const_iterator cend() const; | |
[[nodiscard]] bool empty() const noexcept; | |
[[nodiscard]] size_type size() const noexcept; | |
[[nodiscard]] const_mapped_reference operator[](const key_type& key) const; | |
[[nodiscard]]const_iterator find(const key_type& key) const noexcept; | |
[[nodiscard]] const_iterator begin() const; | |
[[nodiscard]] const_iterator cbegin() const; | |
[[nodiscard]] const_iterator end() const; | |
[[nodiscard]] const_iterator cend() const; |
src/layout/map_layout/map_array.cpp
Outdated
|
||
bool map_array::check_keys_sorted() const | ||
{ | ||
// TODO: implement this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do in this PR ?
src/layout/map_layout/map_value.cpp
Outdated
{ | ||
return val == k; | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we really enter in this case ?
size_type index = find_index(key); | ||
if (index == m_index_end) | ||
{ | ||
throw std::out_of_range("key not found in map"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have the same behavior as std::map and so create the entry instead of raising an exception ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation could be used in at()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means making the map_array mutable, which implies resizing the underlying children arrays. If we decide to do so, it should probably be done in a dedicated PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have a const at() I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would suggest a vector or array API instead of a map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, there is an const T& at()in the std: https://en.cppreference.com/w/cpp/container/map/at.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my bad, I missed this one.
209f39b
to
d0c0fb7
Compare
ffa29f5
to
ac21167
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the map layout functionality including new array and value types for maps, along with tests and necessary integrations in the build system and dispatch mechanism.
- Introduces map_array and map_value classes with associated unit tests.
- Updates CMake and dispatch to integrate map layout functionality.
- Adds definitions and traits for map types in header files.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
test/test_map_array.cpp | Adds unit tests for map_array functionality (contains debug prints). |
test/test_list_value.cpp | Updates include directives to add map_value. |
test/CMakeLists.txt | Adjusts test targets by commenting out some tests and adding map_array reference. |
src/layout/map_layout/map_value.cpp | New implementation of map_value (spelling typo in license header). |
src/layout/map_layout/map_array.cpp | New implementation of map_array (spelling typo and a bug in raw_keys_array non-const method). |
include/sparrow/types/data_type.hpp | Adds MAP data type support. |
include/sparrow/types/data_traits.hpp | Specializes arrow_traits for map_value. |
include/sparrow/layout/map_layout/map_value.hpp | New header for map_value definition. |
include/sparrow/layout/map_layout/map_array.hpp | New header for map_array with a spelling issue in an alias and proper API prototypes. |
include/sparrow/layout/dispatch.hpp | Updates dispatch to handle MAP type. |
CMakeLists.txt | Includes new map layout sources in the build. |
.github/workflows/windows.yml | Updates test execution commands for Windows builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #450 +/- ##
==========================================
- Coverage 88.30% 87.62% -0.69%
==========================================
Files 96 100 +4
Lines 7301 7545 +244
==========================================
+ Hits 6447 6611 +164
- Misses 854 934 +80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/layout/map_layout/map_array.cpp
Outdated
isorted = true; | ||
for (std::size_t j = index_begin; j + 1 < index_end; ++j) | ||
{ | ||
isorted = isorted && (ar[j] < ar[j + 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an early exit if isorted == false
src/layout/map_layout/map_array.cpp
Outdated
{ | ||
std::size_t index_begin = offsets[i]; | ||
std::size_t index_end = offsets[i + 1]; | ||
sorted = sorted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an early exit if sorted == false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test with std::format ?
for more information, see https://pre-commit.ci
No description provided.