Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rust-rocksdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
rust-rocksdb
Commits
94c4b0cb
Commit
94c4b0cb
authored
Jul 06, 2017
by
Cholerae Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rocksdb: impl Clone for Options
Signed-off-by:
Cholerae Hu
<
huyingqian@pingcap.com
>
parent
7ad71128
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
3 deletions
+34
-3
c.cc
librocksdb_sys/crocksdb/c.cc
+9
-2
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+2
-1
lib.rs
librocksdb_sys/src/lib.rs
+1
-0
rocksdb_options.rs
src/rocksdb_options.rs
+14
-0
test_rocksdb_options.rs
tests/test_rocksdb_options.rs
+8
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
94c4b0cb
...
...
@@ -112,7 +112,10 @@ struct crocksdb_readoptions_t {
Slice
upper_bound
;
// stack variable to set pointer to in ReadOptions
};
struct
crocksdb_writeoptions_t
{
WriteOptions
rep
;
};
struct
crocksdb_options_t
{
Options
rep
;
};
struct
crocksdb_options_t
{
crocksdb_options_t
()
=
default
;
crocksdb_options_t
(
const
crocksdb_options_t
&
other
)
:
rep
(
other
.
rep
)
{}
Options
rep
;
};
struct
crocksdb_compactoptions_t
{
CompactRangeOptions
rep
;
};
...
...
@@ -1590,7 +1593,11 @@ crocksdb_options_t* crocksdb_options_create() {
return
new
crocksdb_options_t
;
}
void
crocksdb_options_destroy
(
crocksdb_options_t
*
options
)
{
crocksdb_options_t
*
crocksdb_options_copy
(
crocksdb_options_t
*
other
)
{
return
new
crocksdb_options_t
(
*
other
);
}
void
crocksdb_options_destroy
(
const
crocksdb_options_t
*
options
)
{
delete
options
;
}
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
94c4b0cb
...
...
@@ -602,7 +602,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_cuckoo_table_factory(
/* Options */
extern
C_ROCKSDB_LIBRARY_API
crocksdb_options_t
*
crocksdb_options_create
();
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_destroy
(
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
crocksdb_options_t
*
crocksdb_options_copy
(
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_destroy
(
const
crocksdb_options_t
*
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_increase_parallelism
(
crocksdb_options_t
*
opt
,
int
total_threads
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_options_optimize_for_point_lookup
(
...
...
librocksdb_sys/src/lib.rs
View file @
94c4b0cb
...
...
@@ -237,6 +237,7 @@ macro_rules! ffi_try {
extern
"C"
{
pub
fn
crocksdb_get_options_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
)
->
*
mut
DBOptions
;
pub
fn
crocksdb_options_create
()
->
*
mut
DBOptions
;
pub
fn
crocksdb_options_copy
(
opts
:
*
const
DBOptions
)
->
*
mut
DBOptions
;
pub
fn
crocksdb_options_destroy
(
opts
:
*
mut
DBOptions
);
pub
fn
crocksdb_cache_create_lru
(
capacity
:
size_t
)
->
*
mut
DBCache
;
pub
fn
crocksdb_cache_destroy
(
cache
:
*
mut
DBCache
);
...
...
src/rocksdb_options.rs
View file @
94c4b0cb
...
...
@@ -319,6 +319,20 @@ impl Default for Options {
}
}
impl
Clone
for
Options
{
// Only copy DBOptions.
fn
clone
(
&
self
)
->
Self
{
unsafe
{
let
opts
=
crocksdb_ffi
::
crocksdb_options_copy
(
self
.inner
);
assert
!
(
!
opts
.is_null
());
Options
{
inner
:
opts
,
filter
:
None
,
}
}
}
}
impl
Options
{
pub
fn
new
()
->
Options
{
Options
::
default
()
...
...
tests/test_rocksdb_options.rs
View file @
94c4b0cb
...
...
@@ -376,3 +376,11 @@ fn test_get_compression_per_level() {
let
v2
=
opts2
.get_compression_per_level
();
assert_eq!
(
v2
.len
(),
0
);
}
#[test]
fn
test_clone_options
()
{
let
mut
opts
=
Options
::
new
();
opts
.compression
(
DBCompressionType
::
DBSnappy
);
let
opts2
=
opts
.clone
();
assert_eq!
(
opts
.get_compression
(),
opts2
.get_compression
());
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment