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
b196e4dd
Commit
b196e4dd
authored
May 16, 2017
by
zhangjinpeng1987
Committed by
ShuYu Wang
May 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
writebatch with capacity (#58)
parent
5e80fbd4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
1 deletion
+26
-1
c.cc
librocksdb_sys/crocksdb/c.cc
+6
-0
c.h
librocksdb_sys/crocksdb/rocksdb/c.h
+2
-0
lib.rs
librocksdb_sys/src/lib.rs
+3
-1
rocksdb.rs
src/rocksdb.rs
+15
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
b196e4dd
...
@@ -1145,6 +1145,12 @@ crocksdb_writebatch_t* crocksdb_writebatch_create() {
...
@@ -1145,6 +1145,12 @@ crocksdb_writebatch_t* crocksdb_writebatch_create() {
return
new
crocksdb_writebatch_t
;
return
new
crocksdb_writebatch_t
;
}
}
crocksdb_writebatch_t
*
crocksdb_writebatch_create_with_capacity
(
size_t
reserved_bytes
)
{
crocksdb_writebatch_t
*
b
=
new
crocksdb_writebatch_t
;
b
->
rep
=
WriteBatch
(
reserved_bytes
);
return
b
;
}
crocksdb_writebatch_t
*
crocksdb_writebatch_create_from
(
const
char
*
rep
,
crocksdb_writebatch_t
*
crocksdb_writebatch_create_from
(
const
char
*
rep
,
size_t
size
)
{
size_t
size
)
{
crocksdb_writebatch_t
*
b
=
new
crocksdb_writebatch_t
;
crocksdb_writebatch_t
*
b
=
new
crocksdb_writebatch_t
;
...
...
librocksdb_sys/crocksdb/rocksdb/c.h
View file @
b196e4dd
...
@@ -404,6 +404,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_iter_get_error(
...
@@ -404,6 +404,8 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_iter_get_error(
/* Write batch */
/* Write batch */
extern
C_ROCKSDB_LIBRARY_API
crocksdb_writebatch_t
*
crocksdb_writebatch_create
();
extern
C_ROCKSDB_LIBRARY_API
crocksdb_writebatch_t
*
crocksdb_writebatch_create
();
extern
C_ROCKSDB_LIBRARY_API
crocksdb_writebatch_t
*
crocksdb_writebatch_create_with_capacity
(
size_t
reserved_bytes
);
extern
C_ROCKSDB_LIBRARY_API
crocksdb_writebatch_t
*
crocksdb_writebatch_create_from
(
extern
C_ROCKSDB_LIBRARY_API
crocksdb_writebatch_t
*
crocksdb_writebatch_create_from
(
const
char
*
rep
,
size_t
size
);
const
char
*
rep
,
size_t
size
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_writebatch_destroy
(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_writebatch_destroy
(
...
...
librocksdb_sys/src/lib.rs
View file @
b196e4dd
...
@@ -222,7 +222,8 @@ extern "C" {
...
@@ -222,7 +222,8 @@ extern "C" {
pub
fn
crocksdb_options_optimize_for_point_lookup
(
options
:
*
mut
DBOptions
,
pub
fn
crocksdb_options_optimize_for_point_lookup
(
options
:
*
mut
DBOptions
,
block_cache_size_mb
:
u64
);
block_cache_size_mb
:
u64
);
pub
fn
crocksdb_options_set_table_cache_numshardbits
(
options
:
*
mut
DBOptions
,
bits
:
c_int
);
pub
fn
crocksdb_options_set_table_cache_numshardbits
(
options
:
*
mut
DBOptions
,
bits
:
c_int
);
pub
fn
crocksdb_options_set_writable_file_max_buffer_size
(
options
:
*
mut
DBOptions
,
nbytes
:
c_int
);
pub
fn
crocksdb_options_set_writable_file_max_buffer_size
(
options
:
*
mut
DBOptions
,
nbytes
:
c_int
);
pub
fn
crocksdb_options_set_max_write_buffer_number
(
options
:
*
mut
DBOptions
,
bufno
:
c_int
);
pub
fn
crocksdb_options_set_max_write_buffer_number
(
options
:
*
mut
DBOptions
,
bufno
:
c_int
);
pub
fn
crocksdb_options_set_min_write_buffer_number_to_merge
(
options
:
*
mut
DBOptions
,
pub
fn
crocksdb_options_set_min_write_buffer_number_to_merge
(
options
:
*
mut
DBOptions
,
bufno
:
c_int
);
bufno
:
c_int
);
...
@@ -475,6 +476,7 @@ extern "C" {
...
@@ -475,6 +476,7 @@ extern "C" {
batch
:
*
mut
DBWriteBatch
,
batch
:
*
mut
DBWriteBatch
,
err
:
*
mut
*
mut
c_char
);
err
:
*
mut
*
mut
c_char
);
pub
fn
crocksdb_writebatch_create
()
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_create
()
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_create_with_capacity
(
cap
:
size_t
)
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_create_from
(
rep
:
*
const
u8
,
size
:
size_t
)
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_create_from
(
rep
:
*
const
u8
,
size
:
size_t
)
->
*
mut
DBWriteBatch
;
pub
fn
crocksdb_writebatch_destroy
(
batch
:
*
mut
DBWriteBatch
);
pub
fn
crocksdb_writebatch_destroy
(
batch
:
*
mut
DBWriteBatch
);
pub
fn
crocksdb_writebatch_clear
(
batch
:
*
mut
DBWriteBatch
);
pub
fn
crocksdb_writebatch_clear
(
batch
:
*
mut
DBWriteBatch
);
...
...
src/rocksdb.rs
View file @
b196e4dd
...
@@ -1103,6 +1103,10 @@ impl WriteBatch {
...
@@ -1103,6 +1103,10 @@ impl WriteBatch {
WriteBatch
::
default
()
WriteBatch
::
default
()
}
}
pub
fn
with_capacity
(
cap
:
usize
)
->
WriteBatch
{
WriteBatch
{
inner
:
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_create_with_capacity
(
cap
)
}
}
}
pub
fn
count
(
&
self
)
->
usize
{
pub
fn
count
(
&
self
)
->
usize
{
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_count
(
self
.inner
)
as
usize
}
unsafe
{
crocksdb_ffi
::
crocksdb_writebatch_count
(
self
.inner
)
as
usize
}
}
}
...
@@ -1516,6 +1520,17 @@ mod test {
...
@@ -1516,6 +1520,17 @@ mod test {
assert
!
(
r
.unwrap
()
.is_none
());
assert
!
(
r
.unwrap
()
.is_none
());
let
r
=
db
.get
(
b
"k13"
);
let
r
=
db
.get
(
b
"k13"
);
assert
!
(
r
.unwrap
()
.is_none
());
assert
!
(
r
.unwrap
()
.is_none
());
// test with capacity
let
batch
=
WriteBatch
::
with_capacity
(
1024
);
batch
.put
(
b
"kc1"
,
b
"v1"
)
.unwrap
();
batch
.put
(
b
"kc2"
,
b
"v2"
)
.unwrap
();
let
p
=
db
.write
(
batch
);
assert
!
(
p
.is_ok
());
let
r
=
db
.get
(
b
"kc1"
);
assert
!
(
r
.unwrap
()
.is_some
());
let
r
=
db
.get
(
b
"kc2"
);
assert
!
(
r
.unwrap
()
.is_some
());
}
}
#[test]
#[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