Unverified Commit 77575fa7 authored by Tong Zhigao's avatar Tong Zhigao Committed by GitHub

Add run_ldb_tool; (#232)

Signed-off-by: 's avatarTong Zhigao <tongzhigao@pingcap.com>
parent 5c9bcda8
......@@ -17,6 +17,7 @@
#include "rocksdb/env.h"
#include "rocksdb/filter_policy.h"
#include "rocksdb/iterator.h"
#include "rocksdb/ldb_tool.h"
#include "rocksdb/listener.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/merge_operator.h"
......@@ -145,6 +146,7 @@ using rocksdb::CompactionOptions;
using rocksdb::PerfLevel;
using rocksdb::PerfContext;
using rocksdb::BottommostLevelCompaction;
using rocksdb::LDBTool;
using std::shared_ptr;
......@@ -4680,4 +4682,8 @@ uint64_t crocksdb_perf_context_env_new_logger_nanos(crocksdb_perf_context_t* ctx
return ctx->rep.env_new_logger_nanos;
}
void crocksdb_run_ldb_tool(int argc, char** argv) {
LDBTool().Run(argc, argv);
}
} // end extern "C"
......@@ -1882,6 +1882,8 @@ extern C_ROCKSDB_LIBRARY_API uint64_t
crocksdb_perf_context_env_unlock_file_nanos(crocksdb_perf_context_t*);
extern C_ROCKSDB_LIBRARY_API uint64_t
crocksdb_perf_context_env_new_logger_nanos(crocksdb_perf_context_t*);
extern C_ROCKSDB_LIBRARY_API void
crocksdb_run_ldb_tool(int argc, char** argv);
#ifdef __cplusplus
} /* end extern "C" */
......
......@@ -1674,6 +1674,7 @@ extern "C" {
pub fn crocksdb_perf_context_env_lock_file_nanos(ctx: *mut DBPerfContext) -> u64;
pub fn crocksdb_perf_context_env_unlock_file_nanos(ctx: *mut DBPerfContext) -> u64;
pub fn crocksdb_perf_context_env_new_logger_nanos(ctx: *mut DBPerfContext) -> u64;
pub fn crocksdb_run_ldb_tool(argc: c_int, argv: *const *const c_char);
}
#[cfg(test)]
......
......@@ -33,9 +33,9 @@ pub use merge_operator::MergeOperands;
pub use metadata::{ColumnFamilyMetaData, LevelMetaData, SstFileMetaData};
pub use perf_context::{get_perf_level, set_perf_level, PerfContext, PerfLevel};
pub use rocksdb::{
load_latest_options, set_external_sst_file_global_seq_no, BackupEngine, CFHandle, DBIterator,
DBVector, Env, ExternalSstFileInfo, Kv, Range, SeekKey, SequentialFile, SstFileWriter,
Writable, WriteBatch, DB,
load_latest_options, run_ldb_tool, set_external_sst_file_global_seq_no, BackupEngine, CFHandle,
DBIterator, DBVector, Env, ExternalSstFileInfo, Kv, Range, SeekKey, SequentialFile,
SstFileWriter, Writable, WriteBatch, DB,
};
pub use rocksdb_options::{
BlockBasedOptions, CColumnFamilyDescriptor, ColumnFamilyOptions, CompactOptions,
......
......@@ -2204,6 +2204,20 @@ pub fn load_latest_options(
}
}
pub fn run_ldb_tool(ldb_args: &Vec<String>) {
unsafe {
let ldb_args_cstrs: Vec<_> = ldb_args
.iter()
.map(|s| CString::new(s.as_bytes()).unwrap())
.collect();
let args: Vec<_> = ldb_args_cstrs.iter().map(|s| s.as_ptr()).collect();
crocksdb_ffi::crocksdb_run_ldb_tool(
args.len() as i32,
args.as_ptr() as *const *const c_char,
);
}
}
#[cfg(test)]
mod test {
use super::*;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment