Skip to content

Commit

Permalink
specify dummy id, use new new to construct serializer
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
  • Loading branch information
BugenZhao committed Feb 26, 2025
1 parent cd56b40 commit bd1cf58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/common/src/util/value_encoding/column_aware_row_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ mod new_serde {

fn new_serialize_struct(struct_type: &StructType, value: StructRef<'_>, buf: &mut impl BufMut) {
let serializer = super::Serializer::new_new(
&[], // TODO: column ids
struct_type.types().cloned(), // TODO: avoid this clone
&struct_type.ids().unwrap().collect_vec(), // TODO: avoid this clone
struct_type.types().cloned(), // TODO: avoid this clone
);

let bytes = serializer.serialize(value); // TODO: serialize into the buf directly
Expand Down Expand Up @@ -115,7 +115,7 @@ mod new_serde {

fn new_deserialize_struct(struct_def: &StructType, data: &mut &[u8]) -> Result<ScalarImpl> {
let deserializer = super::Deserializer::new(
&[], // TODO: column ids
&struct_def.ids().unwrap().collect_vec(), // TODO: avoid this clone
struct_def.types().cloned().collect_vec().into(), // TODO: avoid this clone
std::iter::empty(),
);
Expand Down Expand Up @@ -329,7 +329,10 @@ impl Serializer {
}
}

pub fn new_new(column_ids: &[ColumnId], data_types: impl Iterator<Item = DataType>) -> Self {
pub fn new_new(
column_ids: &[ColumnId],
data_types: impl IntoIterator<Item = DataType>,
) -> Self {
// currently we hard-code ColumnId as i32
let mut encoded_column_ids = Vec::with_capacity(column_ids.len() * 4);
for id in column_ids {
Expand All @@ -338,7 +341,7 @@ impl Serializer {

Self {
encoded_column_ids,
data_types: data_types.collect(),
data_types: data_types.into_iter().collect(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/storage/src/row_serde/value_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl ValueRowSerdeNew for ColumnAwareSerde {
}
});

let serializer = Serializer::new(&column_ids);
let serializer = Serializer::new_new(&column_ids, schema.clone());
let deserializer = Deserializer::new(&column_ids, schema.into(), column_with_default);
ColumnAwareSerde {
serializer,
Expand Down

0 comments on commit bd1cf58

Please # to comment.