forked from GreptimeTeam/greptimedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mito2): add file purger and cooperate with scheduler to purge ss…
…t files (GreptimeTeam#2251) * feat: add file purger and use scheduler Signed-off-by: ZhuZiyi <[email protected]> * chore: code format Signed-off-by: ZhuZiyi <[email protected]> * chore: code format Signed-off-by: ZhuZiyi <[email protected]> * feat: print some information about handling error message Signed-off-by: ZhuZiyi <[email protected]> * fix: resolve conversion Signed-off-by: ZhuZiyi <[email protected]> * chore: code format Signed-off-by: ZhuZiyi <[email protected]> * chore: resolve conversation Signed-off-by: ZhuZiyi <[email protected]> * fix: resolve conflicting files Signed-off-by: ZhuZiyi <[email protected]> * chore: code format Signed-off-by: ZhuZiyi <[email protected]> * chore: code format Signed-off-by: ZhuZiyi <[email protected]> --------- Signed-off-by: ZhuZiyi <[email protected]>
- Loading branch information
Showing
6 changed files
with
191 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::sync::Arc; | ||
|
||
use object_store::{util, ObjectStore}; | ||
use snafu::ResultExt; | ||
|
||
use crate::error::{DeleteSstSnafu, Result}; | ||
use crate::sst::file::FileId; | ||
|
||
pub type AccessLayerRef = Arc<AccessLayer>; | ||
|
||
/// Sst access layer. | ||
pub struct AccessLayer { | ||
sst_dir: String, | ||
object_store: ObjectStore, | ||
} | ||
|
||
impl std::fmt::Debug for AccessLayer { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct("AccessLayer") | ||
.field("sst_dir", &self.sst_dir) | ||
.finish() | ||
} | ||
} | ||
|
||
impl AccessLayer { | ||
pub fn new(sst_dir: &str, object_store: ObjectStore) -> AccessLayer { | ||
AccessLayer { | ||
sst_dir: sst_dir.to_string(), | ||
object_store, | ||
} | ||
} | ||
|
||
fn sst_file_path(&self, file_name: &str) -> String { | ||
util::join_path(&self.sst_dir, file_name) | ||
} | ||
|
||
/// Deletes a SST file with given file id. | ||
pub async fn delete_sst(&self, file_id: FileId) -> Result<()> { | ||
let path = self.sst_file_path(&file_id.as_parquet()); | ||
self.object_store | ||
.delete(&path) | ||
.await | ||
.context(DeleteSstSnafu { file_id }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters