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

Reverse read order API and sqlite storage implementation #1083

Merged
merged 7 commits into from
Oct 6, 2022

Conversation

emersonknapp
Copy link
Collaborator

@emersonknapp emersonknapp commented Sep 8, 2022

Add a new BaseReadInterface::set_read_order API, and implement it for the SqliteStorage.

Adds 2 new capabilities: reverse-timestamp reading, and file-order reading. Does not implement reverse-file-order reading.

@emersonknapp emersonknapp marked this pull request as ready for review September 8, 2022 21:43
@emersonknapp emersonknapp requested a review from a team as a code owner September 8, 2022 21:43
@emersonknapp emersonknapp requested review from hidmic and jhdcs and removed request for a team September 8, 2022 21:43
@emersonknapp emersonknapp marked this pull request as draft September 8, 2022 22:52
@emersonknapp
Copy link
Collaborator Author

API sweep to expose to Python revealed a larger surface area than I suspected - need to fix up the SequentialReader to be able to iterate backward between storage files, if necessary. Moving back to draft

@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Sep 24, 2022

Ready to go but now depends on #1098 for the reverse timestamp split-bag test to work correctly

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@emersonknapp Thanks for implementation and sorry for delay in review from my side.
It turns out a lot of changes in many files and I was need to check logic very carefully.

Please see my comments and suggestions inline.

@emersonknapp
Copy link
Collaborator Author

Pulling the one last conversation out to main thread for visibility:

I am thinking now that maybe it doesn't make sense to set the row id at all on set_read_order - maybe the user needs to explicitly seek to the end of the file? The cases are a little bit ambiguous how it should behave.
Maybe,

  • If set_read_order(reverse=true) set before open, then on open automatically seek to end of file
  • If storage is already open, then set_read_order doesn't change the place, even if no messages have been written yet
    Does that behavior make sense?

@emersonknapp emersonknapp requested review from MichaelOrlov and removed request for james-rms October 3, 2022 22:10
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Oct 3, 2022

Gist: https://gist.githubusercontent.com/emersonknapp/c5fded23fae98a4aafcf2a94672512a4/raw/ad0dd75e0b643a5c5f1a91b71dd5457352fc9d46/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
TEST args: --packages-above rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/10937

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@emersonknapp
I found out that when we will have read order by file without reverse which is currently supported the seek(timestamp) will not really work and will reset our seek_row_id which is unexpected.

I don't see a descent solution for this case. Therefore I would suggest to disable rosbag2_storage::ReadOrder::File completely for sqlite_storage implementation and create a follow up task to properly support it. It looks like that we will need to make some overhaul in sqlite_storage.cpp and in logic related to how we preparing database for readout in different cases.

I have also concern that we are not really doing db readout on seek and set_read_order - it will complicate things if we will add more logic in those methods and someone would do set_read_order then right after that seek before reading out new message. However it will be Ok to have it as is currently is if will have only one sort by timestamp order.

@emersonknapp
Copy link
Collaborator Author

OK - I have disabled File order reading entirely

@emersonknapp
Copy link
Collaborator Author

Gist: https://gist.githubusercontent.com/emersonknapp/f4e47a0ee418ead1fcaeaa13f9330cbf/raw/ad0dd75e0b643a5c5f1a91b71dd5457352fc9d46/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
TEST args: --packages-above rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/10946

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
…reader tests

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

Tentatively approve.
I found out one printf in tests I think this is residual from debug/development. It would be nice to remove it. It's trivial and minor I think we can omit rerunning CI if it will be removed.

I am more worry about appeared warnings on Windows build about YAML_CPP_DLL redefinition. There are wasn't such warnings from previous CI run.
@emersonknapp Do you have any idea what caused those warnings on Windows build?

reader.close();

for (bool do_reset : {false, true}) {
printf("Testing with do_reset %d\n", do_reset);
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgotten debug printf from yesterday?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, removing. Also yes, the windows warnings were from being slightly out of date - I will rebase and rerun.

@MichaelOrlov
Copy link
Contributor

MichaelOrlov commented Oct 5, 2022

@emersonknapp Ok It seems I know root cause of the warnings on Windows build.
It looks like they are appeared due to recent merge on rolling ros2/yaml_cpp_vendor#38 .
The fix for warning in rosbag2 was also recently merged in #964.

Could you please try to rebase your branch on top of latest rolling and re-run CI for Windows job?

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

Gist: https://gist.githubusercontent.com/emersonknapp/4790ab890f1abc4f1c7d22fcb809ef0d/raw/ad0dd75e0b643a5c5f1a91b71dd5457352fc9d46/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
TEST args: --packages-above rosbag2_compression rosbag2_cpp rosbag2_py rosbag2_storage rosbag2_storage_default_plugins rosbag2_transport
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/10951

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@emersonknapp emersonknapp merged commit 16cb47f into rolling Oct 6, 2022
@delete-merged-branch delete-merged-branch bot deleted the emersonknapp/reverse-iteration branch October 6, 2022 00:45
@MichaelOrlov
Copy link
Contributor

@emersonknapp Thanks for your hard work on this PR and sorry for long review process.
It turns out that logic for file ordering became complicated and opened up a "can of warms".
Please don't be angry on me if I was to pedantic on code review.

@emersonknapp
Copy link
Collaborator Author

No worries, sorry if I was brusque yesterday, I was feeling grumpy because I hadn't had any coffee. Thanks for holding a high standard for the code

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.

None yet

3 participants