Skip to content

Commit

Permalink
FFI: add two empty implement FFI for compatibility (#361)
Browse files Browse the repository at this point in the history
* FFI: add two empty implement FFI

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* add description

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* move into a struct

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* move to CloudStorageEngineInterfaces

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* fmt

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* update version

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* f

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* f

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

* update version

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

---------

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
  • Loading branch information
Lloyd-Pottiger authored Jan 18, 2024
1 parent 04e2be4 commit 23baffc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
19 changes: 19 additions & 0 deletions proxy_components/proxy_ffi/src/encryption_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,22 @@ pub extern "C" fn ffi_handle_link_file(
)
}
}

// The CloudStorageEngineFFI contains dummy implementation of
// CloudStorageEngine-specific FFI, not used, just for tiflash compilation.
pub struct CloudStorageEngineFFI {}

impl CloudStorageEngineFFI {
// always return false
pub extern "C" fn ffi_get_keyspace_encryption(
_proxy_ptr: RaftStoreProxyPtr,
_keyspace_id: u32,
) -> bool {
false
}

// always return empty string
pub extern "C" fn ffi_get_master_key(_proxy_ptr: RaftStoreProxyPtr) -> RawCppStringPtr {
get_engine_store_server_helper().gen_cpp_string(b"")
}
}
15 changes: 14 additions & 1 deletion proxy_components/proxy_ffi/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ pub mod root {
) -> root::DB::RustStrWithViewVec,
>,
}
#[repr(C)]
#[derive(Debug)]
pub struct CloudStorageEngineInterfaces {
pub fn_get_keyspace_encryption: ::std::option::Option<
unsafe extern "C" fn(arg1: root::DB::RaftStoreProxyPtr, arg2: u32) -> bool,
>,
pub fn_get_master_key: ::std::option::Option<
unsafe extern "C" fn(
arg1: root::DB::RaftStoreProxyPtr,
) -> root::DB::RawCppStringPtr,
>,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum MsgPBType {
Expand Down Expand Up @@ -420,6 +432,7 @@ pub mod root {
),
>,
pub sst_reader_interfaces: root::DB::SSTReaderInterfaces,
pub cloud_storage_engine_interfaces: root::DB::CloudStorageEngineInterfaces,
pub fn_server_info: ::std::option::Option<
unsafe extern "C" fn(
arg1: root::DB::RaftStoreProxyPtr,
Expand Down Expand Up @@ -741,7 +754,7 @@ pub mod root {
arg3: root::DB::RawVoidPtr,
) -> u32;
}
pub const RAFT_STORE_PROXY_VERSION: u64 = 5455550920944837743;
pub const RAFT_STORE_PROXY_VERSION: u64 = 3560036848329077111;
pub const RAFT_STORE_PROXY_MAGIC_NUMBER: u32 = 324508639;
}
}
12 changes: 9 additions & 3 deletions proxy_components/proxy_ffi/src/raftstore_proxy_helper_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use super::{
encryption_impls::*,
engine_store_helper_impls::*,
interfaces_ffi::{
BaseBuffView, ConfigJsonType, CppStrVecView, KVGetStatus, RaftProxyStatus,
RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr, RawCppStringPtr,
RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
BaseBuffView, CloudStorageEngineInterfaces, ConfigJsonType, CppStrVecView, KVGetStatus,
RaftProxyStatus, RaftStoreProxyFFIHelper, RaftStoreProxyPtr, RaftstoreVer, RawCppPtr,
RawCppStringPtr, RawRustPtr, RawVoidPtr, RustStrWithView, SSTReaderInterfaces,
},
read_index_helper,
snapshot_reader_impls::*,
Expand Down Expand Up @@ -78,6 +78,12 @@ impl RaftStoreProxyFFIHelper {
fn_approx_size: Some(ffi_approx_size),
fn_get_split_keys: Some(ffi_get_split_keys),
},
cloud_storage_engine_interfaces: CloudStorageEngineInterfaces {
fn_get_keyspace_encryption: Some(
CloudStorageEngineFFI::ffi_get_keyspace_encryption,
),
fn_get_master_key: Some(CloudStorageEngineFFI::ffi_get_master_key),
},
fn_server_info: None,
fn_make_read_index_task: Some(ffi_make_read_index_task),
fn_make_async_waker: Some(ffi_make_async_waker),
Expand Down
2 changes: 1 addition & 1 deletion raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
#include <cstdint>
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 5455550920944837743ull; }
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 3560036848329077111ull; }
6 changes: 6 additions & 0 deletions raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ struct SSTReaderInterfaces {
RustStrWithViewVec (*fn_get_split_keys)(SSTReaderPtr, uint64_t splits_count);
};

struct CloudStorageEngineInterfaces {
bool (*fn_get_keyspace_encryption)(RaftStoreProxyPtr, uint32_t);
RawCppStringPtr (*fn_get_master_key)(RaftStoreProxyPtr);
};

enum class MsgPBType : uint32_t {
ReadIndexResponse = 0,
ServerInfoResponse,
Expand Down Expand Up @@ -264,6 +269,7 @@ struct RaftStoreProxyFFIHelper {
void (*fn_insert_batch_read_index_resp)(RawVoidPtr, BaseBuffView,
uint64_t)); // To remove
SSTReaderInterfaces sst_reader_interfaces;
CloudStorageEngineInterfaces cloud_storage_engine_interfaces;

uint32_t (*fn_server_info)(RaftStoreProxyPtr, BaseBuffView, RawVoidPtr);
RawRustPtr (*fn_make_read_index_task)(RaftStoreProxyPtr, BaseBuffView);
Expand Down

0 comments on commit 23baffc

Please sign in to comment.