C: add support for WriteBatch SliceParts params
This commit is contained in:
parent
a187e66ad0
commit
21cd6b7ad8
98
db/c.cc
98
db/c.cc
@ -65,6 +65,7 @@ using rocksdb::Range;
|
|||||||
using rocksdb::ReadOptions;
|
using rocksdb::ReadOptions;
|
||||||
using rocksdb::SequentialFile;
|
using rocksdb::SequentialFile;
|
||||||
using rocksdb::Slice;
|
using rocksdb::Slice;
|
||||||
|
using rocksdb::SliceParts;
|
||||||
using rocksdb::SliceTransform;
|
using rocksdb::SliceTransform;
|
||||||
using rocksdb::Snapshot;
|
using rocksdb::Snapshot;
|
||||||
using rocksdb::Status;
|
using rocksdb::Status;
|
||||||
@ -1077,6 +1078,43 @@ void rocksdb_writebatch_put_cf(
|
|||||||
b->rep.Put(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
b->rep.Put(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_putv(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
Slice value_slices[num_values];
|
||||||
|
for (size_t i = 0; i < num_values; i++) {
|
||||||
|
value_slices[i] = Slice(values_list[i], values_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Put(SliceParts(key_slices, num_keys),
|
||||||
|
SliceParts(value_slices, num_values));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_putv_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
Slice value_slices[num_values];
|
||||||
|
for (size_t i = 0; i < num_values; i++) {
|
||||||
|
value_slices[i] = Slice(values_list[i], values_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Put(column_family->rep, SliceParts(key_slices, num_keys),
|
||||||
|
SliceParts(value_slices, num_values));
|
||||||
|
}
|
||||||
|
|
||||||
void rocksdb_writebatch_merge(
|
void rocksdb_writebatch_merge(
|
||||||
rocksdb_writebatch_t* b,
|
rocksdb_writebatch_t* b,
|
||||||
const char* key, size_t klen,
|
const char* key, size_t klen,
|
||||||
@ -1092,6 +1130,43 @@ void rocksdb_writebatch_merge_cf(
|
|||||||
b->rep.Merge(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
b->rep.Merge(column_family->rep, Slice(key, klen), Slice(val, vlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_mergev(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
Slice value_slices[num_values];
|
||||||
|
for (size_t i = 0; i < num_values; i++) {
|
||||||
|
value_slices[i] = Slice(values_list[i], values_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Merge(SliceParts(key_slices, num_keys),
|
||||||
|
SliceParts(value_slices, num_values));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_mergev_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
Slice value_slices[num_values];
|
||||||
|
for (size_t i = 0; i < num_values; i++) {
|
||||||
|
value_slices[i] = Slice(values_list[i], values_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Merge(column_family->rep, SliceParts(key_slices, num_keys),
|
||||||
|
SliceParts(value_slices, num_values));
|
||||||
|
}
|
||||||
|
|
||||||
void rocksdb_writebatch_delete(
|
void rocksdb_writebatch_delete(
|
||||||
rocksdb_writebatch_t* b,
|
rocksdb_writebatch_t* b,
|
||||||
const char* key, size_t klen) {
|
const char* key, size_t klen) {
|
||||||
@ -1105,6 +1180,29 @@ void rocksdb_writebatch_delete_cf(
|
|||||||
b->rep.Delete(column_family->rep, Slice(key, klen));
|
b->rep.Delete(column_family->rep, Slice(key, klen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_deletev(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Delete(SliceParts(key_slices, num_keys));
|
||||||
|
}
|
||||||
|
|
||||||
|
void rocksdb_writebatch_deletev_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes) {
|
||||||
|
Slice key_slices[num_keys];
|
||||||
|
for (size_t i = 0; i < num_keys; i++) {
|
||||||
|
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||||
|
}
|
||||||
|
b->rep.Delete(column_family->rep, SliceParts(key_slices, num_keys));
|
||||||
|
}
|
||||||
|
|
||||||
void rocksdb_writebatch_iterate(
|
void rocksdb_writebatch_iterate(
|
||||||
rocksdb_writebatch_t* b,
|
rocksdb_writebatch_t* b,
|
||||||
void* state,
|
void* state,
|
||||||
|
18
db/c_test.c
18
db/c_test.c
@ -465,6 +465,24 @@ int main(int argc, char** argv) {
|
|||||||
rocksdb_writebatch_destroy(wb);
|
rocksdb_writebatch_destroy(wb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StartPhase("writebatch_vectors");
|
||||||
|
{
|
||||||
|
rocksdb_writebatch_t* wb = rocksdb_writebatch_create();
|
||||||
|
const char* k_list[2] = { "z", "ap" };
|
||||||
|
const size_t k_sizes[2] = { 1, 2 };
|
||||||
|
const char* v_list[3] = { "x", "y", "z" };
|
||||||
|
const size_t v_sizes[3] = { 1, 1, 1 };
|
||||||
|
rocksdb_writebatch_putv(wb, 2, k_list, k_sizes, 3, v_list, v_sizes);
|
||||||
|
rocksdb_write(db, woptions, wb, &err);
|
||||||
|
CheckNoError(err);
|
||||||
|
CheckGet(db, roptions, "zap", "xyz");
|
||||||
|
rocksdb_writebatch_delete(wb, "zap", 3);
|
||||||
|
rocksdb_write(db, woptions, wb, &err);
|
||||||
|
CheckNoError(err);
|
||||||
|
CheckGet(db, roptions, "zap", NULL);
|
||||||
|
rocksdb_writebatch_destroy(wb);
|
||||||
|
}
|
||||||
|
|
||||||
StartPhase("writebatch_rep");
|
StartPhase("writebatch_rep");
|
||||||
{
|
{
|
||||||
rocksdb_writebatch_t* wb1 = rocksdb_writebatch_create();
|
rocksdb_writebatch_t* wb1 = rocksdb_writebatch_create();
|
||||||
|
@ -380,6 +380,19 @@ extern void rocksdb_writebatch_put_cf(
|
|||||||
rocksdb_column_family_handle_t* column_family,
|
rocksdb_column_family_handle_t* column_family,
|
||||||
const char* key, size_t klen,
|
const char* key, size_t klen,
|
||||||
const char* val, size_t vlen);
|
const char* val, size_t vlen);
|
||||||
|
extern void rocksdb_writebatch_putv(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes);
|
||||||
|
extern void rocksdb_writebatch_putv_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes);
|
||||||
extern void rocksdb_writebatch_merge(
|
extern void rocksdb_writebatch_merge(
|
||||||
rocksdb_writebatch_t*,
|
rocksdb_writebatch_t*,
|
||||||
const char* key, size_t klen,
|
const char* key, size_t klen,
|
||||||
@ -389,6 +402,19 @@ extern void rocksdb_writebatch_merge_cf(
|
|||||||
rocksdb_column_family_handle_t* column_family,
|
rocksdb_column_family_handle_t* column_family,
|
||||||
const char* key, size_t klen,
|
const char* key, size_t klen,
|
||||||
const char* val, size_t vlen);
|
const char* val, size_t vlen);
|
||||||
|
extern void rocksdb_writebatch_mergev(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes);
|
||||||
|
extern void rocksdb_writebatch_mergev_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes,
|
||||||
|
size_t num_values, const char* const* values_list,
|
||||||
|
const size_t* values_list_sizes);
|
||||||
extern void rocksdb_writebatch_delete(
|
extern void rocksdb_writebatch_delete(
|
||||||
rocksdb_writebatch_t*,
|
rocksdb_writebatch_t*,
|
||||||
const char* key, size_t klen);
|
const char* key, size_t klen);
|
||||||
@ -396,6 +422,15 @@ extern void rocksdb_writebatch_delete_cf(
|
|||||||
rocksdb_writebatch_t*,
|
rocksdb_writebatch_t*,
|
||||||
rocksdb_column_family_handle_t* column_family,
|
rocksdb_column_family_handle_t* column_family,
|
||||||
const char* key, size_t klen);
|
const char* key, size_t klen);
|
||||||
|
void rocksdb_writebatch_deletev(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes);
|
||||||
|
void rocksdb_writebatch_deletev_cf(
|
||||||
|
rocksdb_writebatch_t* b,
|
||||||
|
rocksdb_column_family_handle_t* column_family,
|
||||||
|
size_t num_keys, const char* const* keys_list,
|
||||||
|
const size_t* keys_list_sizes);
|
||||||
extern void rocksdb_writebatch_iterate(
|
extern void rocksdb_writebatch_iterate(
|
||||||
rocksdb_writebatch_t*,
|
rocksdb_writebatch_t*,
|
||||||
void* state,
|
void* state,
|
||||||
|
Loading…
Reference in New Issue
Block a user