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
e340fdda
Commit
e340fdda
authored
Jun 22, 2016
by
siddontang
Committed by
GitHub
Jun 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22 from siddontang/siddontang/writebatch-count
support writebatch count
parents
7de3c903
98ebc5d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
rocksdb.rs
src/rocksdb.rs
+14
-0
No files found.
src/rocksdb.rs
View file @
e340fdda
...
...
@@ -960,6 +960,14 @@ impl WriteBatch {
pub
fn
new
()
->
WriteBatch
{
WriteBatch
::
default
()
}
pub
fn
count
(
&
self
)
->
usize
{
unsafe
{
rocksdb_ffi
::
rocksdb_writebatch_count
(
self
.inner
)
as
usize
}
}
pub
fn
is_empty
(
&
self
)
->
bool
{
self
.count
()
==
0
}
}
impl
Drop
for
WriteBatch
{
...
...
@@ -1162,7 +1170,11 @@ mod test {
// test put
let
batch
=
WriteBatch
::
new
();
assert
!
(
db
.get
(
b
"k1"
)
.unwrap
()
.is_none
());
assert_eq!
(
batch
.count
(),
0
);
assert
!
(
batch
.is_empty
());
let
_
=
batch
.put
(
b
"k1"
,
b
"v1111"
);
assert_eq!
(
batch
.count
(),
1
);
assert
!
(
!
batch
.is_empty
());
assert
!
(
db
.get
(
b
"k1"
)
.unwrap
()
.is_none
());
let
p
=
db
.write
(
batch
);
assert
!
(
p
.is_ok
());
...
...
@@ -1172,6 +1184,8 @@ mod test {
// test delete
let
batch
=
WriteBatch
::
new
();
let
_
=
batch
.delete
(
b
"k1"
);
assert_eq!
(
batch
.count
(),
1
);
assert
!
(
!
batch
.is_empty
());
let
p
=
db
.write
(
batch
);
assert
!
(
p
.is_ok
());
assert
!
(
db
.get
(
b
"k1"
)
.unwrap
()
.is_none
());
...
...
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