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 10 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

Choose a reason for hiding this comment

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

Can you check iterators too ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually It's already done in the generic_consistency_test (and we have a lot of redundancy if other test cases). Or did you have additional tests in mind?

@JohanMabille JohanMabille force-pushed the map_array branch 3 times, most recently from ae6aac9 to 90b4617 Compare June 13, 2025 15:12
@JohanMabille JohanMabille force-pushed the map_array branch 3 times, most recently from 530819b to 58148bb Compare June 17, 2025 07:16
@JohanMabille JohanMabille force-pushed the map_array branch 6 times, most recently from 1712873 to e45061f Compare June 17, 2025 13:18
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.

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