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