Skip to content

Commit

Permalink
fix f64 lz4 decode
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter committed Mar 16, 2024
1 parent c9d7b95 commit f03dbba
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions locustdb-derive/src/reify_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ fn types(t: &Ident) -> Option<Vec<Type>> {
"IntegerNoU64" => Some(vec![Type::U8, Type::U16, Type::U32, Type::I64]),
"NumberNoU64" => Some(vec![Type::U8, Type::U16, Type::U32, Type::I64, Type::F64]),
"Integer" => Some(vec![Type::U8, Type::U16, Type::U32, Type::U64, Type::I64]),
"Number" => Some(vec![Type::U8, Type::U16, Type::U32, Type::U64, Type::I64, Type::F64]),
"Float" => Some(vec![Type::F64]),
"NullableInteger" => Some(vec![Type::NullableU8, Type::NullableU16, Type::NullableU32, Type::NullableI64]),
"NullableFloat" => Some(vec![Type::NullableF64]),
Expand Down
5 changes: 3 additions & 2 deletions src/engine/operators/assemble_nullable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ impl<'a, T: VecData<T>> VecOperator<'a> for AssembleNullable<T> {

fn inputs(&self) -> Vec<BufferRef<Any>> { vec![self.data.any(), self.present.any()] }
fn outputs(&self) -> Vec<BufferRef<Any>> { vec![self.nullable_data.any()] }
fn can_stream_input(&self, _: usize) -> bool { true }
fn can_stream_output(&self, _: usize) -> bool { true }
// TODO: make streaming again?
fn can_stream_input(&self, _: usize) -> bool { false }
fn can_stream_output(&self, _: usize) -> bool { false }
fn allocates(&self) -> bool { true }
fn display_op(&self, _: bool) -> String { format!("nullable({}, {})", self.data, self.present) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine/operators/lz4_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct LZ4Decode<'a, T> {
pub has_more: bool,
}

impl<'a, T: GenericIntVec<T>> VecOperator<'a> for LZ4Decode<'a, T> {
impl<'a, T: VecData<T> + Default + 'static> VecOperator<'a> for LZ4Decode<'a, T> {
fn execute(&mut self, _: bool, scratchpad: &mut Scratchpad<'a>) -> Result<(), QueryError> {
let mut decoded = scratchpad.get_mut(self.decoded);
let len = lz4::decode(&mut self.reader, &mut decoded);
Expand All @@ -23,7 +23,7 @@ impl<'a, T: GenericIntVec<T>> VecOperator<'a> for LZ4Decode<'a, T> {
}

fn init(&mut self, _: usize, batch_size: usize, scratchpad: &mut Scratchpad<'a>) {
scratchpad.set(self.decoded, vec![T::zero(); batch_size]);
scratchpad.set(self.decoded, vec![T::default(); batch_size]);
let encoded = scratchpad.get_pinned(self.encoded);
self.reader = Box::new(lz4::decoder(encoded));
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/operators/vector_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub mod operator {
let reader: Box<dyn Read> = Box::new(&[] as &[u8]);
reify_types! {
"lz4_decode";
decoded: Integer;
decoded: Number;
Ok(Box::new(LZ4Decode::<'a, _> { encoded, decoded, decoded_len, reader, has_more: true }))
}
}
Expand Down

0 comments on commit f03dbba

Please sign in to comment.