Skip to content

Commit

Permalink
M src/meta/api/src/schema_api_impl.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Dec 6, 2024
1 parent 34ea28b commit f0034fa
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions src/meta/api/src/schema_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,38 +1648,23 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SchemaApi for KV {
) -> Result<Vec<Option<String>>, KVAppError> {
debug!(req :? =(&table_ids); "SchemaApi: {}", func_name!());

let mut id_name_kv_keys = Vec::with_capacity(table_ids.len());
for id in table_ids {
let k = TableIdToName { table_id: *id }.to_string_key();
id_name_kv_keys.push(k);
}

// Batch get all table-name by id
let seq_names = self.mget_kv(&id_name_kv_keys).await?;
let mut table_names = Vec::with_capacity(table_ids.len());

for seq_name in seq_names {
if let Some(seq_name) = seq_name {
let name_ident: DBIdTableName = deserialize_struct(&seq_name.data)?;
table_names.push(Some(name_ident.table_name));
} else {
table_names.push(None);
}
}
let id_to_name_idents = table_ids.iter().map(|id| TableIdToName { table_id: *id });

let mut meta_kv_keys = Vec::with_capacity(table_ids.len());
for id in table_ids {
let k = TableId { table_id: *id }.to_string_key();
meta_kv_keys.push(k);
}
let seq_names = self.get_pb_values_vec(id_to_name_idents).await?;
let mut table_names = seq_names
.into_iter()
.map(|seq_name| seq_name.map(|s| s.data.table_name))
.collect::<Vec<_>>();

let seq_metas = self.mget_kv(&meta_kv_keys).await?;
let id_idents = table_ids.iter().map(|id| TableId { table_id: *id });
let seq_metas = self.get_pb_values_vec(id_idents).await?;
for (i, seq_meta_opt) in seq_metas.iter().enumerate() {
if let Some(seq_meta) = seq_meta_opt {
let table_meta: TableMeta = deserialize_struct(&seq_meta.data)?;
if table_meta.drop_on.is_some() {
if seq_meta.data.drop_on.is_some() {
table_names[i] = None;
}
} else {
table_names[i] = None;
}
}

Expand Down

0 comments on commit f0034fa

Please sign in to comment.