diff --git a/src/mito2/src/region.rs b/src/mito2/src/region.rs index c566dd47c0..292f3ec6d4 100644 --- a/src/mito2/src/region.rs +++ b/src/mito2/src/region.rs @@ -849,6 +849,44 @@ impl MitoRegion { .collect::>() } + /// Returns all live SST file metas and the current manifest version from + /// the region manifest, merging both the normal and staging manifests. + /// + /// While the region is in staging mode (e.g. during region copy/migration), + /// the authoritative live file set lives in the staging manifest, so this + /// method merges both — matching the semantics of [`manifest_sst_entries`]. + /// + /// The returned manifest version is the staging version when a staging + /// manifest is present, otherwise the normal manifest version. + pub async fn all_manifest_files(&self) -> (Vec, ManifestVersion) { + let manifest = self.manifest_ctx.manifest().await; + let staging = self + .manifest_ctx + .staging_manifest() + .await + .map(|m| (m.files.clone(), m.manifest_version)); + + let version = staging + .as_ref() + .map(|(_, v)| *v) + .unwrap_or(manifest.manifest_version); + + let files = match staging { + Some((staging_files, _)) => { + let merged = manifest + .files + .clone() + .into_iter() + .chain(staging_files) + .collect::>(); + merged.into_values().collect() + } + None => manifest.files.values().cloned().collect(), + }; + + (files, version) + } + /// Exit staging mode successfully by merging all staged manifests and making them visible. /// Merges staged manifest actions into the live manifest and exits staging mode. ///