mito2/sst/index/build.rs
1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Shared index plans and physical inputs carried into SST writers.
16
17use std::sync::Arc;
18
19use crate::sst::file::FileHandle;
20use crate::sst::index::puffin_manager::SstPuffinManager;
21use crate::sst::index::registry::IndexBuildPlan;
22
23/// An immutable plan with operation-scoped input files and output constraints.
24/// Compaction and SST index rebuilds supply these inputs, including asynchronous
25/// post-flush indexing. Synchronous memtable flushes have no persisted input files.
26#[derive(Clone)]
27pub struct IndexBuildInputs {
28 /// Typed plans shared by output files of this operation.
29 pub plan: Arc<IndexBuildPlan>,
30 /// Pinned physical input files. Post-flush indexing reads the newly written SST.
31 pub inputs: Arc<[FileHandle]>,
32 /// Reads persisted inputs even when output uses a local write cache.
33 /// Input availability is determined by `inputs.is_empty()`, not this manager.
34 pub input_puffin_manager: SstPuffinManager,
35 /// Allows coarse input reuse only for the complete input scope without slicing.
36 /// The caller that owns the output plan validates this scope.
37 /// This is not a promise that input rows equal live output rows: deduplication
38 /// or deletion may remove rows. Handlers must record input-derived coverage
39 /// separately from actual output counts when reusing approximate summaries.
40 pub can_merge_inputs: bool,
41 /// Existing allocation available to optional index creators; `None` sets no limit here.
42 /// Single-region compaction and rebuild currently provide no shared total limit.
43 pub memory_limit: Option<usize>,
44 /// Exact row count of an unchanged SST during rebuild, otherwise unknown.
45 pub output_rows: Option<u64>,
46}