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
cf9871d8
Unverified
Commit
cf9871d8
authored
Sep 21, 2020
by
Connor
Committed by
GitHub
Sep 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deleteblobfiles API for titan (#542)
Signed-off-by:
Connor1996
<
zbk602423539@gmail.com
>
parent
41afbae4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
1 deletion
+178
-1
c.cc
librocksdb_sys/crocksdb/c.cc
+54
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+16
-0
titan
librocksdb_sys/libtitan_sys/titan
+1
-1
lib.rs
librocksdb_sys/src/lib.rs
+30
-0
rocksdb.rs
src/rocksdb.rs
+73
-0
test_titan.rs
tests/cases/test_titan.rs
+4
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
cf9871d8
...
...
@@ -5858,4 +5858,58 @@ void ctitandb_delete_files_in_ranges_cf(
static_cast
<
TitanDB
*>
(
db
->
rep
)
->
DeleteFilesInRanges
(
cf
->
rep
,
&
ranges
[
0
],
num_ranges
,
include_end
));
}
void
ctitandb_delete_blob_files_in_range
(
crocksdb_t
*
db
,
const
char
*
start_key
,
size_t
start_key_len
,
const
char
*
limit_key
,
size_t
limit_key_len
,
unsigned
char
include_end
,
char
**
errptr
)
{
Slice
a
,
b
;
RangePtr
range
(
start_key
?
(
a
=
Slice
(
start_key
,
start_key_len
),
&
a
)
:
nullptr
,
limit_key
?
(
b
=
Slice
(
limit_key
,
limit_key_len
),
&
b
)
:
nullptr
);
SaveError
(
errptr
,
static_cast
<
TitanDB
*>
(
db
->
rep
)
->
DeleteBlobFilesInRanges
(
db
->
rep
->
DefaultColumnFamily
(),
&
range
,
1
,
include_end
));
}
void
ctitandb_delete_blob_files_in_range_cf
(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
column_family
,
const
char
*
start_key
,
size_t
start_key_len
,
const
char
*
limit_key
,
size_t
limit_key_len
,
unsigned
char
include_end
,
char
**
errptr
)
{
Slice
a
,
b
;
RangePtr
range
(
start_key
?
(
a
=
Slice
(
start_key
,
start_key_len
),
&
a
)
:
nullptr
,
limit_key
?
(
b
=
Slice
(
limit_key
,
limit_key_len
),
&
b
)
:
nullptr
);
SaveError
(
errptr
,
static_cast
<
TitanDB
*>
(
db
->
rep
)
->
DeleteBlobFilesInRanges
(
column_family
->
rep
,
&
range
,
1
,
include_end
));
}
void
ctitandb_delete_blob_files_in_ranges_cf
(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
cf
,
const
char
*
const
*
start_keys
,
const
size_t
*
start_keys_lens
,
const
char
*
const
*
limit_keys
,
const
size_t
*
limit_keys_lens
,
size_t
num_ranges
,
unsigned
char
include_end
,
char
**
errptr
)
{
std
::
vector
<
Slice
>
starts
(
num_ranges
);
std
::
vector
<
Slice
>
limits
(
num_ranges
);
std
::
vector
<
RangePtr
>
ranges
(
num_ranges
);
for
(
auto
i
=
0
;
i
<
num_ranges
;
i
++
)
{
const
Slice
*
start
=
nullptr
;
if
(
start_keys
[
i
])
{
starts
[
i
]
=
Slice
(
start_keys
[
i
],
start_keys_lens
[
i
]);
start
=
&
starts
[
i
];
}
const
Slice
*
limit
=
nullptr
;
if
(
limit_keys
[
i
])
{
limits
[
i
]
=
Slice
(
limit_keys
[
i
],
limit_keys_lens
[
i
]);
limit
=
&
limits
[
i
];
}
ranges
[
i
]
=
RangePtr
(
start
,
limit
);
}
SaveError
(
errptr
,
static_cast
<
TitanDB
*>
(
db
->
rep
)
->
DeleteBlobFilesInRanges
(
cf
->
rep
,
&
ranges
[
0
],
num_ranges
,
include_end
));
}
}
// end extern "C"
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
cf9871d8
...
...
@@ -2312,6 +2312,22 @@ extern C_ROCKSDB_LIBRARY_API void ctitandb_delete_files_in_ranges_cf(
const
char
*
const
*
limit_keys
,
const
size_t
*
limit_keys_lens
,
size_t
num_ranges
,
unsigned
char
include_end
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
ctitandb_delete_blob_files_in_range
(
crocksdb_t
*
db
,
const
char
*
start_key
,
size_t
start_key_len
,
const
char
*
limit_key
,
size_t
limit_key_len
,
unsigned
char
include_end
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
ctitandb_delete_blob_files_in_range_cf
(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
column_family
,
const
char
*
start_key
,
size_t
start_key_len
,
const
char
*
limit_key
,
size_t
limit_key_len
,
unsigned
char
include_end
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
ctitandb_delete_blob_files_in_ranges_cf
(
crocksdb_t
*
db
,
crocksdb_column_family_handle_t
*
cf
,
const
char
*
const
*
start_keys
,
const
size_t
*
start_keys_lens
,
const
char
*
const
*
limit_keys
,
const
size_t
*
limit_keys_lens
,
size_t
num_ranges
,
unsigned
char
include_end
,
char
**
errptr
);
#ifdef __cplusplus
}
/* end extern "C" */
#endif
...
...
titan
@
28717a8b
Subproject commit
81814eced9a1fd035274b85398f99b626cd10d6
4
Subproject commit
28717a8b5681d00e648bff8edafc09a9ce7e018
4
librocksdb_sys/src/lib.rs
View file @
cf9871d8
...
...
@@ -2293,6 +2293,36 @@ extern "C" {
include_end
:
bool
,
errptr
:
*
mut
*
mut
c_char
,
);
pub
fn
ctitandb_delete_blob_files_in_range
(
db
:
*
mut
DBInstance
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
include_end
:
bool
,
err
:
*
mut
*
mut
c_char
,
);
pub
fn
ctitandb_delete_blob_files_in_range_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
range_start_key
:
*
const
u8
,
range_start_key_len
:
size_t
,
range_limit_key
:
*
const
u8
,
range_limit_key_len
:
size_t
,
include_end
:
bool
,
err
:
*
mut
*
mut
c_char
,
);
pub
fn
ctitandb_delete_blob_files_in_ranges_cf
(
db
:
*
mut
DBInstance
,
cf
:
*
mut
DBCFHandle
,
start_keys
:
*
const
*
const
u8
,
start_keys_lens
:
*
const
size_t
,
limit_keys
:
*
const
*
const
u8
,
limit_keys_lens
:
*
const
size_t
,
num_ranges
:
size_t
,
include_end
:
bool
,
errptr
:
*
mut
*
mut
c_char
,
);
}
#[cfg(test)]
...
...
src/rocksdb.rs
View file @
cf9871d8
...
...
@@ -1403,6 +1403,79 @@ impl DB {
Ok
(())
}
pub
fn
delete_blob_files_in_range
(
&
self
,
start_key
:
&
[
u8
],
end_key
:
&
[
u8
],
include_end
:
bool
,
)
->
Result
<
(),
String
>
{
unsafe
{
if
self
.is_titan
()
{
ffi_try!
(
ctitandb_delete_blob_files_in_range
(
self
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
,
include_end
));
}
Ok
(())
}
}
pub
fn
delete_blob_files_in_range_cf
(
&
self
,
cf
:
&
CFHandle
,
start_key
:
&
[
u8
],
end_key
:
&
[
u8
],
include_end
:
bool
,
)
->
Result
<
(),
String
>
{
unsafe
{
if
self
.is_titan
()
{
ffi_try!
(
ctitandb_delete_blob_files_in_range_cf
(
self
.inner
,
cf
.inner
,
start_key
.as_ptr
(),
start_key
.len
()
as
size_t
,
end_key
.as_ptr
(),
end_key
.len
()
as
size_t
,
include_end
));
}
Ok
(())
}
}
pub
fn
delete_blob_files_in_ranges_cf
(
&
self
,
cf
:
&
CFHandle
,
ranges
:
&
[
Range
],
include_end
:
bool
,
)
->
Result
<
(),
String
>
{
unsafe
{
if
self
.is_titan
()
{
let
start_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
.map
(|
x
|
x
.start_key
.as_ptr
())
.collect
();
let
start_keys_lens
:
Vec
<
_
>
=
ranges
.iter
()
.map
(|
x
|
x
.start_key
.len
())
.collect
();
let
limit_keys
:
Vec
<*
const
u8
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.as_ptr
())
.collect
();
let
limit_keys_lens
:
Vec
<
_
>
=
ranges
.iter
()
.map
(|
x
|
x
.end_key
.len
())
.collect
();
ffi_try!
(
ctitandb_delete_blob_files_in_ranges_cf
(
self
.inner
,
cf
.inner
,
start_keys
.as_ptr
(),
start_keys_lens
.as_ptr
(),
limit_keys
.as_ptr
(),
limit_keys_lens
.as_ptr
(),
ranges
.len
(),
include_end
));
}
}
Ok
(())
}
pub
fn
get_property_value
(
&
self
,
name
:
&
str
)
->
Option
<
String
>
{
self
.get_property_value_cf_opt
(
None
,
name
)
}
...
...
tests/cases/test_titan.rs
View file @
cf9871d8
...
...
@@ -287,6 +287,8 @@ fn test_titan_delete_files_in_ranges() {
db
.delete_files_in_ranges_cf
(
cf_handle
,
&
ranges
,
false
)
.unwrap
();
db
.delete_blob_files_in_ranges_cf
(
cf_handle
,
&
ranges
,
false
)
.unwrap
();
// Check that ["key0", "key5"] have been deleted, but ["key6", "key8"] still exist.
let
mut
readopts
=
ReadOptions
::
new
();
...
...
@@ -305,6 +307,8 @@ fn test_titan_delete_files_in_ranges() {
let
ranges
=
vec!
[
Range
::
new
(
b
"key6"
,
b
"key8"
)];
db
.delete_files_in_ranges_cf
(
cf_handle
,
&
ranges
,
true
)
.unwrap
();
db
.delete_blob_files_in_ranges_cf
(
cf_handle
,
&
ranges
,
true
)
.unwrap
();
let
mut
iter
=
db
.iter
();
iter
.seek
(
SeekKey
::
Start
)
.unwrap
();
assert
!
(
!
iter
.valid
()
.unwrap
());
...
...
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