-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add topic_id returned by storage to the TopicMetadata #1538
Conversation
6b28ca2
to
d515a62
Compare
d515a62
to
9cde976
Compare
Moving it to the draft again. Motivation: |
Ready for review |
@MichaelOrlov thanks for the PR. this one looks big change, i will try review in this week. you can go ahead to assign this to me. |
@fujitatomoya Thanks for helping with review. |
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.
overall lgtm, a few comments.
rosbag2_storage_sqlite3/include/rosbag2_storage_sqlite3/sqlite_storage.hpp
Outdated
Show resolved
Hide resolved
rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp
Outdated
Show resolved
Hide resolved
- Rationale. To be able to distinguish topics by unique topic ID rather than by topic name in the future. Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
3d65cee
to
e5d8c3a
Compare
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
e5d8c3a
to
814b513
Compare
@emersonknapp @clalancette Could some of you please give formal approval for this PR to be able to merge it? |
Gist: https://gist.githubusercontent.com/MichaelOrlov/9d2827dcef7e219879574e49386f1596/raw/16f993bb8bcfd59af7ac24dbeaa4bec51ead6950/ros2.repos |
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.
lgtm
Re-run CI with the correctly listed |
There's not much information in the migration notes, and all the examples seem to just use the value 0. So if I'm writing a bag file from scratch (using Python say), should each |
The topic_info = rosbag2_py._storage.TopicMetadata(
id=0,
name='synthetic',
type='example_interfaces/msg/Int32',
serialization_format='cdr')
self.writer.create_topic(topic_info) it is assigned to 0 because it will be overwritten by the storage plugin after a call to the Therefore - no special steps for migration are required. |
I guess what I'm trying to figure out is why zero is not the default value, if it is just going to be overwritten. Then the TopicMetadata constructor could have stayed the same. |
Well, it is zero-initialized by default. The |
In the Python bindings introduced by @r7vme in #1569, there is an explicit constructor, and |
Motivation is the same as in Use topic_id instead of topic_name in inner rosbag2 buffers and data structures #1553
About the size of the type for the newly added
topic_id
field.In MCAP specification we reserved 16 bit for the topic_id. This is the
ChannelId
, the MCAP inner type that corresponds to theuint16_t
. When we were creating the MCAP format we decided that the ability to differentiate a maximum65535
topics would be enough in the vast majority of cases. However, in theSQLite3
storage plugin, we are usingtopic_id
as an index to map records from themessages
DB table to the correspondingtopics
table. According to the SQLite3 specification, the index is theint64_t
data type and can't be changed.Therefore the type of the newly addedtopic_id
filed shall be no less thanint64_t
and shall be with the sign.Update:
Decided to keep
uint16_t
fortopic_id
in theTopicMetada
and have a hash map toint64_t
indexes inside the sql storage plugin. The performance will not be affected during recording because currently we already have an internal hash map lookup to find match fortopic_name
to thetopic_id
index. It will be similar hash map lookup, however we will be using externaltopic_id
instead oftopic_name
.