Expose WriteBatch::Append in the C API.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=209345072
This commit is contained in:
parent
f7b0e1d901
commit
16a2b8bb3a
7
db/c.cc
7
db/c.cc
@ -359,7 +359,7 @@ void leveldb_writebatch_delete(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void leveldb_writebatch_iterate(
|
void leveldb_writebatch_iterate(
|
||||||
leveldb_writebatch_t* b,
|
const leveldb_writebatch_t* b,
|
||||||
void* state,
|
void* state,
|
||||||
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
|
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
|
||||||
void (*deleted)(void*, const char* k, size_t klen)) {
|
void (*deleted)(void*, const char* k, size_t klen)) {
|
||||||
@ -382,6 +382,11 @@ void leveldb_writebatch_iterate(
|
|||||||
b->rep.Iterate(&handler);
|
b->rep.Iterate(&handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void leveldb_writebatch_append(leveldb_writebatch_t *destination,
|
||||||
|
const leveldb_writebatch_t *source) {
|
||||||
|
destination->rep.Append(source->rep);
|
||||||
|
}
|
||||||
|
|
||||||
leveldb_options_t* leveldb_options_create() {
|
leveldb_options_t* leveldb_options_create() {
|
||||||
return new leveldb_options_t;
|
return new leveldb_options_t;
|
||||||
}
|
}
|
||||||
|
@ -228,12 +228,18 @@ int main(int argc, char** argv) {
|
|||||||
leveldb_writebatch_clear(wb);
|
leveldb_writebatch_clear(wb);
|
||||||
leveldb_writebatch_put(wb, "bar", 3, "b", 1);
|
leveldb_writebatch_put(wb, "bar", 3, "b", 1);
|
||||||
leveldb_writebatch_put(wb, "box", 3, "c", 1);
|
leveldb_writebatch_put(wb, "box", 3, "c", 1);
|
||||||
leveldb_writebatch_delete(wb, "bar", 3);
|
|
||||||
|
leveldb_writebatch_t* wb2 = leveldb_writebatch_create();
|
||||||
|
leveldb_writebatch_delete(wb2, "bar", 3);
|
||||||
|
leveldb_writebatch_append(wb, wb2);
|
||||||
|
leveldb_writebatch_destroy(wb2);
|
||||||
|
|
||||||
leveldb_write(db, woptions, wb, &err);
|
leveldb_write(db, woptions, wb, &err);
|
||||||
CheckNoError(err);
|
CheckNoError(err);
|
||||||
CheckGet(db, roptions, "foo", "hello");
|
CheckGet(db, roptions, "foo", "hello");
|
||||||
CheckGet(db, roptions, "bar", NULL);
|
CheckGet(db, roptions, "bar", NULL);
|
||||||
CheckGet(db, roptions, "box", "c");
|
CheckGet(db, roptions, "box", "c");
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
leveldb_writebatch_iterate(wb, &pos, CheckPut, CheckDel);
|
leveldb_writebatch_iterate(wb, &pos, CheckPut, CheckDel);
|
||||||
CheckCondition(pos == 3);
|
CheckCondition(pos == 3);
|
||||||
|
@ -155,9 +155,11 @@ LEVELDB_EXPORT void leveldb_writebatch_put(leveldb_writebatch_t*,
|
|||||||
LEVELDB_EXPORT void leveldb_writebatch_delete(leveldb_writebatch_t*,
|
LEVELDB_EXPORT void leveldb_writebatch_delete(leveldb_writebatch_t*,
|
||||||
const char* key, size_t klen);
|
const char* key, size_t klen);
|
||||||
LEVELDB_EXPORT void leveldb_writebatch_iterate(
|
LEVELDB_EXPORT void leveldb_writebatch_iterate(
|
||||||
leveldb_writebatch_t*, void* state,
|
const leveldb_writebatch_t*, void* state,
|
||||||
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
|
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
|
||||||
void (*deleted)(void*, const char* k, size_t klen));
|
void (*deleted)(void*, const char* k, size_t klen));
|
||||||
|
LEVELDB_EXPORT void leveldb_writebatch_append(
|
||||||
|
leveldb_writebatch_t* destination, const leveldb_writebatch_t* source);
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user