Skip to main content

mito2/
series_index.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//! Series index writer and searcher.
16
17// These components are consumed by the upcoming query and maintenance integration.
18#[allow(dead_code)]
19mod catalog;
20#[allow(dead_code)]
21mod purger;
22mod searcher;
23mod task;
24#[allow(dead_code)]
25mod version;
26mod writer;
27
28use futures::stream::BoxStream;
29pub use searcher::SeriesIndexSearcher;
30use store_api::metric_engine_consts::{
31    DATA_SCHEMA_TABLE_ID_COLUMN_NAME as TABLE_ID_COLUMN,
32    DATA_SCHEMA_TSID_COLUMN_NAME as TSID_COLUMN,
33};
34pub use writer::{
35    SeriesIndexWriter, SeriesIndexWriterMetrics, SeriesIndexWriterOptions, series_index_schema,
36};
37
38use crate::error::Result;
39pub(crate) use crate::series_index::catalog::{delete_catalogs, load_version_control};
40pub(crate) use crate::series_index::purger::{IndexFilePurger, series_index_channel};
41pub(crate) use crate::series_index::task::{SeriesIndexTaskState, spawn_series_index_tasks};
42pub(crate) use crate::series_index::version::{SeriesIndexVersion, SeriesIndexVersionControl};
43
44pub(crate) const MIN_TS_COLUMN: &str = "__series_min_ts";
45pub(crate) const MAX_TS_COLUMN: &str = "__series_max_ts";
46pub(crate) const ROW_COUNT_COLUMN: &str = "__series_row_count";
47pub(crate) const METRIC_SERIES_ID_BATCH_SIZE: usize = 500;
48
49/// Identifies one series in a physical metric region.
50#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
51pub struct MetricSeriesId {
52    /// Logical table ID inside the physical metric region.
53    pub table_id: u32,
54    /// Time-series ID inside the logical table.
55    pub tsid: u64,
56}
57
58/// Stream of bounded batches of matching metric-series IDs.
59pub type MetricSeriesIdStream = BoxStream<'static, Result<Vec<MetricSeriesId>>>;