Skip to content

Commit

Permalink
Update bzip2 requirement from 0.4.3 to 0.5.0 (#13740)
Browse files Browse the repository at this point in the history
* Update bzip2 requirement from 0.4.3 to 0.5.0

Updates the requirements on [bzip2](https://github.com/trifectatechfoundation/bzip2-rs) to permit the latest version.
- [Release notes](https://github.com/trifectatechfoundation/bzip2-rs/releases)
- [Commits](trifectatechfoundation/bzip2-rs@0.4.4...v0.5.0)

---
updated-dependencies:
- dependency-name: bzip2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix test

* Fix CLI cargo.lock

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jonahgao <jonahgao@msn.com>
  • Loading branch information
dependabot[bot] and jonahgao authored Dec 21, 2024
1 parent ade14e7 commit 60024c5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
16 changes: 13 additions & 3 deletions datafusion-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async-compression = { version = "0.4.0", features = [
], optional = true }
async-trait = { workspace = true }
bytes = { workspace = true }
bzip2 = { version = "0.4.3", optional = true }
bzip2 = { version = "0.5.0", optional = true }
chrono = { workspace = true }
dashmap = { workspace = true }
datafusion-catalog = { workspace = true }
Expand Down
33 changes: 28 additions & 5 deletions datafusion/core/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ pub fn scan_partitioned_csv(partitions: usize, work_dir: &Path) -> Result<Arc<Cs
))
}

/// Auto finish the wrapped BzEncoder on drop
#[cfg(feature = "compression")]
struct AutoFinishBzEncoder<W: Write>(BzEncoder<W>);

#[cfg(feature = "compression")]
impl<W: Write> Write for AutoFinishBzEncoder<W> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.0.write(buf)
}

fn flush(&mut self) -> std::io::Result<()> {
self.0.flush()
}
}

#[cfg(feature = "compression")]
impl<W: Write> Drop for AutoFinishBzEncoder<W> {
fn drop(&mut self) {
let _ = self.0.try_finish();
}
}

/// Returns file groups [`Vec<Vec<PartitionedFile>>`] for scanning `partitions` of `filename`
pub fn partitioned_file_groups(
path: &str,
Expand Down Expand Up @@ -147,9 +169,10 @@ pub fn partitioned_file_groups(
Box::new(encoder)
}
#[cfg(feature = "compression")]
FileCompressionType::BZIP2 => {
Box::new(BzEncoder::new(file, BzCompression::default()))
}
FileCompressionType::BZIP2 => Box::new(AutoFinishBzEncoder(BzEncoder::new(
file,
BzCompression::default(),
))),
#[cfg(not(feature = "compression"))]
FileCompressionType::GZIP
| FileCompressionType::BZIP2
Expand Down Expand Up @@ -183,8 +206,8 @@ pub fn partitioned_file_groups(
}
}

// Must drop the stream before creating ObjectMeta below as drop
// triggers finish for ZstdEncoder which writes additional data
// Must drop the stream before creating ObjectMeta below as drop triggers
// finish for ZstdEncoder/BzEncoder which writes additional data
for mut w in writers.into_iter() {
w.flush().unwrap();
}
Expand Down

0 comments on commit 60024c5

Please sign in to comment.