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
035db162
Unverified
Commit
035db162
authored
Dec 03, 2021
by
Xintao
Committed by
GitHub
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete_file interface (#670)
Signed-off-by:
Xintao
<
hunterlxt@live.com
>
parent
4dd1d667
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
5 deletions
+20
-5
c.cc
librocksdb_sys/crocksdb/c.cc
+2
-2
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+4
-3
lib.rs
librocksdb_sys/src/lib.rs
+1
-0
rocksdb.rs
src/rocksdb.rs
+8
-0
test_event_listener.rs
tests/cases/test_event_listener.rs
+5
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
035db162
...
...
@@ -1335,8 +1335,8 @@ void crocksdb_approximate_memtable_stats_cf(
db
->
rep
->
GetApproximateMemTableStats
(
cf
->
rep
,
range
,
count
,
size
);
}
void
crocksdb_delete_file
(
crocksdb_t
*
db
,
const
char
*
name
)
{
db
->
rep
->
DeleteFile
(
name
);
void
crocksdb_delete_file
(
crocksdb_t
*
db
,
const
char
*
name
,
char
**
errptr
)
{
SaveError
(
errptr
,
db
->
rep
->
DeleteFile
(
name
)
);
}
const
crocksdb_livefiles_t
*
crocksdb_livefiles
(
crocksdb_t
*
db
)
{
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
035db162
...
...
@@ -509,7 +509,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_compact_range_cf_opt(
const
char
*
limit_key
,
size_t
limit_key_len
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_delete_file
(
crocksdb_t
*
db
,
const
char
*
name
);
const
char
*
name
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
const
crocksdb_livefiles_t
*
crocksdb_livefiles
(
crocksdb_t
*
db
);
...
...
@@ -1884,8 +1885,8 @@ crocksdb_fifo_compaction_options_set_allow_compaction(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_fifo_compaction_options_destroy
(
crocksdb_fifo_compaction_options_t
*
fifo_opts
);
extern
C_ROCKSDB_LIBRARY_API
size_t
crocksdb_livefiles_count
(
const
crocksdb_livefiles_t
*
);
extern
C_ROCKSDB_LIBRARY_API
size_t
crocksdb_livefiles_count
(
const
crocksdb_livefiles_t
*
);
extern
C_ROCKSDB_LIBRARY_API
const
char
*
crocksdb_livefiles_name
(
const
crocksdb_livefiles_t
*
,
int
index
);
extern
C_ROCKSDB_LIBRARY_API
int
crocksdb_livefiles_level
(
...
...
librocksdb_sys/src/lib.rs
View file @
035db162
...
...
@@ -1493,6 +1493,7 @@ extern "C" {
limit_key
:
*
const
u8
,
limit_key_len
:
size_t
,
);
pub
fn
crocksdb_delete_file
(
db
:
*
mut
DBInstance
,
name
:
*
const
c_char
,
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_delete_files_in_range
(
db
:
*
mut
DBInstance
,
range_start_key
:
*
const
u8
,
...
...
src/rocksdb.rs
View file @
035db162
...
...
@@ -1364,6 +1364,14 @@ impl DB {
}
}
pub
fn
delete_file
(
&
self
,
path
:
&
str
)
->
Result
<
(),
String
>
{
unsafe
{
let
file_path
=
CString
::
new
(
path
)
.unwrap
();
ffi_try!
(
crocksdb_delete_file
(
self
.inner
,
file_path
.as_ptr
()));
Ok
(())
}
}
pub
fn
delete_files_in_range
(
&
self
,
start_key
:
&
[
u8
],
...
...
tests/cases/test_event_listener.rs
View file @
035db162
...
...
@@ -257,6 +257,11 @@ fn test_event_listener_ingestion() {
assert_eq!
(
db
.get
(
b
"k1"
)
.unwrap
()
.unwrap
(),
b
"v1"
);
assert_eq!
(
db
.get
(
b
"k2"
)
.unwrap
()
.unwrap
(),
b
"v2"
);
assert_ne!
(
counter
.ingestion
.load
(
Ordering
::
SeqCst
),
0
);
let
files
=
db
.get_live_files
();
assert
!
(
test_sstfile
.exists
());
assert
!
(
db
.delete_file
(
&
files
.get_name
(
0
))
.is_ok
());
assert
!
(
db
.get
(
b
"k1"
)
.unwrap
()
.is_none
());
assert
!
(
db
.get
(
b
"k2"
)
.unwrap
()
.is_none
());
}
#[test]
...
...
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