-
Notifications
You must be signed in to change notification settings - Fork 240
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 - 6] Add Zstd file decompression implementation #230
[Compression - 6] Add Zstd file decompression implementation #230
Conversation
95f6c4e
to
04698fb
Compare
rosbag2_compression/test/rosbag2_compression/test_zstd_compressor.cpp
Outdated
Show resolved
Hide resolved
61ec2f2
to
db10182
Compare
@ros2/aws-oncall - please run this CI job |
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
db10182
to
e989b8b
Compare
@Karsten1987 this PR is ready for review |
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
…fy it fails with bad input. Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
rosbag2_compression/test/rosbag2_compression/test_zstd_compressor.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
* Add comments on why uniform initialization cannot be used Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/test/rosbag2_compression/test_zstd_compressor.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
a5eee19
to
250bab3
Compare
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/zstd_decompressor.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
4f46b75
to
050d8a4
Compare
@Karsten1987 friendly ping requesting 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.
With compression and decompression being available with this, I would like to see a test which checks the validity of the compression. That is, a file being compressed and decompressed is byte equivalent with the initial file content.
// Read in buffer, handling accordingly | ||
const auto file_pointer = open_file(uri.c_str(), "rb"); | ||
if (file_pointer == nullptr) { | ||
std::stringstream errmsg; | ||
errmsg << "Failed to open file: \"" << uri << "\" for binary reading!"; | ||
|
||
throw std::runtime_error{errmsg.str()}; | ||
} |
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.
Could this check be done before getting the size of the uri
?
std::vector<uint8_t> get_input_buffer(const std::string & uri) | ||
{ | ||
// Get the file size | ||
const auto compressed_buffer_length = rosbag2_storage::FilesystemHelper::get_file_size(uri); |
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 we should react here in case the returned filesize is 0 (aka the file is non-existing)
// the initializer list constructor instead. | ||
std::vector<uint8_t> compressed_buffer(compressed_buffer_length); | ||
|
||
const auto nRead = fread( |
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.
nit: generally we don't have camelcase variable names in ROS2.
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM("Bytes read !(" << | ||
nRead << ") != compressed_buffer_length (" << compressed_buffer_length << | ||
")!"); | ||
// An error indicator is set by fread, so the following check will throw. |
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 comment actually refers to line 90, right?
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.
Yeah, the error log message on L84 exists to provide further information on an error from fread
.
The comment on L87 is indicating that the code should throw at this state and that the check on L90 does the actual throw since fread
may have set the error indicator for other reasons besides nRead != compressed_buffer_length
.
} | ||
|
||
const auto nWrite = fwrite( | ||
output_buffer.data(), sizeof(uint8_t), |
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.
what if output buffer is empty?
/** | ||
* Checks if the frame content is valid. | ||
*/ | ||
void check_frame_content(const size_t frame_content) |
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.
given that we have throw_on_zstd_error
I think this function could be renamed accordingly as it really does only throwing on error.
There's a unit test for this:
|
@Karsten1987 I'm opening a PR to address your comments: #245 |
Changes
zstd_decompressor
header and sourceDependencies