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
95300161
Commit
95300161
authored
Dec 17, 2016
by
siddontang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
writebatch support clear and len API
parent
8081edec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
rocksdb.rs
src/rocksdb.rs
+21
-0
No files found.
src/rocksdb.rs
View file @
95300161
...
...
@@ -891,6 +891,20 @@ impl WriteBatch {
pub
fn
is_empty
(
&
self
)
->
bool
{
self
.count
()
==
0
}
pub
fn
len
(
&
self
)
->
usize
{
unsafe
{
let
mut
length
:
usize
=
0
;
let
_
=
rocksdb_ffi
::
rocksdb_writebatch_data
(
self
.inner
,
&
mut
length
);
return
length
;
}
}
pub
fn
clear
(
&
self
)
{
unsafe
{
rocksdb_ffi
::
rocksdb_writebatch_clear
(
self
.inner
);
}
}
}
impl
Drop
for
WriteBatch
{
...
...
@@ -1102,6 +1116,13 @@ mod test {
let
p
=
db
.write
(
batch
);
assert
!
(
p
.is_ok
());
assert
!
(
db
.get
(
b
"k1"
)
.unwrap
()
.is_none
());
let
batch
=
WriteBatch
::
new
();
let
prev_len
=
batch
.len
();
let
_
=
batch
.delete
(
b
"k1"
);
assert
!
(
batch
.len
()
>
0
);
batch
.clear
();
assert_eq!
(
batch
.len
(),
prev_len
);
}
#[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