Commit 193485b1 authored by Wallace's avatar Wallace Committed by Yi Wu

new multibatch write (#452)

Signed-off-by: 's avatarLittle-Wallace <bupt2013211450@gmail.com>

renew branch of multibatch-write. Optimize for large write batch block other thread.
parent fd5301cb
...@@ -985,12 +985,11 @@ void crocksdb_write_multi_batch( ...@@ -985,12 +985,11 @@ void crocksdb_write_multi_batch(
crocksdb_writebatch_t** batches, crocksdb_writebatch_t** batches,
size_t batch_size, size_t batch_size,
char** errptr) { char** errptr) {
thread_local std::vector<WriteBatch*> ws; std::vector<WriteBatch*> ws;
ws.clear();
for (size_t i = 0; i < batch_size; i ++) { for (size_t i = 0; i < batch_size; i ++) {
ws.push_back(&batches[i]->rep); ws.push_back(&batches[i]->rep);
} }
SaveError(errptr, db->rep->MultiThreadWrite(options->rep, ws)); SaveError(errptr, db->rep->MultiBatchWrite(options->rep, std::move(ws)));
} }
char* crocksdb_get( char* crocksdb_get(
......
...@@ -774,11 +774,7 @@ impl DB { ...@@ -774,11 +774,7 @@ impl DB {
writeopts: &WriteOptions, writeopts: &WriteOptions,
) -> Result<(), String> { ) -> Result<(), String> {
unsafe { unsafe {
let b: Vec<*mut DBWriteBatch> = batches let b: Vec<*mut DBWriteBatch> = batches.iter().map(|w| w.inner).collect();
.iter()
.filter(|w| w.count() > 0)
.map(|w| w.inner)
.collect();
if !b.is_empty() { if !b.is_empty() {
ffi_try!(crocksdb_write_multi_batch( ffi_try!(crocksdb_write_multi_batch(
self.inner, self.inner,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment