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
25391594
Commit
25391594
authored
Sep 05, 2019
by
Little-Wallace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add interface to support write multi batch
Signed-off-by:
Little-Wallace
<
bupt2013211450@gmail.com
>
parent
56d3bd75
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
0 deletions
+36
-0
c.cc
librocksdb_sys/crocksdb/c.cc
+13
-0
c.h
librocksdb_sys/crocksdb/crocksdb/c.h
+3
-0
lib.rs
librocksdb_sys/src/lib.rs
+8
-0
rocksdb.rs
src/rocksdb.rs
+12
-0
No files found.
librocksdb_sys/crocksdb/c.cc
View file @
25391594
...
...
@@ -960,6 +960,19 @@ void crocksdb_write(
SaveError
(
errptr
,
db
->
rep
->
Write
(
options
->
rep
,
&
batch
->
rep
));
}
void
crocksdb_write_multi_batch
(
crocksdb_t
*
db
,
const
crocksdb_writeoptions_t
*
options
,
crocksdb_writebatch_t
**
batches
,
size_t
batch_size
,
char
**
errptr
)
{
std
::
vector
<
WriteBatch
*>
ws
;
for
(
size_t
i
=
0
;
i
<
batch_size
;
i
++
)
{
ws
.
push_back
(
&
batches
[
i
]
->
rep
);
}
SaveError
(
errptr
,
db
->
rep
->
MultiThreadWrite
(
options
->
rep
,
ws
));
}
char
*
crocksdb_get
(
crocksdb_t
*
db
,
const
crocksdb_readoptions_t
*
options
,
...
...
librocksdb_sys/crocksdb/crocksdb/c.h
View file @
25391594
...
...
@@ -341,6 +341,9 @@ extern C_ROCKSDB_LIBRARY_API void crocksdb_merge_cf(
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_write
(
crocksdb_t
*
db
,
const
crocksdb_writeoptions_t
*
options
,
crocksdb_writebatch_t
*
batch
,
char
**
errptr
);
extern
C_ROCKSDB_LIBRARY_API
void
crocksdb_write_multi_batch
(
crocksdb_t
*
db
,
const
crocksdb_writeoptions_t
*
options
,
crocksdb_writebatch_t
**
batches
,
size_t
batch_size
,
char
**
errptr
);
/* Returns NULL if not found. A malloc()ed array otherwise.
Stores the length of the array in *vallen. */
...
...
librocksdb_sys/src/lib.rs
View file @
25391594
...
...
@@ -912,6 +912,14 @@ extern "C" {
batch
:
*
mut
DBWriteBatch
,
err
:
*
mut
*
mut
c_char
,
);
pub
fn
crocksdb_write_multi_batch
(
db
:
*
mut
DBInstance
,
writeopts
:
*
const
DBWriteOptions
,
batch
:
*
const
*
mut
DBWriteBatch
,
batchlen
:
size_t
,
err
:
*
mut
*
mut
c_char
,
);
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
;
...
...
src/rocksdb.rs
View file @
25391594
...
...
@@ -738,6 +738,18 @@ impl DB {
&
self
.path
}
pub
fn
multi_thread_write
(
&
self
,
batches
:
&
Vec
<
WriteBatch
>
,
writeopts
:
&
WriteOptions
)
->
Result
<
(),
String
>
{
unsafe
{
if
batches
.len
()
==
1
{
ffi_try!
(
crocksdb_write
(
self
.inner
,
writeopts
.inner
,
batches
[
0
]
.inner
));
}
else
{
let
b
:
Vec
<*
mut
DBWriteBatch
>
=
batches
.iter
()
.map
(|
w
|
w
.inner
)
.collect
();
ffi_try!
(
crocksdb_write_multi_batch
(
self
.inner
,
writeopts
.inner
,
b
.as_ptr
(),
b
.len
()));
}
}
Ok
(())
}
pub
fn
write_opt
(
&
self
,
batch
:
&
WriteBatch
,
writeopts
:
&
WriteOptions
)
->
Result
<
(),
String
>
{
unsafe
{
ffi_try!
(
crocksdb_write
(
self
.inner
,
writeopts
.inner
,
batch
.inner
));
...
...
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