-
Notifications
You must be signed in to change notification settings - Fork 263
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
[compression] Add a SequentialCompressionReader #258
Conversation
cb7ed83
to
fdf09f2
Compare
rosbag2_compression/include/rosbag2_compression/sequential_compression_reader.hpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
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.
This looks file overall, but I'm concerned about the amount of copied code - what do you think?
* | ||
* \return true if there are still files to read in the list | ||
*/ | ||
virtual bool has_next_file() const; |
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.
I know this is only the second time we're writing this pattern, but the sequential file URI logic is a decent amount of copy-pasted code. It may be worth a refactor to delegate functionality to a common sequential file handler.
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.
I agree that it's a lot of similar code.
The problem with the sequential reader is that some of the functionality is private and not exposed in its public API. Moreover that's for another PR.
If we find ourselves doing this again though, then yes a refactor is in order.
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.
Rule of 3 is my point exactly. And I would not suggest trying to use the other thing's private API. I would suggest pulling all the sequential file handling logic out into a totally separate thing that both use
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.
Splitting SequentialReader
may be a step in resolving Issue #213 since SequentialCompressionReader
requires a metadata file.
I think there will be refactoring in the future where SequentialReader
may split again into a specialized form for ROS1 bagfile support. If that happens, I think it would be more beneficial to refactor then.
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.
Why can't this class inherit from the SequentialReader
?
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
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.
mainly LGTM, take a look at my comment on the decompressor.
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/include/rosbag2_compression/sequential_compression_reader.hpp
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
|
||
void SequentialCompressionReader::set_current_file(const std::string & file) | ||
{ | ||
*current_file_iterator_ = file; |
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.
I think it's much better to keep an index into file_paths_
than to keep an iterator. An iterator is just as bad as a raw pointer, subject to invalidation. While it's easy to compare the iterator to file_paths_.end()
, it's hard to check if an iterator is indeed somewhere between file_paths_.begin()
and file_paths_.end()
.
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
c3b07da
to
58c7629
Compare
@ros2/aws-oncall please rerun CI |
All CI is green. |
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.
It's mainly new code, so it looks okay to me.
I wonder though why you couldn't inherit from the SequentialReader
class to reduce code duplication.
* | ||
* \return true if there are still files to read in the list | ||
*/ | ||
virtual bool has_next_file() const; |
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.
Why can't this class inherit from the SequentialReader
?
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_reader.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/test/rosbag2_compression/test_sequential_compression_reader.cpp
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
There's some private methods that need to be updated and/or refactored to support compression. |
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
5b8feeb
to
82f0ba1
Compare
Implements a
SequentialCompressionReader
that useszstd
to both decompress files and read them sequentially.Depends on #257.