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

feat(storage): Splitting table change log from HummockVersion on CN side #20050

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/storage/hummock_sdk/src/change_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ impl<T> TableChangeLogCommon<T> {
}
self.0.push_back(new_change_log);
}

pub fn change_log_into_iter(self) -> impl Iterator<Item = EpochNewChangeLogCommon<T>> {
self.0.into_iter()
}
}

pub type TableChangeLog = TableChangeLogCommon<SstableInfo>;
Expand Down
32 changes: 20 additions & 12 deletions src/storage/hummock_sdk/src/compaction_group/hummock_version_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::level::{Level, LevelCommon, Levels, OverlappingLevel};
use crate::sstable_info::SstableInfo;
use crate::table_watermark::{ReadTableWatermark, TableWatermarks};
use crate::version::{
GroupDelta, GroupDeltaCommon, HummockVersion, HummockVersionCommon, HummockVersionDelta,
GroupDelta, GroupDeltaCommon, HummockVersion, HummockVersionCommon, HummockVersionDeltaCommon,
HummockVersionStateTableInfo, IntraLevelDelta, IntraLevelDeltaCommon, ObjectIdReader,
SstableIdReader,
};
Expand All @@ -50,7 +50,7 @@ pub struct SstDeltaInfo {

pub type BranchedSstInfo = HashMap<CompactionGroupId, Vec<HummockSstableId>>;

impl HummockVersion {
impl<L> HummockVersionCommon<SstableInfo, L> {
pub fn get_compaction_group_levels(&self, compaction_group_id: CompactionGroupId) -> &Levels {
self.levels
.get(&compaction_group_id)
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn safe_epoch_read_table_watermarks_impl(
.collect()
}

impl HummockVersion {
impl<L: Clone> HummockVersionCommon<SstableInfo, L> {
pub fn count_new_ssts_in_group_split(
&self,
parent_group_id: CompactionGroupId,
Expand Down Expand Up @@ -356,7 +356,10 @@ impl HummockVersion {
.all(|level| !level.table_infos.is_empty()));
}

pub fn build_sst_delta_infos(&self, version_delta: &HummockVersionDelta) -> Vec<SstDeltaInfo> {
pub fn build_sst_delta_infos(
&self,
version_delta: &HummockVersionDeltaCommon<SstableInfo, L>,
) -> Vec<SstDeltaInfo> {
let mut infos = vec![];

// Skip trivial move delta for refiller
Expand Down Expand Up @@ -459,7 +462,10 @@ impl HummockVersion {
infos
}

pub fn apply_version_delta(&mut self, version_delta: &HummockVersionDelta) {
pub fn apply_version_delta(
&mut self,
version_delta: &HummockVersionDeltaCommon<SstableInfo, L>,
) {
assert_eq!(self.id, version_delta.prev_id);

let (changed_table_info, mut is_commit_epoch) = self.state_table_info.apply_delta(
Expand Down Expand Up @@ -930,16 +936,10 @@ impl HummockVersion {
}
}

impl<T> HummockVersionCommon<T>
impl<T> HummockVersionCommon<T, T>
where
T: SstableIdReader + ObjectIdReader,
{
pub fn get_combined_levels(&self) -> impl Iterator<Item = &'_ LevelCommon<T>> + '_ {
self.levels
.values()
.flat_map(|level| level.l0.sub_levels.iter().rev().chain(level.levels.iter()))
}

pub fn get_object_ids(&self) -> HashSet<HummockSstableObjectId> {
self.get_sst_infos().map(|s| s.object_id()).collect()
}
Expand Down Expand Up @@ -1094,6 +1094,14 @@ impl Levels {
}
}

impl<T, L> HummockVersionCommon<T, L> {
pub fn get_combined_levels(&self) -> impl Iterator<Item = &'_ LevelCommon<T>> + '_ {
self.levels
.values()
.flat_map(|level| level.l0.sub_levels.iter().rev().chain(level.levels.iter()))
}
}

pub fn build_initial_compaction_group_levels(
group_id: CompactionGroupId,
compaction_config: &CompactionConfig,
Expand Down
5 changes: 3 additions & 2 deletions src/storage/hummock_sdk/src/time_travel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::version::{
};
use crate::{CompactionGroupId, HummockSstableId, HummockSstableObjectId};

pub type IncompleteHummockVersion = HummockVersionCommon<SstableIdInVersion>;
pub type IncompleteHummockVersion = HummockVersionCommon<SstableIdInVersion, SstableIdInVersion>;

/// Populates `SstableInfo` for `table_id`.
/// `SstableInfo` not associated with `table_id` is removed.
Expand Down Expand Up @@ -159,7 +159,8 @@ fn rewrite_levels(mut levels: PbLevels, time_travel_table_ids: &HashSet<StateTab
/// [`IncompleteHummockVersionDelta`] is incomplete because `SSTableInfo` only has the `sst_id` set in the following fields:
/// - `PbGroupDeltas`
/// - `ChangeLogDelta`
pub type IncompleteHummockVersionDelta = HummockVersionDeltaCommon<SstableIdInVersion>;
pub type IncompleteHummockVersionDelta =
HummockVersionDeltaCommon<SstableIdInVersion, SstableIdInVersion>;

/// `SStableInfo` will be stripped.
impl From<(&HummockVersionDelta, &HashSet<StateTableId>)> for IncompleteHummockVersionDelta {
Expand Down
Loading
Loading