metric_engine/engine/
flush.rsuse snafu::ResultExt;
use store_api::region_engine::RegionEngine;
use store_api::region_request::{AffectedRows, RegionFlushRequest, RegionRequest};
use store_api::storage::RegionId;
use crate::engine::MetricEngineInner;
use crate::error::{MitoFlushOperationSnafu, Result, UnsupportedRegionRequestSnafu};
use crate::utils;
impl MetricEngineInner {
pub async fn flush_region(
&self,
region_id: RegionId,
req: RegionFlushRequest,
) -> Result<AffectedRows> {
if !self.is_physical_region(region_id) {
return UnsupportedRegionRequestSnafu {
request: RegionRequest::Flush(req),
}
.fail();
}
let metadata_region_id = utils::to_metadata_region_id(region_id);
self.mito
.handle_request(metadata_region_id, RegionRequest::Flush(req.clone()))
.await
.context(MitoFlushOperationSnafu)
.map(|response| response.affected_rows)?;
let data_region_id = utils::to_data_region_id(region_id);
self.mito
.handle_request(data_region_id, RegionRequest::Flush(req.clone()))
.await
.context(MitoFlushOperationSnafu)
.map(|response| response.affected_rows)
}
}