feat: declare converter

This commit is contained in:
evenyag
2025-03-09 15:33:00 +08:00
parent 62a333ad09
commit 87723effc7
3 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
// 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.
//! SST converter.
use datanode::config::{FileConfig, StorageConfig};
use datanode::datanode::DatanodeBuilder;
use datanode::store::fs::new_fs_object_store;
use meta_client::MetaClientOptions;
use object_store::manager::ObjectStoreManagerRef;
use object_store::ObjectStore;
use snafu::ResultExt;
use crate::error::{DatanodeSnafu, Result};
/// SST converter takes a list of source files and converts them to SST files.
pub struct SstConverter {
/// Object store for input files
input_store: ObjectStore,
/// Object store manager for output files.
output_store_manager: ObjectStoreManagerRef,
}
impl SstConverter {
//
}
/// Builder to build a SST converter.
pub struct SstConverterBuilder {
input_path: String,
meta_options: MetaClientOptions,
storage_config: StorageConfig,
}
impl SstConverterBuilder {
/// Creates a new builder.
pub fn new(input_path: String) -> Self {
Self {
input_path,
meta_options: MetaClientOptions::default(),
storage_config: StorageConfig::default(),
}
}
}
/// A hepler function to create the object store manager.
pub async fn new_object_store_manager(config: &StorageConfig) -> Result<ObjectStoreManagerRef> {
DatanodeBuilder::build_object_store_manager(config)
.await
.context(DatanodeSnafu)
}
/// Creates a input store from a path.
pub async fn new_input_store(path: &str) -> Result<ObjectStore> {
new_fs_object_store(path, &FileConfig::default())
.await
.context(DatanodeSnafu)
}

View File

@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pub mod converter;
pub mod error;
mod reader;
mod table;

View File

@@ -22,6 +22,7 @@ use common_meta::key::table_name::TableNameKey;
use common_meta::key::{TableMetadataManager, TableMetadataManagerRef};
use meta_client::{MetaClientOptions, MetaClientType};
// TODO(yingwen): Error handling.
#[derive(Clone)]
pub struct TableMetadataHelper {
table_metadata_manager: TableMetadataManagerRef,