Skip to main content

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