Skip to content

Commit

Permalink
Fix xor float decode on 32-bit architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter committed Apr 3, 2024
1 parent 05ae8e0 commit 421caff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions locustdb-compression-utils/src/xor_float/double.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn encode(floats: &[f64], max_regret: u32, mantissa: Option<u32>) -> Vec<u8>
&& trailing_zeros >= last_trailing_zeros
&& (regret < max_regret || significant_bits == last_significant_bits)
{
// We want to write first a 1 bit and then a 0 bit, but because we are in LittleEndian mode
// We want to write first a 1 bit and then a 0 bit, but because we are in LittleEndian mode
// the bits get written in reverse order. So we write 0b01 to get 0b10 in the output.
writer.write_int(0b01, 2).unwrap();
let xor = xor >> last_trailing_zeros;
Expand Down Expand Up @@ -63,7 +63,8 @@ pub fn encode(floats: &[f64], max_regret: u32, mantissa: Option<u32>) -> Vec<u8>
pub fn decode(data: &[u8]) -> Result<Vec<f64>, Error> {
let buffer = BitReadBuffer::new(data, LittleEndian);
let mut reader = BitReadStream::new(buffer);
let length = reader.read_int(64).map_err(|_| Error::Eof)?;
let length = reader.read_int::<u64>(64).map_err(|_| Error::Eof)? as usize;

let mut decoded = vec![f64::from_bits(0u64); length];

if length == 0 {
Expand Down

0 comments on commit 421caff

Please sign in to comment.