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(
crocksdb_writebatch_t** batches,
size_t batch_size,
char** errptr) {
thread_local std::vector<WriteBatch*> ws;
ws.clear();
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));
SaveError(errptr, db->rep->MultiBatchWrite(options->rep, std::move(ws)));
}
char* crocksdb_get(
......
......@@ -774,11 +774,7 @@ impl DB {
writeopts: &WriteOptions,
) -> Result<(), String> {
unsafe {
let b: Vec<*mut DBWriteBatch> = batches
.iter()
.filter(|w| w.count() > 0)
.map(|w| w.inner)
.collect();
let b: Vec<*mut DBWriteBatch> = batches.iter().map(|w| w.inner).collect();
if !b.is_empty() {
ffi_try!(crocksdb_write_multi_batch(
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