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

Remove need for &mut self in create_cf and drop_cf (v2) #506

Merged
merged 31 commits into from Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f6eafe1
Use RwLock
carllin Jan 28, 2021
123d613
Update create_cf
CriesofCarrots Feb 11, 2021
0ead892
Test fixup
carllin Feb 12, 2021
c51484c
Add multithread column family map option
carllin Feb 26, 2021
0f5a3cf
Add comments/cleanup
carllin Mar 2, 2021
e88da39
Plumb is_multithreaded through constructors
carllin Mar 2, 2021
c1a203e
Fix tests
carllin Mar 2, 2021
1fc975f
Add multithreaded test for column families
carllin Mar 2, 2021
728b349
Remove clone of handle
carllin Mar 4, 2021
ac09e75
Rework test
carllin Mar 10, 2021
441834e
Revert references
carllin Mar 10, 2021
a6b5366
Add comment
carllin Mar 10, 2021
9f0fb18
Merge branch 'master' into DropCf
Mar 19, 2021
1be386d
Encode single/multi threading into types
ryoqun Mar 24, 2021
78aeab5
Finish off implementing and cleaning
ryoqun Mar 25, 2021
6c9fce8
Fix ci
ryoqun Mar 27, 2021
2ce61ec
Further fix ci
ryoqun Mar 27, 2021
9999360
Further tweak ci actions
ryoqun Mar 27, 2021
82e57d1
Fix typo
ryoqun Mar 27, 2021
42bdf42
Update rust.yml
Mar 29, 2021
67a180a
Impl Send for BoundCF & add type alias for compat
ryoqun Mar 30, 2021
c722e16
Replace all remaining &CF with impl CFRef
ryoqun Mar 30, 2021
4016943
Expose compile-time handy ColumnFamilyRef alias
ryoqun Mar 30, 2021
d687029
Tweaks
ryoqun Mar 30, 2021
61f323b
Remove unneeded cfgs...
ryoqun Mar 30, 2021
7a16581
Rename InternalDbAdapter => DbAccess
ryoqun Apr 6, 2021
f8c7fd4
Rename: map => cfs
ryoqun Apr 6, 2021
a590597
Rename: multi-threaded-as-default => multi-threaded-cf-alteration
ryoqun Apr 6, 2021
1a11b5f
Remove unsafe from trait definition
ryoqun Apr 6, 2021
2cfe746
Improve docs
ryoqun Apr 6, 2021
9fd26a3
Test error by creating CFs via SingleThreaded &ref
ryoqun Apr 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/rust.yml
Expand Up @@ -88,7 +88,14 @@ jobs:
with:
command: test
args: --manifest-path=librocksdb-sys/Cargo.toml
- name: Run rocksdb tests
- name: Run rocksdb tests (single-threaded cf alterations)
uses: actions-rs/cargo@v1
with:
command: test
- name: Run rocksdb tests (multi-threaded cf alterations)
uses: actions-rs/cargo@v1
env:
RUSTFLAGS=-Awarnings # Suppress "variable does not need to be mutable" warnings
with:
command: test
args: --features multi-threaded-as-default
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -24,6 +24,7 @@ lz4 = ["librocksdb-sys/lz4"]
zstd = ["librocksdb-sys/zstd"]
zlib = ["librocksdb-sys/zlib"]
bzip2 = ["librocksdb-sys/bzip2"]
multi-threaded-as-default = []
ryoqun marked this conversation as resolved.
Show resolved Hide resolved

[dependencies]
libc = "0.2"
Expand Down
4 changes: 2 additions & 2 deletions src/backup.rs
Expand Up @@ -235,7 +235,7 @@ impl Default for BackupEngineOptions {
unsafe {
let opts = ffi::rocksdb_options_create();
if opts.is_null() {
panic!("Could not create RocksDB backup options".to_owned());
panic!("Could not create RocksDB backup options");
}
BackupEngineOptions { inner: opts }
}
Expand All @@ -247,7 +247,7 @@ impl Default for RestoreOptions {
unsafe {
let opts = ffi::rocksdb_restore_options_create();
if opts.is_null() {
panic!("Could not create RocksDB restore options".to_owned());
panic!("Could not create RocksDB restore options");
}
RestoreOptions { inner: opts }
}
Expand Down
29 changes: 28 additions & 1 deletion src/column_family.rs
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{ffi, Options};
use crate::{db::MultiThreaded, ffi, Options};

/// The name of the default column family.
///
Expand Down Expand Up @@ -48,3 +48,30 @@ pub struct ColumnFamily {
}

unsafe impl Send for ColumnFamily {}

/// A specialized opaque type used to represent a column family. Used for multi-threaded
/// mode. Clone (and Copy) is derived to behave like &ColumnFamily (used for
/// single-threaded). Clone/Copy is safe because this lifetime is bound to DB like
ryoqun marked this conversation as resolved.
Show resolved Hide resolved
/// iterators/snapshots. On top of it, this is as cheap and small as &ColumnFamily because
/// this only has a single pointer-wide field.
#[derive(Clone, Copy)]
pub struct BoundColumnFamily<'a> {
pub(crate) inner: *mut ffi::rocksdb_column_family_handle_t,
pub(crate) multi_threaded_cfs: std::marker::PhantomData<&'a MultiThreaded>,
}

pub trait ColumnFamilyRef {
fn inner(&self) -> *mut ffi::rocksdb_column_family_handle_t;
}

impl<'a> ColumnFamilyRef for &'a ColumnFamily {
fn inner(&self) -> *mut ffi::rocksdb_column_family_handle_t {
self.inner
}
}

impl<'a> ColumnFamilyRef for BoundColumnFamily<'a> {
fn inner(&self) -> *mut ffi::rocksdb_column_family_handle_t {
self.inner
}
}