Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ struct SSTReaderInterfaces {
struct CloudStorageEngineInterfaces {
bool (*fn_get_keyspace_encryption)(RaftStoreProxyPtr, uint32_t);
RawCppStringPtr (*fn_get_master_key)(RaftStoreProxyPtr);
RustStrWithViewVec (*fn_get_region_bucket_keys)(uint64_t, uint64_t,
RaftStoreProxyPtr);
ColumnarReaderPtr (*fn_get_columnar_reader)(uint64_t, uint64_t, uint64_t,
BaseBuffView, BaseBuffView,
BaseBuffView, BaseBuffView,
Expand Down
14 changes: 14 additions & 0 deletions contrib/tiflash-columnar-hub/hub-runtime/src/cloud_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ impl PdClientWithCache {
pub fn get_security_mgr(&self) -> Arc<SecurityManager> {
self.pd_client.get_security_mgr()
}

pub fn get_region_bucket_keys(&self, region_id: u64, region_ver: u64) -> Vec<Vec<u8>> {
let Some(bucket_stat) = self.pd_client.get_buckets(region_id) else {
return Vec::new();
};
if bucket_stat.meta.region_epoch.get_version() != region_ver {
return Vec::new();
}
bucket_stat.meta.keys.clone()
}
}

#[derive(Clone)]
Expand Down Expand Up @@ -444,6 +454,10 @@ impl CloudHelper {
}
}
}

pub fn get_region_bucket_keys(&self, region_id: u64, region_ver: u64) -> Vec<Vec<u8>> {
self.pd_client.get_region_bucket_keys(region_id, region_ver)
}
}

fn collect_ia_meta_files(meta_paths: &[PathBuf]) -> std::io::Result<Vec<IaMetaFileEntry>> {
Expand Down
20 changes: 18 additions & 2 deletions contrib/tiflash-columnar-hub/hub-runtime/src/columnar_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use kvengine::{CloudColumnarReaders, TableCtx};
use protobuf::{parse_from_bytes, Message};

use crate::{
build_from_string,
build_from_string, build_from_vec_string,
interfaces_ffi::{
BaseBuffView, ColumnarReaderErrorType, ColumnarReaderPtr, RaftStoreProxyPtr, RawRustPtr,
RawVoidPtr, RustStrWithView,
RawVoidPtr, RustStrWithView, RustStrWithViewVec,
},
RawRustPtrType,
};
Expand Down Expand Up @@ -73,6 +73,22 @@ impl From<crate::Error> for ColumnarReaderPtr {
}
}

pub unsafe extern "C" fn ffi_get_region_bucket_keys(
region_id: u64,
region_ver: u64,
hub_ptr: RaftStoreProxyPtr,
) -> RustStrWithViewVec {
let hub = hub_ptr.as_ref();
let bucket_keys = hub
.cloud_helper
.get_region_bucket_keys(region_id, region_ver);
if bucket_keys.is_empty() {
RustStrWithViewVec::default()
} else {
build_from_vec_string(bucket_keys)
}
}

pub unsafe extern "C" fn ffi_make_columnar_reader(
shard_id: u64,
shard_ver: u64,
Expand Down
7 changes: 7 additions & 0 deletions contrib/tiflash-columnar-hub/hub-runtime/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ pub mod root {
arg1: root::DB::RaftStoreProxyPtr,
) -> root::DB::RawCppStringPtr,
>,
pub fn_get_region_bucket_keys: ::std::option::Option<
unsafe extern "C" fn(
arg1: u64,
arg2: u64,
arg3: root::DB::RaftStoreProxyPtr,
) -> root::DB::RustStrWithViewVec,
>,
pub fn_get_columnar_reader: ::std::option::Option<
unsafe extern "C" fn(
arg1: u64,
Expand Down
5 changes: 3 additions & 2 deletions contrib/tiflash-columnar-hub/hub-runtime/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ use tikv_util::{
use crate::{
cloud_helper::{CloudEngineBackends, CloudHelper},
columnar_impls::{
ffi_make_columnar_reader, ffi_physical_table_id, ffi_read_block, ffi_read_column,
ffi_read_handle, ffi_read_version,
ffi_get_region_bucket_keys, ffi_make_columnar_reader, ffi_physical_table_id,
ffi_read_block, ffi_read_column, ffi_read_handle, ffi_read_version,
},
domain_impls::ffi_gc_rust_ptr,
engine_store_helper::{
Expand Down Expand Up @@ -1140,6 +1140,7 @@ fn build_hub_ffi_helper(hub: &ColumnarHub) -> RaftStoreProxyFFIHelper {
cloud_storage_engine_interfaces: CloudStorageEngineInterfaces {
fn_get_keyspace_encryption: Some(ffi_get_keyspace_encryption),
fn_get_master_key: Some(ffi_get_master_key),
fn_get_region_bucket_keys: Some(ffi_get_region_bucket_keys),
fn_get_columnar_reader: Some(ffi_make_columnar_reader),
fn_read_block: Some(ffi_read_block),
fn_read_handle: Some(ffi_read_handle),
Expand Down
Loading