Переглянути джерело

Expose WriteBatch::Append in the C API.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209345072
main
costan 6 роки тому
committed by Victor Costan
джерело
коміт
16a2b8bb3a
3 змінених файлів з 16 додано та 3 видалено
  1. +6
    -1
      db/c.cc
  2. +7
    -1
      db/c_test.c
  3. +3
    -1
      include/leveldb/c.h

+ 6
- 1
db/c.cc Переглянути файл

@ -359,7 +359,7 @@ void leveldb_writebatch_delete(
}
void leveldb_writebatch_iterate(
leveldb_writebatch_t* b,
const leveldb_writebatch_t* b,
void* state,
void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen),
void (*deleted)(void*, const char* k, size_t klen)) {
@ -382,6 +382,11 @@ void leveldb_writebatch_iterate(
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() {
return new leveldb_options_t;
}

+ 7
- 1
db/c_test.c Переглянути файл

@ -228,12 +228,18 @@ int main(int argc, char** argv) {
leveldb_writebatch_clear(wb);
leveldb_writebatch_put(wb, "bar", 3, "b", 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);
CheckNoError(err);
CheckGet(db, roptions, "foo", "hello");
CheckGet(db, roptions, "bar", NULL);
CheckGet(db, roptions, "box", "c");
int pos = 0;
leveldb_writebatch_iterate(wb, &pos, CheckPut, CheckDel);
CheckCondition(pos == 3);

+ 3
- 1
include/leveldb/c.h Переглянути файл

@ -155,9 +155,11 @@ LEVELDB_EXPORT void leveldb_writebatch_put(leveldb_writebatch_t*,
LEVELDB_EXPORT void leveldb_writebatch_delete(leveldb_writebatch_t*,
const char* key, size_t klen);
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 (*deleted)(void*, const char* k, size_t klen));
LEVELDB_EXPORT void leveldb_writebatch_append(
leveldb_writebatch_t* destination, const leveldb_writebatch_t* source);
/* Options */

Завантаження…
Відмінити
Зберегти