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
54347ecf
Commit
54347ecf
authored
May 25, 2016
by
siddontang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: add delete file in range
parent
ed089679
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
6 deletions
+77
-6
Cargo.toml
librocksdb_sys/Cargo.toml
+2
-0
lib.rs
librocksdb_sys/src/lib.rs
+29
-5
rocksdb.rs
src/rocksdb.rs
+46
-1
No files found.
librocksdb_sys/Cargo.toml
View file @
54347ecf
...
...
@@ -5,3 +5,4 @@ authors = ["Jay Lee <busyjaylee@gmail.com>"]
[dependencies]
libc
=
"0.1.8"
tempdir
=
"0.3"
\ No newline at end of file
librocksdb_sys/src/lib.rs
View file @
54347ecf
...
...
@@ -147,7 +147,8 @@ extern "C" {
pub
fn
rocksdb_options_set_bytes_per_sync
(
options
:
DBOptions
,
bytes
:
u64
);
pub
fn
rocksdb_options_set_disable_data_sync
(
options
:
DBOptions
,
v
:
c_int
);
pub
fn
rocksdb_options_set_allow_os_buffer
(
options
:
DBOptions
,
is_allow
:
bool
);
pub
fn
rocksdb_options_set_allow_os_buffer
(
options
:
DBOptions
,
is_allow
:
bool
);
pub
fn
rocksdb_options_optimize_for_point_lookup
(
options
:
DBOptions
,
block_cache_size_mb
:
u64
);
pub
fn
rocksdb_options_set_table_cache_numshardbits
(
options
:
DBOptions
,
...
...
@@ -168,7 +169,8 @@ extern "C" {
bytes
:
u64
);
pub
fn
rocksdb_options_set_target_file_size_multiplier
(
options
:
DBOptions
,
mul
:
c_int
);
pub
fn
rocksdb_options_set_max_bytes_for_level_base
(
options
:
DBOptions
,
bytes
:
u64
);
pub
fn
rocksdb_options_set_max_bytes_for_level_base
(
options
:
DBOptions
,
bytes
:
u64
);
pub
fn
rocksdb_options_set_max_bytes_for_level_multiplier
(
options
:
DBOptions
,
mul
:
c_int
);
pub
fn
rocksdb_options_set_max_log_file_size
(
options
:
DBOptions
,
bytes
:
u64
);
...
...
@@ -443,13 +445,27 @@ extern "C" {
range_limit_key
:
*
const
*
const
u8
,
range_limit_key_len
:
*
const
size_t
,
sizes
:
*
mut
uint64_t
);
pub
fn
rocksdb_delete_file_in_range
(
db
:
DBInstance
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
const
i8
);
pub
fn
rocksdb_delete_file_in_range_cf
(
db
:
DBInstance
,
cf
:
DBCFHandle
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
err
:
*
mut
*
const
i8
);
}
#[cfg(test)]
mod
test
{
use
super
::
*
;
use
std
::
ffi
::
CString
;
use
tempdir
::
TempDir
;
extern
crate
tempdir
;
use
self
::
tempdir
::
TempDir
;
#[test]
fn
internal
()
{
...
...
@@ -462,9 +478,9 @@ mod test {
rocksdb_options_set_create_if_missing
(
opts
,
true
);
let
rustpath
=
TempDir
::
new
(
"_rust_rocksdb_internaltest"
)
.expect
(
""
);
.expect
(
""
);
let
cpath
=
CString
::
new
(
rustpath
.path
()
.to_str
()
.unwrap
())
.unwrap
();
.unwrap
();
let
cpath_ptr
=
cpath
.as_ptr
();
let
mut
err
=
0
as
*
const
i8
;
...
...
@@ -517,6 +533,14 @@ mod test {
assert_eq!
(
sizes
.len
(),
1
);
assert
!
(
sizes
[
0
]
>
0
);
rocksdb_delete_file_in_range
(
db
,
b
"
\x00\x00
"
.as_ptr
(),
2
,
b
"
\xff\x00
"
.as_ptr
(),
2
,
&
mut
err
);
assert
!
(
err
.is_null
(),
error_message
(
err
));
rocksdb_close
(
db
);
rocksdb_destroy_db
(
opts
,
cpath_ptr
,
&
mut
err
);
assert
!
(
err
.is_null
());
...
...
src/rocksdb.rs
View file @
54347ecf
...
...
@@ -812,6 +812,50 @@ impl DB {
}
sizes
}
pub
fn
delete_file_in_range
(
&
self
,
start_key
:
&
[
u8
],
limit_key
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
let
mut
err
:
*
const
i8
=
0
as
*
const
i8
;
let
err_ptr
:
*
mut
*
const
i8
=
&
mut
err
;
rocksdb_ffi
::
rocksdb_delete_file_in_range
(
self
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
limit_key
.as_ptr
(),
limit_key
.len
()
as
size_t
,
err_ptr
);
if
!
err
.is_null
()
{
return
Err
(
error_message
(
err
));
}
Ok
(())
}
}
pub
fn
delete_file_in_range_cf
(
&
self
,
cf
:
DBCFHandle
,
start_key
:
&
[
u8
],
limit_key
:
&
[
u8
])
->
Result
<
(),
String
>
{
unsafe
{
let
mut
err
:
*
const
i8
=
0
as
*
const
i8
;
let
err_ptr
:
*
mut
*
const
i8
=
&
mut
err
;
rocksdb_ffi
::
rocksdb_delete_file_in_range_cf
(
self
.inner
,
cf
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
limit_key
.as_ptr
(),
limit_key
.len
()
as
size_t
,
err_ptr
);
if
!
err
.is_null
()
{
return
Err
(
error_message
(
err
));
}
Ok
(())
}
}
}
impl
Writable
for
DB
{
...
...
@@ -1143,4 +1187,4 @@ fn snapshot_test() {
}
let
opts
=
Options
::
new
();
assert
!
(
DB
::
destroy
(
&
opts
,
path
)
.is_ok
());
}
}
\ No newline at end of file
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