Skip to content

Commit

Permalink
rust: disable lz4 block checksum (#1294)
Browse files Browse the repository at this point in the history
### Changelog
<!-- Write a one-sentence summary of the user-impacting change (API,
UI/UX, performance, etc) that could appear in a changelog. Write "None"
if there is no user-facing change -->

rust: disable lz4 block checksum

### Docs

<!-- Link to a Docs PR, tracking ticket in Linear, OR write "None" if no
documentation changes are needed. -->

None

### Description

Disables the lz4 block checksum to mimic the behaviour of the Go code.

MCAP files from Rust created with a block checksum will currently fail
when run through the MCAP CLI due to
pierrec/lz4#223, so this will ensure greater
compatibility with older MCAP CLI versions.

<!-- Describe the problem, what has changed, and motivation behind those
changes. Pretend you are advocating for this change and the reader is
skeptical. -->

<!-- In addition to unit tests, describe any manual testing you did to
validate this change. -->

<table><tr><th>Before</th><th>After</th></tr><tr><td>

<!--before content goes here-->

</td><td>

<!--after content goes here-->

</td></tr></table>

<!-- If necessary, link relevant Linear or Github issues. Use `Fixes:
foxglove/repo#1234` to auto-close the Github issue or Fixes: FG-### for
Linear isses. -->
  • Loading branch information
bennetthardwick authored Dec 16, 2024
1 parent 4948ad4 commit 9e49a99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ categories = [ "science::robotics", "compression" ]
repository = "https://github.com/foxglove/mcap"
documentation = "https://docs.rs/mcap"
readme = "README.md"
version = "0.13.0"
version = "0.13.1"
edition = "2021"
license = "MIT"

Expand Down
9 changes: 8 additions & 1 deletion rust/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,14 @@ impl<W: Write + Seek> ChunkWriter<W> {
Compressor::Zstd(enc)
}
#[cfg(feature = "lz4")]
Some(Compression::Lz4) => Compressor::Lz4(lz4::EncoderBuilder::new().build(sink)?),
Some(Compression::Lz4) => Compressor::Lz4(
lz4::EncoderBuilder::new()
// Disable the block checksum for wider compatibility with MCAP tooling that
// includes a fault block checksum calculation. Since the MCAP spec includes a
// CRC for the compressed chunk this would be a superfluous check anyway.
.block_checksum(lz4::liblz4::BlockChecksum::NoBlockChecksum)
.build(sink)?,
),
#[cfg(not(any(feature = "zstd", feature = "lz4")))]
Some(_) => unreachable!("`Compression` is an empty enum that cannot be instantiated"),
None => Compressor::Null(sink),
Expand Down

0 comments on commit 9e49a99

Please sign in to comment.