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