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