Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support prefix for object store #463

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions analytic_engine/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use common_util::define_result;
use futures::Future;
use message_queue::kafka::kafka_impl::KafkaImpl;
use object_store::{
aliyun::AliyunOSS, cache::CachedStore, disk_cache::DiskCacheStore, mem_cache::MemCacheStore,
LocalFileSystem, ObjectStoreRef,
aliyun::AliyunOSS, disk_cache::DiskCacheStore, mem_cache::MemCacheStore,
prefix::StoreWithPrefix, LocalFileSystem, ObjectStoreRef,
};
use snafu::{Backtrace, ResultExt, Snafu};
use table_engine::engine::{EngineRuntimes, TableEngineRef};
Expand Down Expand Up @@ -387,19 +387,15 @@ fn open_storage(
let store = LocalFileSystem::new_with_prefix(sst_path).context(OpenObjectStore)?;
Arc::new(store) as _
}
ObjectStoreOptions::Aliyun(aliyun_opts) => Arc::new(AliyunOSS::new(
aliyun_opts.key_id,
aliyun_opts.key_secret,
aliyun_opts.endpoint,
aliyun_opts.bucket,
)) as _,
ObjectStoreOptions::Cache(cache_opts) => {
let local_store = open_storage(*cache_opts.local_store).await?;
let remote_store = open_storage(*cache_opts.remote_store).await?;
let store = CachedStore::init(local_store, remote_store, cache_opts.cache_opts)
.await
.context(OpenObjectStore)?;
Arc::new(store) as _
ObjectStoreOptions::Aliyun(aliyun_opts) => {
let oss = Arc::new(AliyunOSS::new(
aliyun_opts.key_id,
aliyun_opts.key_secret,
aliyun_opts.endpoint,
aliyun_opts.bucket,
));
Arc::new(StoreWithPrefix::new(aliyun_opts.prefix, oss).context(OpenObjectStore)?)
as _
}
};

Expand Down
14 changes: 3 additions & 11 deletions analytic_engine/src/storage_options.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

use common_util::config::ReadableSize;
use object_store::cache::CachedStoreConfig;
use serde::Deserialize;

#[derive(Debug, Clone, Deserialize)]
Expand All @@ -25,9 +24,9 @@ impl Default for StorageOptions {

StorageOptions {
mem_cache_capacity: ReadableSize::mb(512),
mem_cache_partition_bits: 1,
mem_cache_partition_bits: 6,
disk_cache_path: root_path.clone(),
disk_cache_capacity: ReadableSize::gb(5),
disk_cache_capacity: ReadableSize::gb(0),
disk_cache_page_size: ReadableSize::mb(2),
object_store: ObjectStoreOptions::Local(LocalOptions {
data_path: root_path,
Expand All @@ -41,7 +40,6 @@ impl Default for StorageOptions {
pub enum ObjectStoreOptions {
Local(LocalOptions),
Aliyun(AliyunOptions),
Cache(CacheOptions),
}

#[derive(Debug, Clone, Deserialize)]
Expand All @@ -55,11 +53,5 @@ pub struct AliyunOptions {
pub key_secret: String,
pub endpoint: String,
pub bucket: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct CacheOptions {
pub local_store: Box<StorageOptions>,
pub remote_store: Box<StorageOptions>,
pub cache_opts: CachedStoreConfig,
pub prefix: String,
}
Loading