Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve deserialization of value encoding for struct/list #5897

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/common/src/util/value_encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ fn deserialize_value(ty: &DataType, data: &mut impl Buf) -> Result<Datum> {
}

fn deserialize_struct(struct_def: &StructType, data: &mut impl Buf) -> Result<ScalarImpl> {
let field_values = struct_def
.fields
.iter()
.map(|field_type| inner_deserialize_datum(data, field_type))
.collect::<Result<Vec<Datum>>>()?;
let num_fields = struct_def.fields.len();
let mut field_values = Vec::with_capacity(num_fields);
for field_type in &struct_def.fields {
field_values.push(inner_deserialize_datum(data, field_type)?);
}

Ok(ScalarImpl::Struct(StructValue::new(field_values)))
}

fn deserialize_list(item_type: &DataType, data: &mut impl Buf) -> Result<ScalarImpl> {
let len = data.get_u32_le();
let values = (0..len)
.map(|_| inner_deserialize_datum(data, item_type))
.collect::<Result<Vec<Datum>>>()?;

let mut values = Vec::with_capacity(len as usize);
for _ in 0..len {
values.push(inner_deserialize_datum(data, item_type)?);
}
Ok(ScalarImpl::List(ListValue::new(values)))
}

Expand Down