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

Use as less engine_rocks in engine_tiflash as we can #156

Merged
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
2 changes: 1 addition & 1 deletion components/engine_rocks/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rocksdb::{
use crate::raw::Env;

// Use engine::Env directly since Env is not abstracted.
pub fn get_env(
pub(crate) fn get_env(
base_env: Option<Arc<Env>>,
key_manager: Option<Arc<DataKeyManager>>,
) -> std::result::Result<Arc<Env>, String> {
Expand Down
2 changes: 1 addition & 1 deletion components/engine_rocks/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{

#[derive(Clone, Debug)]
pub struct RocksEngine {
pub db: Arc<DB>,
db: Arc<DB>,
shared_block_cache: bool,
}

Expand Down
4 changes: 2 additions & 2 deletions components/raftstore/src/engine_store_ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{
};

use encryption::DataKeyManager;
use engine_rocks::{encryption::get_env, RocksSstIterator, RocksSstReader};
use engine_rocks::{get_env, RocksSstIterator, RocksSstReader};
use engine_traits::{
EncryptionKeyManager, EncryptionMethod, FileEncryptionInfo, Iterator, Peekable, SeekKey,
SstReader, CF_DEFAULT, CF_LOCK, CF_WRITE,
Expand Down Expand Up @@ -663,7 +663,7 @@ pub struct SSTFileReader {

impl SSTFileReader {
fn ffi_get_cf_file_reader(path: &str, key_manager: Option<Arc<DataKeyManager>>) -> RawVoidPtr {
let env = get_env(None, key_manager).unwrap();
let env = get_env(key_manager, None).unwrap();
let sst_reader_res = RocksSstReader::open_with_env(path, Some(env));
match sst_reader_res {
Err(ref e) => tikv_util::error!("Can not open sst file {:?}", e),
Expand Down
2 changes: 1 addition & 1 deletion components/sst_importer/src/sst_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{
/// SstImporter manages SST files that are waiting for ingesting.
pub struct SstImporter {
dir: ImportDir,
pub key_manager: Option<Arc<DataKeyManager>>,
key_manager: Option<Arc<DataKeyManager>>,
switcher: ImportModeSwitcher,
// TODO: lift api_version as a type parameter.
api_version: ApiVersion,
Expand Down
16 changes: 9 additions & 7 deletions engine_tiflash/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ use std::{
},
};

use engine_rocks::{
use engine_rocks::{RocksDBVector, RocksEngineIterator, RocksSnapshot};
use engine_traits::{
Error, IterOptions, Iterable, KvEngine, Peekable, ReadOptions, Result, SyncMutable,
};
use rocksdb::{DBIterator, Writable, DB};

use crate::{
options::RocksReadOptions,
rocks_metrics::{
flush_engine_histogram_metrics, flush_engine_iostall_properties, flush_engine_properties,
Expand All @@ -23,12 +29,7 @@ use engine_rocks::{
ENGINE_HIST_TYPES, ENGINE_TICKER_TYPES, TITAN_ENGINE_HIST_TYPES, TITAN_ENGINE_TICKER_TYPES,
},
util::get_cf_handle,
RocksDBVector, RocksEngineIterator, RocksSnapshot,
};
use engine_traits::{
Error, IterOptions, Iterable, KvEngine, Peekable, ReadOptions, Result, SyncMutable,
};
use rocksdb::{DBIterator, Writable, DB};

pub struct FsStatsExt {
pub used: u64,
Expand All @@ -44,7 +45,8 @@ pub trait FFIHub: FFIHubInner + Send + Sync {}

#[derive(Clone)]
pub struct RocksEngine {
// Must ensure rocks is the first field, for RocksEngine::from_ref
// Must ensure rocks is the first field, for RocksEngine::from_ref.
// We must own a engine_rocks::RocksEngine, since TiKV has not decouple from engine_rocks yet.
pub rocks: engine_rocks::RocksEngine,
pub engine_store_server_helper: isize,
pub pool_capacity: usize,
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ mod ingest {
region_epoch: RegionEpoch,
keys: Vec<String>,
) -> (PathBuf, SstMeta, PathBuf) {
let path = cluster.engines.iter().last().unwrap().1.kv.rocks.path();
let path = cluster.engines.iter().last().unwrap().1.kv.path();
let (import_dir, importer) = create_tmp_importer(&cluster.cfg, path);

// Prepare data
Expand Down