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