Skip to content

Commit

Permalink
refactor(storage): unify split sst
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Jun 17, 2024
1 parent f151c40 commit cb7199a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/meta/src/hummock/manager/commit_epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::collections::{BTreeMap, HashMap};

use itertools::Itertools;
use risingwave_common::catalog::TableId;
use risingwave_hummock_sdk::compaction_group::hummock_version_ext::split_sst;
use risingwave_hummock_sdk::compaction_group::StaticCompactionGroupId;
use risingwave_hummock_sdk::table_stats::{
add_prost_table_stats_map, purge_prost_table_stats, PbTableStatsMap,
Expand Down Expand Up @@ -358,14 +359,12 @@ impl HummockManager {
let mut new_sst_id = next_sstable_object_id(&self.env, new_sst_id_number).await?;
let mut commit_sstables = Vec::with_capacity(sst_to_cg_vec.len() + new_sst_id_number);

for (sst, group_table_ids) in sst_to_cg_vec {
for (mut sst, group_table_ids) in sst_to_cg_vec {
for (group_id, _match_ids) in group_table_ids {
let mut branch_sst = sst.sst_info.clone();
branch_sst.sst_id = new_sst_id;
let branch_sst = split_sst(&mut sst.sst_info, &mut new_sst_id);
commit_sstables.push(ExtendedSstableInfo::with_compaction_group(
group_id, branch_sst,
));
new_sst_id += 1;
}

new_sst_id += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,8 @@ fn split_sst_info_for_level(
.cloned()
.collect_vec();
if !removed_table_ids.is_empty() {
let mut branch_table_info = sst_info.clone();
branch_table_info.sst_id = *new_sst_id;
sst_info.sst_id = *new_sst_id + 1;
*new_sst_id += 1;
insert_table_infos.push(branch_table_info);
let branch_sst = split_sst(sst_info, new_sst_id);
insert_table_infos.push(branch_sst);
}
}
insert_table_infos
Expand Down Expand Up @@ -1293,6 +1290,15 @@ pub fn validate_version(version: &HummockVersion) -> Vec<String> {
res
}

pub fn split_sst(sst_info: &mut SstableInfo, new_sst_id: &mut u64) -> SstableInfo {
let mut branch_table_info = sst_info.clone();
branch_table_info.sst_id = *new_sst_id;
sst_info.sst_id = *new_sst_id + 1;
*new_sst_id += 1;

branch_table_info
}

#[cfg(test)]
mod tests {
use std::collections::HashMap;
Expand Down

0 comments on commit cb7199a

Please sign in to comment.