Skip to content
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

Switch to std::map for TopicTypeMap #546

Merged
merged 6 commits into from
Mar 20, 2025
Merged

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Mar 14, 2025

I open this PR just for visibility, it's related with this PR #536 and in particular with this comment #536 (comment)

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
@ahcorde ahcorde self-assigned this Mar 14, 2025
@ahcorde ahcorde marked this pull request as draft March 14, 2025 12:39
@ahcorde ahcorde requested a review from Yadunund March 17, 2025 16:54
Copy link
Member

@Yadunund Yadunund left a comment

Choose a reason for hiding this comment

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

@clalancette I'm sure had a good reason to introduce tsl::ordered_map in #536. Do you recall which tests were failing without it? Could it have been that the requirements were to return topic names in alphabetical order and not insertion order and that the failing test actually added topics in alphabetical order?

@ahcorde ahcorde marked this pull request as ready for review March 18, 2025 11:02
Copy link
Member

@Yadunund Yadunund left a comment

Choose a reason for hiding this comment

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

We should also delete

https://github.com/ros2/rmw_zenoh/blob/rolling/rmw_zenoh_cpp/src/detail/ordered_map.hpp and https://github.com/ros2/rmw_zenoh/blob/rolling/rmw_zenoh_cpp/src/detail/ordered_hash.hpp

And update CI to not reference those file

run: /ros_entrypoint.sh ament_uncrustify rmw_zenoh_cpp/ --exclude rmw_zenoh_cpp/src/detail/ordered_hash.hpp rmw_zenoh_cpp/src/detail/ordered_map.hpp
- name: cpplint
run: /ros_entrypoint.sh ament_cpplint rmw_zenoh_cpp/ --exclude rmw_zenoh_cpp/src/detail/ordered_hash.hpp rmw_zenoh_cpp/src/detail/ordered_map.hpp

@@ -85,7 +85,7 @@ struct GraphNode
// Map topic name to TopicTypeMap
// This uses a map that remembers insertion order because some parts of the client libraries
// expect that these are returned in the order that they were created.
using TopicMap = tsl::ordered_map<std::string, TopicTypeMap>;
using TopicMap = std::map<std::string, TopicTypeMap>;
Copy link
Member

Choose a reason for hiding this comment

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

Update documentation above.

@Yadunund Yadunund changed the title use std::map in topicMap type Switch to std::map for TopicTypeMap Mar 18, 2025
@ahcorde ahcorde requested a review from Yadunund March 19, 2025 21:48
@clalancette
Copy link
Collaborator

@clalancette I'm sure had a good reason to introduce tsl::ordered_map in #536. Do you recall which tests were failing without it? Could it have been that the requirements were to return topic names in alphabetical order and not insertion order and that the failing test actually added topics in alphabetical order?

Oof, this is a tough one. I made a big mistake in PR #250 in that I did not specify which tests were failing. And there definitely were failing tests at that point that adding the ordered map fixed.

So I went ahead and rebuilt a workspace with this PR in it, and ran all tests. With this in place, every test passed. So whatever it was that was failing before, was fixed in a different way. Thus, I think we can go forward with this change (with one change, which I'll put in a review).

Copy link
Collaborator

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

We should also remove the MIT license from the package.xml, as it is no longer needed.

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
@ahcorde ahcorde requested a review from clalancette March 20, 2025 14:38
@@ -94,8 +94,6 @@ if(BUILD_TESTING)
find_package(ament_cmake_uncrustify REQUIRED)
find_package(ament_cmake_xmllint REQUIRED)

set(_linter_excludes src/detail/ordered_hash.hpp src/detail/ordered_map.hpp)

ament_copyright(EXCLUDE src/detail/simplified_xxhash3.cpp src/detail/simplified_xxhash3.hpp)
ament_cpplint(EXCLUDE ${_linter_excludes})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I just noticed this one. Since we are no longer setting _linter_excludes, this should be:

Suggested change
ament_cpplint(EXCLUDE ${_linter_excludes})
ament_cpplint()

(same for ament_uncrustify down below, which I can't put a comment in due to GitHub limitations)

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
@ahcorde ahcorde requested a review from clalancette March 20, 2025 14:50
Copy link
Collaborator

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks @ahcorde

// This uses a map that remembers insertion order because some parts of the client libraries
// expect that these are returned in the order that they were created.
using TopicMap = tsl::ordered_map<std::string, TopicTypeMap>;
// This uses a map that sort element by name because some parts of the client libraries
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
// This uses a map that sort element by name because some parts of the client libraries
// This uses a map that sorts keys alphabetically because some parts of the client libraries

@ahcorde
Copy link
Contributor Author

ahcorde commented Mar 20, 2025

Thank you for the review @clalancette 👍

@ahcorde ahcorde merged commit db25318 into rolling Mar 20, 2025
5 checks passed
@ahcorde ahcorde deleted the ahcorde/rolling/topic_map branch March 20, 2025 16:11
@ahcorde
Copy link
Contributor Author

ahcorde commented Mar 20, 2025

https://github.com/Mergifyio backport jazzy humble

Copy link

mergify bot commented Mar 20, 2025

backport jazzy humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Mar 20, 2025
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: Yuyuan Yuan <[email protected]>
(cherry picked from commit db25318)
mergify bot pushed a commit that referenced this pull request Mar 20, 2025
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: Yuyuan Yuan <[email protected]>
(cherry picked from commit db25318)

# Conflicts:
#	rmw_zenoh_cpp/CMakeLists.txt
ahcorde added a commit that referenced this pull request Mar 20, 2025
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: Yuyuan Yuan <[email protected]>
(cherry picked from commit db25318)

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
ahcorde added a commit that referenced this pull request Mar 20, 2025
* Switch to std::map for TopicTypeMap (#546)

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: Yuyuan Yuan <[email protected]>
(cherry picked from commit db25318)
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
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.

4 participants