Skip to content

Commit

Permalink
flush does not consume self anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
vigna committed Jan 14, 2024
1 parent b08ed66 commit 04bb193
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bitvec = { version = "1.0.1", features = ["atomic"] }
num_cpus = "1.15.0"
epserde = "0.2.0"
sux = "0.1"
dsi-bitstream = "0.1.0"
dsi-bitstream = "0.1.2"
# Bin dependancies
clap = { version = "4.1.6", features = ["derive"] }
dsi-progress-logger = "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/graph/bvgraph/bvgraph_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ pub trait BVGraphCodesWriter {
fn write_residual(&mut self, value: u64) -> Result<usize, Self::Error>;

/// Consume the writer and call flush on the underlying writer
fn flush(self) -> Result<(), Self::Error>;
fn flush(&mut self) -> Result<(), Self::Error>;
}
3 changes: 2 additions & 1 deletion src/graph/bvgraph/bvgraph_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl<WGCW: BVGraphCodesWriter> BVComp<WGCW> {
}

/// Consume the compressor and flush the inner writer.
pub fn flush(self) -> Result<(), WGCW::Error> {
pub fn flush(&mut self) -> Result<(), WGCW::Error> {
self.bit_write.flush()
}
}
Expand Down Expand Up @@ -651,6 +651,7 @@ mod test {

bvcomp.extend(&seq_graph).unwrap();
bvcomp.flush()?;
drop(bvcomp);

// Read it back
let buffer_32: &[u32] = unsafe { buffer.align_to().1 };
Expand Down
4 changes: 2 additions & 2 deletions src/graph/bvgraph/code_readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ where
select_code_write!(self, RESIDUALS, K, value)
}

fn flush(self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
self.code_writer.flush()
}
}
Expand Down Expand Up @@ -489,7 +489,7 @@ impl<
select_code_mock_write!(RESIDUALS, K, value)
}

fn flush(self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
4 changes: 2 additions & 2 deletions src/graph/bvgraph/dyn_bv_code_readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ where
(self.write_residual)(&mut self.code_writer, value)
}

fn flush(self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
self.code_writer.flush()
}
}
Expand Down Expand Up @@ -600,7 +600,7 @@ impl BVGraphCodesWriter for DynamicCodesMockWriter {
Ok((self.len_residual)(value))
}

fn flush(self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}

0 comments on commit 04bb193

Please sign in to comment.