Skip to content

Commit

Permalink
Support RocksDB transaction. (rust-rocksdb#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyuanliu authored Aug 5, 2022
1 parent 934855f commit 2257be1
Show file tree
Hide file tree
Showing 25 changed files with 4,121 additions and 204 deletions.
16 changes: 3 additions & 13 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,8 @@ fn build_rocksdb() {
.trim()
.split('\n')
.map(str::trim)
.collect::<Vec<&'static str>>();

// We have a pregenerated a version of build_version.cc in the local directory
lib_sources = lib_sources
.iter()
.cloned()
.filter(|&file| file != "util/build_version.cc")
// We have a pre-generated a version of build_version.cc in the local directory
.filter(|file| !matches!(*file, "util/build_version.cc"))
.collect::<Vec<&'static str>>();

if target.contains("x86_64") {
Expand Down Expand Up @@ -143,10 +138,6 @@ fn build_rocksdb() {
}
}

if target.contains("aarch64") {
lib_sources.push("util/crc32c_arm64.cc")
}

if target.contains("apple-ios") {
config.define("OS_MACOSX", None);

Expand Down Expand Up @@ -248,8 +239,7 @@ fn build_rocksdb() {
}

for file in lib_sources {
let file = "rocksdb/".to_string() + file;
config.file(&file);
config.file(&format!("rocksdb/{file}"));
}

config.file("build_version.cc");
Expand Down
6 changes: 0 additions & 6 deletions librocksdb-sys/rocksdb_lib_sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ options/options.cc
options/options_helper.cc
options/options_parser.cc
port/port_posix.cc
port/win/env_default.cc
port/win/env_win.cc
port/win/io_win.cc
port/win/port_win.cc
port/win/win_logger.cc
port/win/win_thread.cc
port/stack_trace.cc
table/adaptive/adaptive_table_factory.cc
table/block_based/binary_search_index_reader.cc
Expand Down
4 changes: 2 additions & 2 deletions src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
//

use crate::{ffi, ffi_util::to_cpath, Error, DB};
use crate::{db::DBInner, ffi, ffi_util::to_cpath, Error, DB};

use libc::{c_int, c_uchar};
use std::path::Path;
Expand Down Expand Up @@ -82,7 +82,7 @@ impl BackupEngine {
unsafe {
ffi_try!(ffi::rocksdb_backup_engine_create_new_backup_flush(
self.inner,
db.inner,
db.inner.inner(),
c_uchar::from(flush_before_backup),
));
Ok(())
Expand Down
9 changes: 4 additions & 5 deletions src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
//!
//! [1]: https://github.com/facebook/rocksdb/wiki/Checkpoints
use crate::{ffi, ffi_util::to_cpath, Error, DB};
use std::marker::PhantomData;
use std::path::Path;
use crate::{db::DBInner, ffi, ffi_util::to_cpath, DBCommon, Error, ThreadMode};
use std::{marker::PhantomData, path::Path};

/// Undocumented parameter for `ffi::rocksdb_checkpoint_create` function. Zero by default.
const LOG_SIZE_FOR_FLUSH: u64 = 0_u64;
Expand All @@ -36,11 +35,11 @@ impl<'db> Checkpoint<'db> {
///
/// Does not actually produce checkpoints, call `.create_checkpoint()` method to produce
/// a DB checkpoint.
pub fn new(db: &'db DB) -> Result<Self, Error> {
pub fn new<T: ThreadMode, I: DBInner>(db: &'db DBCommon<T, I>) -> Result<Self, Error> {
let checkpoint: *mut ffi::rocksdb_checkpoint_t;

unsafe {
checkpoint = ffi_try!(ffi::rocksdb_checkpoint_object_create(db.inner));
checkpoint = ffi_try!(ffi::rocksdb_checkpoint_object_create(db.inner.inner()));
}

if checkpoint.is_null() {
Expand Down
Loading

0 comments on commit 2257be1

Please sign in to comment.