mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-29 09:58:48 +08:00
mdbx++: переименование mdbx::txn::put_multiple_samelength()
.
This commit is contained in:
parent
f738552721
commit
07309427fd
34
mdbx.h++
34
mdbx.h++
@ -4669,25 +4669,26 @@ public:
|
|||||||
return append(map, kv.key, kv.value, multivalue_order_preserved);
|
return append(map, kv.key, kv.value, multivalue_order_preserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t put_multiple(map_handle map, const slice &key,
|
size_t put_multiple_samelength(map_handle map, const slice &key,
|
||||||
const size_t value_length, const void *values_array,
|
const size_t value_length,
|
||||||
size_t values_count, put_mode mode,
|
const void *values_array, size_t values_count,
|
||||||
bool allow_partial = false);
|
put_mode mode, bool allow_partial = false);
|
||||||
template <typename VALUE>
|
template <typename VALUE>
|
||||||
size_t put_multiple(map_handle map, const slice &key,
|
size_t put_multiple_samelength(map_handle map, const slice &key,
|
||||||
const VALUE *values_array, size_t values_count,
|
const VALUE *values_array, size_t values_count,
|
||||||
put_mode mode, bool allow_partial = false) {
|
put_mode mode, bool allow_partial = false) {
|
||||||
static_assert(::std::is_standard_layout<VALUE>::value &&
|
static_assert(::std::is_standard_layout<VALUE>::value &&
|
||||||
!::std::is_pointer<VALUE>::value &&
|
!::std::is_pointer<VALUE>::value &&
|
||||||
!::std::is_array<VALUE>::value,
|
!::std::is_array<VALUE>::value,
|
||||||
"Must be a standard layout type!");
|
"Must be a standard layout type!");
|
||||||
return put_multiple(map, key, sizeof(VALUE), values_array, values_count,
|
return put_multiple_samelength(map, key, sizeof(VALUE), values_array,
|
||||||
mode, allow_partial);
|
values_count, mode, allow_partial);
|
||||||
}
|
}
|
||||||
template <typename VALUE>
|
template <typename VALUE>
|
||||||
void put_multiple(map_handle map, const slice &key,
|
void put_multiple_samelength(map_handle map, const slice &key,
|
||||||
const ::std::vector<VALUE> &vector, put_mode mode) {
|
const ::std::vector<VALUE> &vector,
|
||||||
put_multiple(map, key, vector.data(), vector.size(), mode);
|
put_mode mode) {
|
||||||
|
put_multiple_samelength(map, key, vector.data(), vector.size(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ptrdiff_t estimate(map_handle map, const pair &from,
|
inline ptrdiff_t estimate(map_handle map, const pair &from,
|
||||||
@ -6913,10 +6914,11 @@ inline void txn::append(map_handle map, const slice &key, const slice &value,
|
|||||||
: MDBX_APPEND));
|
: MDBX_APPEND));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t txn::put_multiple(map_handle map, const slice &key,
|
inline size_t txn::put_multiple_samelength(map_handle map, const slice &key,
|
||||||
const size_t value_length,
|
const size_t value_length,
|
||||||
const void *values_array, size_t values_count,
|
const void *values_array,
|
||||||
put_mode mode, bool allow_partial) {
|
size_t values_count, put_mode mode,
|
||||||
|
bool allow_partial) {
|
||||||
MDBX_val args[2] = {{const_cast<void *>(values_array), value_length},
|
MDBX_val args[2] = {{const_cast<void *>(values_array), value_length},
|
||||||
{nullptr, values_count}};
|
{nullptr, values_count}};
|
||||||
const int err = ::mdbx_put(handle_, map.dbi, const_cast<slice *>(&key), args,
|
const int err = ::mdbx_put(handle_, map.dbi, const_cast<slice *>(&key), args,
|
||||||
|
@ -50,13 +50,20 @@ int main(int argc, const char *argv[]) {
|
|||||||
|
|
||||||
const uint64_t array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 42, 17, 99, 0, 33, 333};
|
const uint64_t array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 42, 17, 99, 0, 33, 333};
|
||||||
txn = env.start_write();
|
txn = env.start_write();
|
||||||
txn.put_multiple(map, buffer::key_from_u64(13), array + 3, 4, mdbx::upsert);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(13), array + 3, 4,
|
||||||
txn.put_multiple(map, buffer::key_from_u64(10), array + 0, 1, mdbx::upsert);
|
mdbx::upsert);
|
||||||
txn.put_multiple(map, buffer::key_from_u64(12), array + 2, 3, mdbx::upsert);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(10), array + 0, 1,
|
||||||
txn.put_multiple(map, buffer::key_from_u64(15), array + 5, 6, mdbx::upsert);
|
mdbx::upsert);
|
||||||
txn.put_multiple(map, buffer::key_from_u64(14), array + 4, 5, mdbx::upsert);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(12), array + 2, 3,
|
||||||
txn.put_multiple(map, buffer::key_from_u64(11), array + 1, 2, mdbx::upsert);
|
mdbx::upsert);
|
||||||
txn.put_multiple(map, buffer::key_from_u64(16), array + 6, 7, mdbx::upsert);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(15), array + 5, 6,
|
||||||
|
mdbx::upsert);
|
||||||
|
txn.put_multiple_samelength(map, buffer::key_from_u64(14), array + 4, 5,
|
||||||
|
mdbx::upsert);
|
||||||
|
txn.put_multiple_samelength(map, buffer::key_from_u64(11), array + 1, 2,
|
||||||
|
mdbx::upsert);
|
||||||
|
txn.put_multiple_samelength(map, buffer::key_from_u64(16), array + 6, 7,
|
||||||
|
mdbx::upsert);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
txn = env.start_read();
|
txn = env.start_read();
|
||||||
@ -119,21 +126,29 @@ int main(int argc, const char *argv[]) {
|
|||||||
txn.abort();
|
txn.abort();
|
||||||
|
|
||||||
txn = env.start_write();
|
txn = env.start_write();
|
||||||
txn.put_multiple(map, buffer::key_from_u64(7), array + 3, 4, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(7), array + 3, 4,
|
||||||
|
mdbx::update);
|
||||||
txn.upsert(map, buffer::key_from_u64(10), buffer::key_from_u64(14));
|
txn.upsert(map, buffer::key_from_u64(10), buffer::key_from_u64(14));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(11), array + 4, 5, mdbx::upsert);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(11), array + 4, 5,
|
||||||
txn.put_multiple(map, buffer::key_from_u64(12), array + 0, 1, mdbx::update);
|
mdbx::upsert);
|
||||||
|
txn.put_multiple_samelength(map, buffer::key_from_u64(12), array + 0, 1,
|
||||||
|
mdbx::update);
|
||||||
txn.update(map, buffer::key_from_u64(13), buffer::key_from_u64(18));
|
txn.update(map, buffer::key_from_u64(13), buffer::key_from_u64(18));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(14), array + 2, 3, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(14), array + 2, 3,
|
||||||
|
mdbx::update);
|
||||||
txn.update(map, buffer::key_from_u64(15), buffer::key_from_u64(13));
|
txn.update(map, buffer::key_from_u64(15), buffer::key_from_u64(13));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(16), array + 6, 9, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(16), array + 6, 9,
|
||||||
|
mdbx::update);
|
||||||
txn.update(map, buffer::key_from_u64(21), buffer::key_from_u64(17));
|
txn.update(map, buffer::key_from_u64(21), buffer::key_from_u64(17));
|
||||||
txn.update(map, buffer::key_from_u64(22), buffer::key_from_u64(15));
|
txn.update(map, buffer::key_from_u64(22), buffer::key_from_u64(15));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(23), array + 1, 2, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(23), array + 1, 2,
|
||||||
|
mdbx::update);
|
||||||
txn.update(map, buffer::key_from_u64(24), buffer::key_from_u64(16));
|
txn.update(map, buffer::key_from_u64(24), buffer::key_from_u64(16));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(25), array + 5, 6, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(25), array + 5, 6,
|
||||||
|
mdbx::update);
|
||||||
txn.upsert(map, buffer::key_from_u64(26), buffer::key_from_u64(12));
|
txn.upsert(map, buffer::key_from_u64(26), buffer::key_from_u64(12));
|
||||||
txn.put_multiple(map, buffer::key_from_u64(27), array + 12, 3, mdbx::update);
|
txn.put_multiple_samelength(map, buffer::key_from_u64(27), array + 12, 3,
|
||||||
|
mdbx::update);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
txn = env.start_read();
|
txn = env.start_read();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user