Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

JohanMabille
Copy link
Collaborator

No description provided.


ArrowArray arr = make_arrow_array(
static_cast<std::int64_t>(size), // length
static_cast<int64_t>(null_count),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static_cast<int64_t>(null_count),
static_cast<std::int64_t>(null_count),

std::string("+m"), // format
name, // name
metadata, // metadata
std::nullopt, // flags,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 51 to 57
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;


bool map_array::check_keys_sorted() const
{
// TODO: implement this
Copy link
Collaborator

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 ?

{
return val == k;
}
else
Copy link
Collaborator

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");
Copy link
Collaborator

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 ?

Copy link
Collaborator

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()

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@JohanMabille JohanMabille force-pushed the map_array branch 10 times, most recently from 209f39b to d0c0fb7 Compare June 16, 2025 14:03
@JohanMabille JohanMabille force-pushed the map_array branch 12 times, most recently from ffa29f5 to ac21167 Compare June 18, 2025 12:50
@Alex-PLACET Alex-PLACET requested review from Copilot June 18, 2025 15:47
Copy link
Contributor

@Copilot Copilot AI left a 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.

Copy link
Contributor

@Copilot Copilot AI left a 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.

Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 50 lines in your changes missing coverage. Please review.

Project coverage is 87.62%. Comparing base (dc18702) to head (dd59f1b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/layout/map_layout/map_value.cpp 57.35% 29 Missing ⚠️
src/layout/map_layout/map_array.cpp 80.45% 17 Missing ⚠️
include/sparrow/layout/map_layout/map_array.hpp 94.73% 2 Missing ⚠️
include/sparrow/types/data_type.hpp 0.00% 2 Missing ⚠️
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     
Flag Coverage Δ
unittests 87.62% <75.00%> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

isorted = true;
for (std::size_t j = index_begin; j + 1 < index_end; ++j)
{
isorted = isorted && (ar[j] < ar[j + 1]);
Copy link
Collaborator

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

{
std::size_t index_begin = offsets[i];
std::size_t index_end = offsets[i + 1];
sorted = sorted
Copy link
Collaborator

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

Copy link
Collaborator

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 ?

@JohanMabille JohanMabille requested a review from Alex-PLACET June 20, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants