diff --git a/src/metric-engine/src/config.rs b/src/metric-engine/src/config.rs index 150885ed49..e342cd9d73 100644 --- a/src/metric-engine/src/config.rs +++ b/src/metric-engine/src/config.rs @@ -17,13 +17,14 @@ use std::time::Duration; use common_telemetry::warn; use serde::{Deserialize, Serialize}; -/// The default flush interval of the metadata region. +/// The default flush interval of the metadata region. pub(crate) const DEFAULT_FLUSH_METADATA_REGION_INTERVAL: Duration = Duration::from_secs(30); /// Configuration for the metric engine. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct EngineConfig { /// Whether to use sparse primary key encoding. + #[serde(default = "EngineConfig::default_sparse_primary_key_encoding")] pub sparse_primary_key_encoding: bool, /// The flush interval of the metadata region. #[serde( @@ -37,7 +38,7 @@ impl Default for EngineConfig { fn default() -> Self { Self { flush_metadata_region_interval: DEFAULT_FLUSH_METADATA_REGION_INTERVAL, - sparse_primary_key_encoding: true, + sparse_primary_key_encoding: Self::default_sparse_primary_key_encoding(), } } } @@ -47,6 +48,10 @@ impl EngineConfig { DEFAULT_FLUSH_METADATA_REGION_INTERVAL } + fn default_sparse_primary_key_encoding() -> bool { + true + } + /// Sanitizes the configuration. pub fn sanitize(&mut self) { if self.flush_metadata_region_interval.is_zero() {