mito2/
lib.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//! # Mito
16//!
17//! Mito is the a region engine to store timeseries data.
18
19#![feature(let_chains)]
20#![feature(assert_matches)]
21#![feature(result_flattening)]
22#![feature(int_roundings)]
23#![feature(debug_closure_helpers)]
24#![feature(duration_constructors)]
25
26#[cfg(any(test, feature = "test"))]
27#[cfg_attr(feature = "test", allow(unused))]
28pub mod test_util;
29
30pub mod access_layer;
31pub mod cache;
32pub mod compaction;
33pub mod config;
34pub mod engine;
35pub mod error;
36pub mod flush;
37pub mod manifest;
38pub mod memtable;
39mod metrics;
40pub mod read;
41pub mod region;
42mod region_write_ctx;
43pub mod request;
44pub mod schedule;
45pub mod sst;
46mod time_provider;
47pub mod wal;
48mod worker;
49
50#[cfg_attr(doc, aquamarine::aquamarine)]
51/// # Mito developer document
52///
53/// ## Engine
54///
55/// Engine hierarchy:
56///
57/// ```mermaid
58/// classDiagram
59/// class MitoEngine {
60///     -WorkerGroup workers
61/// }
62/// class MitoRegion {
63///     +VersionControlRef version_control
64///     -RegionId region_id
65///     -String manifest_dir
66///     -AtomicI64 last_flush_millis
67///     +region_id() RegionId
68///     +scan() ChunkReaderImpl
69/// }
70/// class RegionMap {
71///     -HashMap<RegionId, MitoRegionRef> regions
72/// }
73/// class ChunkReaderImpl
74///
75/// class WorkerGroup {
76///     -Vec~RegionWorker~ workers
77/// }
78/// class RegionWorker {
79///     -RegionMap regions
80///     -Sender sender
81///     -JoinHandle handle
82/// }
83/// class RegionWorkerThread~LogStore~ {
84///     -RegionMap regions
85///     -Receiver receiver
86///     -Wal~LogStore~ wal
87///     -ObjectStore object_store
88///     -MemtableBuilderRef memtable_builder
89///     -FlushSchedulerRef~LogStore~ flush_scheduler
90///     -FlushStrategy flush_strategy
91///     -CompactionSchedulerRef~LogStore~ compaction_scheduler
92///     -FilePurgerRef file_purger
93/// }
94/// class Wal~LogStore~ {
95///     -LogStore log_store
96/// }
97/// class MitoConfig
98///
99/// MitoEngine o-- MitoConfig
100/// MitoEngine o-- MitoRegion
101/// MitoEngine o-- WorkerGroup
102/// MitoRegion o-- VersionControl
103/// MitoRegion -- ChunkReaderImpl
104/// WorkerGroup o-- RegionWorker
105/// RegionWorker o-- RegionMap
106/// RegionWorker -- RegionWorkerThread~LogStore~
107/// RegionWorkerThread~LogStore~ o-- RegionMap
108/// RegionWorkerThread~LogStore~ o-- Wal~LogStore~
109/// ```
110///
111/// ## Metadata
112///
113/// Metadata hierarchy:
114///
115/// ```mermaid
116/// classDiagram
117/// class VersionControl {
118///     -CowCell~Version~ version
119///     -AtomicU64 committed_sequence
120/// }
121/// class Version {
122///     -RegionMetadataRef metadata
123///     -MemtableVersionRef memtables
124///     -SstVersionRef ssts
125///     -SequenceNumber flushed_sequence
126///     -ManifestVersion manifest_version
127/// }
128/// class MemtableVersion {
129///     -MemtableRef mutable
130///     -Vec~MemtableRef~ immutables
131///     +mutable_memtable() MemtableRef
132///     +immutable_memtables() &[MemtableRef]
133///     +freeze_mutable(MemtableRef new_mutable) MemtableVersion
134/// }
135/// class SstVersion {
136///     -LevelMetaVec levels
137///     -AccessLayerRef sst_layer
138///     -FilePurgerRef file_purger
139///     -Option~i64~ compaction_time_window
140/// }
141/// class LevelMeta {
142///     -Level level
143///     -HashMap<FileId, FileHandle> files
144/// }
145/// class FileHandle {
146///     -FileMeta meta
147///     -bool compacting
148///     -AtomicBool deleted
149///     -AccessLayerRef sst_layer
150///     -FilePurgerRef file_purger
151/// }
152/// class FileMeta {
153///     +RegionId region_id
154///     +FileId file_id
155///     +Option<Timestamp, Timestamp> time_range
156///     +Level level
157///     +u64 file_size
158/// }
159/// VersionControl o-- Version
160/// Version o-- RegionMetadata
161/// Version o-- MemtableVersion
162/// Version o-- SstVersion
163/// SstVersion o-- LevelMeta
164/// LevelMeta o-- FileHandle
165/// FileHandle o-- FileMeta
166/// class RegionMetadata
167/// ```
168///
169/// ## Region workers
170///
171/// The engine handles DMLs and DDLs in dedicated [workers](crate::worker::WorkerGroup).
172///
173/// ## Region manifest
174///
175/// The [RegionManifestManager](crate::manifest::manager::RegionManifestManager) manages metadata of the engine.
176///
177mod docs {}