PMEMKV
1.4.1-git1.g7db5b8f
This is the C++ documentation for PMEMKV.
|
Go to the documentation of this file.
10 #include <libpmemobj++/slice.hpp>
11 #include <libpmemobj++/string_view.hpp>
17 #include "libpmemkv.h"
18 #include <libpmemobj/pool_base.h>
85 OK = PMEMKV_STATUS_OK,
86 UNKNOWN_ERROR = PMEMKV_STATUS_UNKNOWN_ERROR,
87 NOT_FOUND = PMEMKV_STATUS_NOT_FOUND,
88 NOT_SUPPORTED = PMEMKV_STATUS_NOT_SUPPORTED,
90 INVALID_ARGUMENT = PMEMKV_STATUS_INVALID_ARGUMENT,
92 CONFIG_PARSING_ERROR =
93 PMEMKV_STATUS_CONFIG_PARSING_ERROR,
95 PMEMKV_STATUS_CONFIG_TYPE_ERROR,
97 STOPPED_BY_CB = PMEMKV_STATUS_STOPPED_BY_CB,
100 PMEMKV_STATUS_OUT_OF_MEMORY,
103 PMEMKV_STATUS_WRONG_ENGINE_NAME,
105 TRANSACTION_SCOPE_ERROR =
106 PMEMKV_STATUS_TRANSACTION_SCOPE_ERROR,
108 DEFRAG_ERROR = PMEMKV_STATUS_DEFRAG_ERROR,
111 PMEMKV_STATUS_COMPARATOR_MISMATCH,
126 static const std::string statuses[] = {
"OK",
131 "CONFIG_PARSING_ERROR",
136 "TRANSACTION_SCOPE_ERROR",
138 "COMPARATOR_MISMATCH"};
140 int status_no =
static_cast<int>(s);
141 os << statuses[status_no] <<
" (" << status_no <<
")";
156 const char *
what() const noexcept final
158 return std::runtime_error::what();
174 template <
typename T>
183 result(
const T &val) noexcept(noexcept(T(std::declval<T>())));
185 result(
const result &other) noexcept(noexcept(T(std::declval<T>())));
186 result(
result &&other) noexcept(noexcept(T(std::declval<T>())));
187 result(T &&val) noexcept(noexcept(T(std::declval<T>())));
192 operator=(
const result &other) noexcept(noexcept(std::declval<T>().~T()) &&
193 noexcept(T(std::declval<T>())));
195 noexcept(T(std::declval<T>())));
197 bool is_ok() const noexcept;
212 template <typename T>
213 result<T>::
result(const T &val) noexcept(noexcept(T(std::declval<T>())))
223 template <
typename T>
226 assert(
s != status::OK);
234 template <
typename T>
239 new (&
value) T(other.value);
247 template <
typename T>
251 new (&
value) T(std::move(other.value));
253 other.s = status::UNKNOWN_ERROR;
259 template <
typename T>
271 template <
typename T>
274 noexcept(T(std::declval<T>())))
276 if (
s == status::OK && other.is_ok())
278 else if (other.is_ok())
279 new (&
value) T(other.value);
280 else if (
s == status::OK)
293 template <
typename T>
296 noexcept(T(std::declval<T>())))
298 if (
s == status::OK && other.is_ok())
299 value = std::move(other.value);
300 else if (other.is_ok())
301 new (&
value) T(std::move(other.value));
302 else if (
s == status::OK)
306 other.s = status::UNKNOWN_ERROR;
316 template <
typename T>
327 template <
typename T>
330 return s == status::OK;
342 template <
typename T>
360 template <
typename T>
378 template <
typename T>
381 if (
s == status::OK) {
382 s = status::UNKNOWN_ERROR;
383 return std::move(
value);
396 template <
typename T>
402 template <
typename T>
408 template <
typename T>
414 template <
typename T>
420 template <
typename T>
448 explicit config(pmemkv_config *cfg) noexcept;
450 template <
typename T>
451 status put_data(
const std::string &key,
const T *
value,
452 const std::size_t number = 1) noexcept;
454 template <
typename T>
455 status put_object(
const std::string &key, T *
value,
456 void (*deleter)(
void *)) noexcept;
457 template <
typename T,
typename D>
458 status put_object(
const std::string &key, std::unique_ptr<T, D>
object) noexcept;
459 status put_uint64(
const std::string &key, std::uint64_t
value) noexcept;
460 status put_int64(
const std::string &key, std::int64_t
value) noexcept;
461 status put_string(
const std::string &key,
const std::string &
value) noexcept;
463 status put_size(std::uint64_t size) noexcept;
464 status put_path(
const std::string &path) noexcept;
466 status put_oid(PMEMoid *oid) noexcept;
467 template <
typename Comparator>
468 status put_comparator(Comparator &&comparator);
470 template <
typename T>
471 status get_data(
const std::string &key, T *&
value, std::size_t &number)
const
473 template <
typename T>
474 status get_object(
const std::string &key, T *&
value)
const noexcept;
476 status get_uint64(
const std::string &key, std::uint64_t &
value)
const noexcept;
477 status get_int64(
const std::string &key, std::int64_t &
value)
const noexcept;
478 status get_string(
const std::string &key, std::string &
value)
const noexcept;
480 pmemkv_config *release() noexcept;
485 std::unique_ptr<pmemkv_config, decltype(&pmemkv_config_delete)>
config_;
505 tx(pmemkv_tx *tx_) noexcept;
510 void abort() noexcept;
513 std::unique_ptr<pmemkv_tx, decltype(&pmemkv_tx_end)>
tx_;
538 template <
bool IsConst>
549 void close() noexcept;
551 status count_all(std::
size_t &cnt) noexcept;
557 std::
size_t &cnt) noexcept;
591 status defrag(
double start_percent = 0,
double amount_percent = 100);
595 result<read_iterator> new_read_iterator();
596 result<write_iterator> new_write_iterator();
598 std::
string errormsg();
601 std::unique_ptr<pmemkv_db, decltype(&pmemkv_close)> db_;
625 template <
bool IsConst>
628 pmemkv_write_iterator>::type;
630 template <
typename T>
642 status seek_to_first() noexcept;
643 status seek_to_last() noexcept;
645 status is_next() noexcept;
652 read_range(
size_t pos = 0,
653 size_t n = std::numeric_limits<
size_t>::max()) noexcept;
655 template <
bool IC = IsConst>
657 write_range(
size_t pos = 0,
658 size_t n = std::numeric_limits<
size_t>::max()) noexcept;
660 template <
bool IC = IsConst>
661 typename std::enable_if<!IC,
status>::type commit() noexcept;
662 template <
bool IC = IsConst>
663 typename std::enable_if<!IC>::type abort() noexcept;
668 typename std::conditional<IsConst, decltype(&pmemkv_iterator_delete),
669 decltype(&pmemkv_write_iterator_delete)>::type>
672 pmemkv_iterator *get_raw_it();
679 template <
bool IsConst>
680 template <typename T>
722 template <
bool IsConst>
723 template <
typename T>
728 template <
bool IsConst>
729 template <
typename T>
736 template <
bool IsConst>
737 template <
typename T>
745 template <
bool IsConst>
746 template <
typename T>
755 template <
bool IsConst>
756 template <
typename T>
764 template <
bool IsConst>
765 template <
typename T>
774 template <
bool IsConst>
775 template <
typename T>
782 template <
bool IsConst>
783 template <
typename T>
787 return this->ao.c - other.
ao.
c;
790 template <
bool IsConst>
791 template <
typename T>
795 return this->ao.c != other.
ao.
c;
798 template <
bool IsConst>
799 template <
typename T>
804 template <
bool IsConst>
805 template <
typename T>
820 : it_(it, &pmemkv_write_iterator_delete)
837 template <
bool IsConst>
840 return static_cast<status>(
841 pmemkv_iterator_seek(this->get_raw_it(), key.data(), key.size()));
857 template <
bool IsConst>
860 return static_cast<status>(
861 pmemkv_iterator_seek_lower(this->get_raw_it(), key.data(), key.size()));
877 template <
bool IsConst>
880 return static_cast<status>(pmemkv_iterator_seek_lower_eq(this->get_raw_it(),
881 key.data(), key.size()));
897 template <
bool IsConst>
900 return static_cast<status>(
901 pmemkv_iterator_seek_higher(this->get_raw_it(), key.data(), key.size()));
917 template <
bool IsConst>
920 return static_cast<status>(pmemkv_iterator_seek_higher_eq(
921 this->get_raw_it(), key.data(), key.size()));
935 template <
bool IsConst>
938 return static_cast<status>(pmemkv_iterator_seek_to_first(this->get_raw_it()));
952 template <
bool IsConst>
955 return static_cast<status>(pmemkv_iterator_seek_to_last(this->get_raw_it()));
968 template <
bool IsConst>
971 return static_cast<status>(pmemkv_iterator_is_next(this->get_raw_it()));
987 template <
bool IsConst>
990 return static_cast<status>(pmemkv_iterator_next(this->get_raw_it()));
1006 template <
bool IsConst>
1009 return static_cast<status>(pmemkv_iterator_prev(this->get_raw_it()));
1021 template <
bool IsConst>
1026 auto s =
static_cast<status>(pmemkv_iterator_key(this->get_raw_it(), &c, &size));
1028 if (s == status::OK)
1050 template <
bool IsConst>
1056 auto s =
static_cast<status>(
1057 pmemkv_iterator_read_range(this->get_raw_it(), pos, n, &data, &size));
1059 if (s == status::OK)
1091 auto s =
static_cast<status>(
1092 pmemkv_write_iterator_write_range(this->it_.get(), pos, n, &data, &size));
1094 if (s == status::OK) {
1096 return {{data, data + size}};
1097 }
catch (std::out_of_range &e) {
1098 return {status::INVALID_ARGUMENT};
1117 auto s =
static_cast<status>(pmemkv_write_iterator_commit(this->it_.get()));
1128 pmemkv_write_iterator_abort(this->it_.get());
1140 return it_.get()->iter;
1165 template <
typename T,
typename D>
1187 template <
typename Comparator>
1199 return cmp.compare(key1, key2);
1207 std::unique_ptr<comparator_base> ptr,
1208 std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *>
1210 : ptr(std::move(ptr)), c_cmp(std::move(c_cmp))
1219 std::unique_ptr<comparator_base>
ptr;
1220 std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *>
c_cmp;
1229 static inline void call_up_destructor(
void *
object)
1235 static inline void *call_up_get(
void *
object)
1237 auto *ptr =
static_cast<unique_ptr_wrapper_base *
>(object);
1241 static inline int call_comparator_function(
const char *k1,
size_t kb1,
const char *k2,
1242 size_t kb2,
void *arg)
1244 auto *cmp =
static_cast<comparator_base *
>(arg);
1261 inline config::config(pmemkv_config *cfg) noexcept : config_(cfg, &pmemkv_config_delete)
1273 if (this->config_.get() ==
nullptr) {
1274 this->config_ = {pmemkv_config_new(), &pmemkv_config_delete};
1276 if (this->config_.get() ==
nullptr)
1293 template <
typename T>
1295 const std::size_t count) noexcept
1298 return status::UNKNOWN_ERROR;
1300 return static_cast<status>(pmemkv_config_put_data(
1301 this->config_.get(), key.data(), (
void *)value, count *
sizeof(T)));
1314 template <
typename T>
1316 void (*deleter)(
void *)) noexcept
1319 return status::UNKNOWN_ERROR;
1321 return static_cast<status>(pmemkv_config_put_object(
1322 this->config_.get(), key.data(), (
void *)value, deleter));
1333 template <
typename T,
typename D>
1335 std::unique_ptr<T, D>
object) noexcept
1338 return status::UNKNOWN_ERROR;
1344 }
catch (std::bad_alloc &e) {
1345 return status::OUT_OF_MEMORY;
1347 return status::UNKNOWN_ERROR;
1350 return static_cast<status>(pmemkv_config_put_object_cb(
1351 this->config_.get(), key.data(), (
void *)wrapper, internal::call_up_get,
1352 internal::call_up_destructor));
1374 template <
typename Comparator>
1378 std::is_same<decltype(std::declval<Comparator>().compare(
1379 std::declval<string_view>(),
1380 std::declval<string_view>())),
1382 "Comparator should implement `int compare(pmem::kv::string_view, pmem::kv::string_view)` method");
1383 static_assert(std::is_convertible<decltype(std::declval<Comparator>().name()),
1384 std::string>::value,
1385 "Comparator should implement `std::string name()` method");
1387 std::unique_ptr<internal::comparator_base> wrapper;
1390 wrapper = std::unique_ptr<internal::comparator_base>(
1392 std::forward<Comparator>(comparator)));
1393 }
catch (std::bad_alloc &e) {
1394 return status::OUT_OF_MEMORY;
1396 return status::UNKNOWN_ERROR;
1400 std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *>(
1401 pmemkv_comparator_new(&internal::call_comparator_function,
1402 std::string(comparator.name()).c_str(),
1404 &pmemkv_comparator_delete);
1406 return status::UNKNOWN_ERROR;
1413 }
catch (std::bad_alloc &e) {
1414 return status::OUT_OF_MEMORY;
1416 return status::UNKNOWN_ERROR;
1419 return static_cast<status>(pmemkv_config_put_object_cb(
1420 this->config_.get(),
"comparator", (
void *)entry, internal::call_up_get,
1421 internal::call_up_destructor));
1435 return status::UNKNOWN_ERROR;
1437 return static_cast<status>(
1438 pmemkv_config_put_uint64(this->config_.get(), key.data(), value));
1452 return status::UNKNOWN_ERROR;
1454 return static_cast<status>(
1455 pmemkv_config_put_int64(this->config_.get(), key.data(), value));
1467 const std::string &value) noexcept
1470 return status::UNKNOWN_ERROR;
1472 return static_cast<status>(
1473 pmemkv_config_put_string(this->config_.get(), key.data(), value.data()));
1485 return put_uint64(
"size", size);
1498 return put_string(
"path", path);
1510 return put_uint64(
"force_create", value ? 1 : 0);
1525 return status::UNKNOWN_ERROR;
1527 return static_cast<status>(pmemkv_config_put_oid(this->config_.get(), oid));
1540 template <
typename T>
1542 std::size_t &count)
const noexcept
1544 if (this->config_.get() ==
nullptr)
1545 return status::NOT_FOUND;
1548 auto s =
static_cast<status>(pmemkv_config_get_data(
1549 this->config_.get(), key.data(), (
const void **)&value, &size));
1551 if (s != status::OK)
1554 count = size /
sizeof(T);
1568 template <
typename T>
1571 if (this->config_.get() ==
nullptr)
1572 return status::NOT_FOUND;
1574 auto s =
static_cast<status>(pmemkv_config_get_object(
1575 this->config_.get(), key.data(), (
void **)&value));
1591 if (this->config_.get() ==
nullptr)
1592 return status::NOT_FOUND;
1594 return static_cast<status>(
1595 pmemkv_config_get_uint64(this->config_.get(), key.data(), &value));
1609 if (this->config_.get() ==
nullptr)
1610 return status::NOT_FOUND;
1612 return static_cast<status>(
1613 pmemkv_config_get_int64(this->config_.get(), key.data(), &value));
1627 if (this->config_.get() ==
nullptr)
1628 return status::NOT_FOUND;
1632 auto s =
static_cast<status>(
1633 pmemkv_config_get_string(this->config_.get(), key.data(), &data));
1635 if (s != status::OK)
1651 return this->config_.release();
1657 inline tx::tx(pmemkv_tx *tx_) noexcept : tx_(tx_, &pmemkv_tx_end)
1672 return static_cast<status>(pmemkv_tx_remove(tx_.get(), key.data(), key.size()));
1686 return static_cast<status>(pmemkv_tx_put(tx_.get(), key.data(), key.size(),
1687 value.data(), value.size()));
1699 return static_cast<status>(pmemkv_tx_commit(tx_.get()));
1708 pmemkv_tx_abort(tx_.get());
1717 static inline int call_get_kv_function(
const char *key,
size_t keybytes,
1718 const char *value,
size_t valuebytes,
void *arg)
1720 return (*
reinterpret_cast<std::function<get_kv_function> *
>(arg))(
1724 static inline void call_get_v_function(
const char *value,
size_t valuebytes,
void *arg)
1726 (*
reinterpret_cast<std::function<get_v_function> *
>(arg))(
1730 static inline void call_get_copy(
const char *v,
size_t vb,
void *arg)
1732 auto c =
reinterpret_cast<std::string *
>(arg);
1756 static_cast<status>(pmemkv_open(engine_name.c_str(), cfg.release(), &
db));
1757 if (s == pmem::kv::status::OK)
1758 this->db_.reset(
db);
1767 this->db_.reset(
nullptr);
1779 return static_cast<status>(pmemkv_count_all(this->db_.get(), &cnt));
1794 return static_cast<status>(
1795 pmemkv_count_above(this->db_.get(), key.data(), key.size(), &cnt));
1810 return static_cast<status>(
1811 pmemkv_count_equal_above(this->db_.get(), key.data(), key.size(), &cnt));
1826 return static_cast<status>(
1827 pmemkv_count_equal_below(this->db_.get(), key.data(), key.size(), &cnt));
1842 return static_cast<status>(
1843 pmemkv_count_below(this->db_.get(), key.data(), key.size(), &cnt));
1858 std::size_t &cnt) noexcept
1860 return static_cast<status>(pmemkv_count_between(this->db_.get(), key1.data(),
1861 key1.size(), key2.data(),
1862 key2.size(), &cnt));
1879 return static_cast<status>(pmemkv_get_all(this->db_.get(), callback, arg));
1894 return static_cast<status>(
1895 pmemkv_get_all(this->db_.get(), call_get_kv_function, &f));
1917 return static_cast<status>(
1918 pmemkv_get_above(this->db_.get(), key.data(), key.size(), callback, arg));
1937 return static_cast<status>(pmemkv_get_above(
1938 this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
1961 return static_cast<status>(pmemkv_get_equal_above(this->db_.get(), key.data(),
1962 key.size(), callback, arg));
1981 std::function<get_kv_function> f) noexcept
1983 return static_cast<status>(pmemkv_get_equal_above(
1984 this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
2007 return static_cast<status>(pmemkv_get_equal_below(this->db_.get(), key.data(),
2008 key.size(), callback, arg));
2027 std::function<get_kv_function> f) noexcept
2029 return static_cast<status>(pmemkv_get_equal_below(
2030 this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
2052 return static_cast<status>(
2053 pmemkv_get_below(this->db_.get(), key.data(), key.size(), callback, arg));
2072 return static_cast<status>(pmemkv_get_below(
2073 this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
2096 return static_cast<status>(pmemkv_get_between(this->db_.get(), key1.data(),
2097 key1.size(), key2.data(),
2098 key2.size(), callback, arg));
2116 std::function<get_kv_function> f) noexcept
2118 return static_cast<status>(
2119 pmemkv_get_between(this->db_.get(), key1.data(), key1.size(), key2.data(),
2120 key2.size(), call_get_kv_function, &f));
2134 return static_cast<status>(
2135 pmemkv_exists(this->db_.get(), key.data(), key.size()));
2155 return static_cast<status>(
2156 pmemkv_get(this->db_.get(), key.data(), key.size(), callback, arg));
2172 return static_cast<status>(pmemkv_get(this->db_.get(), key.data(), key.size(),
2173 call_get_v_function, &f));
2188 return static_cast<status>(pmemkv_get(this->db_.get(), key.data(), key.size(),
2189 call_get_copy, value));
2203 return static_cast<status>(pmemkv_put(this->db_.get(), key.data(), key.size(),
2204 value.data(), value.size()));
2217 return static_cast<status>(
2218 pmemkv_remove(this->db_.get(), key.data(), key.size()));
2232 return static_cast<status>(
2233 pmemkv_defrag(this->db_.get(), start_percent, amount_percent));
2243 pmemkv_write_iterator *tmp;
2244 auto ret =
static_cast<status>(pmemkv_write_iterator_new(
db_.get(), &tmp));
2245 if (
static_cast<status>(ret) == status::OK)
2258 pmemkv_iterator *tmp;
2259 auto ret =
static_cast<status>(pmemkv_iterator_new(
db_.get(), &tmp));
2260 if (ret == status::OK)
2275 return std::string(pmemkv_errormsg());
2283 static inline std::string
errormsg()
2285 return std::string(pmemkv_errormsg());
2296 auto s =
static_cast<status>(pmemkv_tx_begin(
db_.get(), &tx_));
2298 if (s == status::OK)
status put_string(const std::string &key, const std::string &value) noexcept
Puts string value to a config.
Definition: libpmemkv.hpp:1466
status seek_to_last() noexcept
Changes iterator position to the last record.
Definition: libpmemkv.hpp:953
status put_object(const std::string &key, T *value, void(*deleter)(void *)) noexcept
Puts object pointed by value, of type T, with given destructor to a config.
Definition: libpmemkv.hpp:1315
std::enable_if<!IC, result< pmem::obj::slice< OutputIterator< char > > > >::type write_range(size_t pos=0, size_t n=std::numeric_limits< size_t >::max()) noexcept
status get_string(const std::string &key, std::string &value) const noexcept
Gets string value from a config item with key name.
Definition: libpmemkv.hpp:1624
comparator_wrapper(const Comparator &cmp)
Definition: libpmemkv.hpp:1189
db() noexcept
Default constructor with uninitialized database.
Definition: libpmemkv.hpp:1740
std::unique_ptr< comparator_base > ptr
Definition: libpmemkv.hpp:1219
result< tx > tx_begin() noexcept
Starts a pmemkv transaction.
Definition: libpmemkv.hpp:2293
Holds configuration parameters for engines.
Definition: libpmemkv.hpp:445
status get_status() const noexcept
Returns status from the result.
Definition: libpmemkv.hpp:397
status commit() noexcept
Commits the transaction.
Definition: libpmemkv.hpp:1697
bool operator!=(const status &lhs, const result< T > &rhs)
Definition: libpmemkv.hpp:421
result & operator=(const result &other) noexcept(noexcept(std::declval< T >().~T()) &&noexcept(T(std::declval< T >())))
Default copy assignment operator.
Definition: libpmemkv.hpp:273
Persistent memory namespace.
bool operator==(const result< T > &lhs, const status &rhs)
Definition: libpmemkv.hpp:403
std::unique_ptr< iterator_type, typename std::conditional< IsConst, decltype(&pmemkv_iterator_delete), decltype(&pmemkv_write_iterator_delete)>::type > it_
Definition: libpmemkv.hpp:670
result< read_iterator > new_read_iterator()
Returns new read iterator in pmem::kv::result.
Definition: libpmemkv.hpp:2256
Stores result of an operation. It always contains status and optionally can contain value.
Definition: libpmemkv.hpp:175
assign_only ao
Definition: libpmemkv.hpp:719
~result()
Explicit destructor.
Definition: libpmemkv.hpp:260
Iterator provides methods to iterate over records in db.
Definition: libpmemkv.hpp:626
result< string_view > key() noexcept
Returns record's key (pmem::kv::string_view), in pmem::kv::result<pmem::kv::string_view>.
Definition: libpmemkv.hpp:1022
status get(string_view key, get_v_callback *callback, void *arg) noexcept
Executes (C-like) callback function for record with given key.
Definition: libpmemkv.hpp:2153
T * c
Definition: libpmemkv.hpp:716
status put_force_create(bool value) noexcept
Puts force_create parameter to a config, For supporting engines If false, pmemkv opens file specified...
Definition: libpmemkv.hpp:1508
void close() noexcept
Closes pmemkv database.
Definition: libpmemkv.hpp:1765
status next() noexcept
Changes iterator position to the next record.
Definition: libpmemkv.hpp:988
tx(pmemkv_tx *tx_) noexcept
Constructs C++ tx object from a C pmemkv_tx pointer.
Definition: libpmemkv.hpp:1657
unique_ptr_wrapper(std::unique_ptr< T, D > ptr)
Definition: libpmemkv.hpp:1167
status
Status returned by most of pmemkv functions.
Definition: libpmemkv.hpp:84
status get_int64(const std::string &key, std::int64_t &value) const noexcept
Gets std::int64_t value from a config item with key name.
Definition: libpmemkv.hpp:1606
std::enable_if<!IC, status >::type commit() noexcept
status put_size(std::uint64_t size) noexcept
Puts size to a config.
Definition: libpmemkv.hpp:1483
Definition: libpmemkv.hpp:708
pmemkv_config * release() noexcept
Similarly to std::unique_ptr::release it passes the ownership of underlying pmemkv_config variable an...
Definition: libpmemkv.hpp:1649
std::ostream & operator<<(std::ostream &os, const status &s)
Provides string representation of a status, along with its number as specified by enum.
Definition: libpmemkv.hpp:124
typename std::conditional< IsConst, pmemkv_iterator, pmemkv_write_iterator >::type iterator_type
Definition: libpmemkv.hpp:628
result(const T &val) noexcept(noexcept(T(std::declval< T >())))
Creates result with value (status is automatically initialized to status::OK).
Definition: libpmemkv.hpp:213
status put_oid(PMEMoid *oid) noexcept
Puts PMEMoid object to a config.
Definition: libpmemkv.hpp:1522
Definition: libpmemkv.hpp:1205
obj::string_view string_view
Partial string_view implemenetation, defined in pmem::obj namespace in libpmemobj-cpp library (see: h...
Definition: libpmemkv.hpp:47
int get_kv_function(string_view key, string_view value)
The C++ idiomatic function type to use for callback using key-value pair.
Definition: libpmemkv.hpp:55
status seek_lower(string_view key) noexcept
Changes iterator position to the record with key lower than given key.
Definition: libpmemkv.hpp:858
status put_int64(const std::string &key, std::int64_t value) noexcept
Puts std::int64_t value to a config.
Definition: libpmemkv.hpp:1449
Definition: libpmemkv.hpp:1179
status seek(string_view key) noexcept
Changes iterator position to the record with given key.
Definition: libpmemkv.hpp:838
Definition: libpmemkv.hpp:1157
status get_all(get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db.
Definition: libpmemkv.hpp:1877
OutputIterator provides iteration through elements without a possibility of reading them....
Definition: libpmemkv.hpp:681
void abort() noexcept
Aborts the transaction.
Definition: libpmemkv.hpp:1706
void * get() override
Definition: libpmemkv.hpp:1171
Definition: libpmemkv.hpp:1188
status seek_higher(string_view key) noexcept
Changes iterator position to the record with key higher than given key.
Definition: libpmemkv.hpp:898
status count_equal_above(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than or equal ...
Definition: libpmemkv.hpp:1808
Main pmemkv class, it provides functions to operate on data in database.
Definition: libpmemkv.hpp:537
status remove(string_view key) noexcept
Removes from database record with given key.
Definition: libpmemkv.hpp:1670
bool operator!=(const result< T > &lhs, const status &rhs)
Definition: libpmemkv.hpp:415
std::unique_ptr< pmemkv_db, decltype(&pmemkv_close)> db_
Definition: libpmemkv.hpp:601
bool is_ok() const noexcept
Checks if the result contains value (status == status::OK).
Definition: libpmemkv.hpp:328
status prev() noexcept
Changes iterator position to the previous record.
Definition: libpmemkv.hpp:1007
comparator_config_entry(std::unique_ptr< comparator_base > ptr, std::unique_ptr< pmemkv_comparator, decltype(pmemkv_comparator_delete) * > c_cmp)
Definition: libpmemkv.hpp:1206
status put_comparator(Comparator &&comparator)
Puts comparator object to a config.
Definition: libpmemkv.hpp:1375
void pointer
Definition: libpmemkv.hpp:686
result< write_iterator > new_write_iterator()
Returns new write iterator in pmem::kv::result.
Definition: libpmemkv.hpp:2241
status get_equal_below(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower tha...
Definition: libpmemkv.hpp:2004
std::enable_if<!IC >::type abort() noexcept
pmemkv_iterator * get_raw_it()
status get_between(string_view key1, string_view key2, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:2093
status defrag(double start_percent=0, double amount_percent=100)
Defragments approximately 'amount_percent' percent of elements in the database starting from 'start_p...
Definition: libpmemkv.hpp:2230
status seek_higher_eq(string_view key) noexcept
Changes iterator position to the record with key equal or higher than given key.
Definition: libpmemkv.hpp:918
status is_next() noexcept
Checks if there is a next record available.
Definition: libpmemkv.hpp:969
std::unique_ptr< pmemkv_config, decltype(&pmemkv_config_delete)> config_
Definition: libpmemkv.hpp:485
status get_above(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:1914
void get_v_function(string_view value)
The C++ idiomatic function type to use for callback using only the value.
Definition: libpmemkv.hpp:62
status count_below(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are less than the given ke...
Definition: libpmemkv.hpp:1840
status get_data(const std::string &key, T *&value, std::size_t &number) const noexcept
Gets object from a config item with key name and copies it into T object value.
Definition: libpmemkv.hpp:1541
int init() noexcept
Initialization function for config.
Definition: libpmemkv.hpp:1271
status seek_lower_eq(string_view key) noexcept
Changes iterator position to the record with key equal or lower than given key.
Definition: libpmemkv.hpp:878
status put_data(const std::string &key, const T *value, const std::size_t number=1) noexcept
Puts binary data pointed by value, of type T, with count of elements to a config.
Definition: libpmemkv.hpp:1294
status count_all(std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db.
Definition: libpmemkv.hpp:1777
iterator(iterator_type *it)
std::unique_ptr< pmemkv_tx, decltype(&pmemkv_tx_end)> tx_
Definition: libpmemkv.hpp:513
status get_uint64(const std::string &key, std::uint64_t &value) const noexcept
Gets std::uint64_t value from a config item with key name.
Definition: libpmemkv.hpp:1588
comparator_wrapper(Comparator &&cmp)
Definition: libpmemkv.hpp:1193
status get_equal_above(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:1958
result< string_view > read_range(size_t pos=0, size_t n=std::numeric_limits< size_t >::max()) noexcept
Returns value's range (pmem::kv::string_view) to read, in pmem::kv::result.
Definition: libpmemkv.hpp:1051
status get_below(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower tha...
Definition: libpmemkv.hpp:2049
void value_type
Definition: libpmemkv.hpp:688
status put(string_view key, string_view value) noexcept
Inserts a key-value pair into pmemkv database.
Definition: libpmemkv.hpp:1684
Pmemkv transaction handle.
Definition: libpmemkv.hpp:503
virtual ~unique_ptr_wrapper_base()
Definition: libpmemkv.hpp:1158
status remove(string_view key) noexcept
Removes from database record with given key.
Definition: libpmemkv.hpp:2215
virtual int compare(string_view key1, string_view key2)=0
pmemkv_get_kv_callback get_kv_callback
Key-value pair callback, C-style.
Definition: libpmemkv.hpp:67
std::string errormsg()
Returns a human readable string describing the last error.
Definition: libpmemkv.hpp:2273
std::unique_ptr< pmemkv_comparator, decltype(pmemkv_comparator_delete) * > c_cmp
Definition: libpmemkv.hpp:1220
status count_equal_below(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are lower than or equal to...
Definition: libpmemkv.hpp:1824
std::output_iterator_tag iterator_category
Definition: libpmemkv.hpp:689
std::unique_ptr< T, D > ptr
Definition: libpmemkv.hpp:1176
Defines a type of object to be thrown by result::get_value() when result doesn't contain value.
Definition: libpmemkv.hpp:150
pmemkv_get_v_callback get_v_callback
Value-only callback, C-style.
Definition: libpmemkv.hpp:71
void * get() override
Definition: libpmemkv.hpp:1214
status open(const std::string &engine_name, config &&cfg=config{}) noexcept
Opens the pmemkv database with specified config.
Definition: libpmemkv.hpp:1752
status count_above(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the given...
Definition: libpmemkv.hpp:1792
Definition: libpmemkv.hpp:1166
const T & get_value() const &
Returns const reference to value from the result.
Definition: libpmemkv.hpp:343
status s
Definition: libpmemkv.hpp:180
bad_result_access(const char *what_arg)
Definition: libpmemkv.hpp:152
config() noexcept
Default constructor with uninitialized config.
Definition: libpmemkv.hpp:1253
status exists(string_view key) noexcept
Checks existence of record with given key.
Definition: libpmemkv.hpp:2132
status put_uint64(const std::string &key, std::uint64_t value) noexcept
Puts std::uint64_t value to a config.
Definition: libpmemkv.hpp:1432
status seek_to_first() noexcept
Changes iterator position to the first record.
Definition: libpmemkv.hpp:936
status get_object(const std::string &key, T *&value) const noexcept
Gets binary data from a config item with key name and assigns pointer to T object value.
Definition: libpmemkv.hpp:1569
std::ptrdiff_t difference_type
Definition: libpmemkv.hpp:687
status put_path(const std::string &path) noexcept
Puts path to a config.
Definition: libpmemkv.hpp:1496
status count_between(string_view key1, string_view key2, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the key1 ...
Definition: libpmemkv.hpp:1857
status put(string_view key, string_view value) noexcept
Inserts a key-value pair into pmemkv database.
Definition: libpmemkv.hpp:2201
Comparator cmp
Definition: libpmemkv.hpp:1202
int compare(string_view key1, string_view key2) override
Definition: libpmemkv.hpp:1197
T value
Definition: libpmemkv.hpp:177
const char * what() const noexcept final
Definition: libpmemkv.hpp:156
virtual ~comparator_base()
Definition: libpmemkv.hpp:1181