PMEMKV
1.3.1-git1.g6468f74
This is the C++ documentation for PMEMKV.
|
Main pmemkv class, it provides functions to operate on data in database. More...
#include <libpmemkv.hpp>
Public Member Functions | |
db () noexcept | |
Default constructor with uninitialized database. More... | |
~db () | |
Default destructor. More... | |
db (const db &other)=delete | |
db (db &&other) noexcept | |
Move constructor. More... | |
db & | operator= (const db &other)=delete |
db & | operator= (db &&other) noexcept |
Move assignment operator. More... | |
status | open (const std::string &engine_name) noexcept |
Opens the pmemkv database without any configuration parameters. More... | |
status | open (const std::string &engine_name, config &&cfg) noexcept |
Opens the pmemkv database with specified config. More... | |
void | close () noexcept |
Closes pmemkv database. More... | |
status | count_all (std::size_t &cnt) noexcept |
It returns number of currently stored elements in pmem::kv::db. More... | |
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 key. More... | |
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 to the given key. More... | |
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 the given key. More... | |
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 key. More... | |
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 and less than the key2. More... | |
status | get_all (get_kv_callback *callback, void *arg) noexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db. More... | |
status | get_all (std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db. More... | |
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 than the given key. More... | |
status | get_above (string_view key, std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than the given key. More... | |
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 than or equal to the given key. More... | |
status | get_equal_above (string_view key, std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than or equal to the given key. More... | |
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 than or equal to the given key. More... | |
status | get_equal_below (string_view key, std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db, whose keys are lower than or equal to the given key. More... | |
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 than the given key. More... | |
status | get_below (string_view key, std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db, whose keys are less than the given key. More... | |
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 than the key1 and less than the key2. More... | |
status | get_between (string_view key1, string_view key2, std::function< get_kv_function > f) noexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than the key1 and less than the key2. More... | |
status | exists (string_view key) noexcept |
Checks existence of record with given key. More... | |
status | get (string_view key, get_v_callback *callback, void *arg) noexcept |
Executes (C-like) callback function for record with given key. More... | |
status | get (string_view key, std::function< get_v_function > f) noexcept |
Executes function for record with given key. More... | |
status | get (string_view key, std::string *value) noexcept |
Gets value copy of record with given key. More... | |
status | put (string_view key, string_view value) noexcept |
Inserts a key-value pair into pmemkv database. More... | |
status | remove (string_view key) noexcept |
Removes from database record with given key. More... | |
status | defrag (double start_percent=0, double amount_percent=100) |
Defragments approximately 'amount_percent' percent of elements in the database starting from 'start_percent' percent of elements. More... | |
std::string | errormsg () |
Returns a human readable string describing the last error. More... | |
Private Attributes | |
pmemkv_db * | _db |
Main pmemkv class, it provides functions to operate on data in database.
Database class for creating, opening and closing pmemkv's data file. It provides functions to write, read & remove data, count elements stored and check for existence of an element based on its key.
Note: It does not explicitly provide upper_bound/lower_bound functions. If you want to obtain an element(s) above or below the selected key, you can use pmem::kv::get_above() or pmem::kv::get_below(). See descriptions of these functions for details.
|
inlinenoexcept |
Default constructor with uninitialized database.
|
inline |
Default destructor.
Closes pmemkv database.
|
delete |
|
inlinenoexcept |
Move constructor.
Initializes database with another database. Ownership is being transferred to a class that move constructor was called on.
[in] | other | another database, to be moved from |
|
inlinenoexcept |
Closes pmemkv database.
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the given key.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound of counting |
[out] | cnt | number of records in pmem::kv::db matching query |
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db.
[out] | cnt | number of records stored in pmem::kv::db. |
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db, whose keys are less than the given key.
Keys are sorted in order specified by a comparator.
[in] | key | sets the upper bound of counting |
[out] | cnt | number of records in pmem::kv::db matching query |
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the key1 and less than the key2.
Keys are sorted in order specified by a comparator.
[in] | key1 | sets the lower bound of counting |
[in] | key2 | sets the upper bound of counting |
[out] | cnt | number of records in pmem::kv::db matching query |
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than or equal to the given key.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound of counting |
[out] | cnt | number of records in pmem::kv::db matching query |
|
inlinenoexcept |
It returns number of currently stored elements in pmem::kv::db, whose keys are lower than or equal to the given key.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound of counting |
[out] | cnt | number of records in pmem::kv::db matching query |
|
inline |
Defragments approximately 'amount_percent' percent of elements in the database starting from 'start_percent' percent of elements.
[in] | start_percent | starting percent of elements to defragment from |
[in] | amount_percent | amount percent of elements to defragment |
|
inline |
Returns a human readable string describing the last error.
Even if this is a method from the db class, it can return the last error from some other class.
|
inlinenoexcept |
Checks existence of record with given key.
If record is present pmem::kv::status::OK is returned, otherwise pmem::kv::status::NOT_FOUND is returned. Other possible return values are described in pmem::kv::status.
[in] | key | record's key to query for in database |
|
inlinenoexcept |
Executes (C-like) callback function for record with given key.
If record is present and no error occurred, the function returns pmem::kv::status::OK. If record does not exist pmem::kv::status::NOT_FOUND is returned. Other possible return values are described in pmem::kv::status. Callback is called with the following parameters: pointer to a value, size of the value and arg specified by the user. This function is guaranteed to be implemented by all engines.
[in] | key | record's key to query for |
[in] | callback | function to be called for returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for record with given key.
If record is present and no error occurred the function returns pmem::kv::status::OK. If record does not exist pmem::kv::status::NOT_FOUND is returned.
[in] | key | record's key to query for |
[in] | f | function called for returned element, it is called with only one param - value (key is known) |
|
inlinenoexcept |
Gets value copy of record with given key.
In absence of any errors, pmem::kv::status::OK is returned. This function is guaranteed to be implemented by all engines.
[in] | key | record's key to query for |
[out] | value | stores returned copy of the data |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater than the given key.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_above() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound for querying |
[in] | callback | function to be called for each returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than the given key.
Callback can stop iteration by returning non-zero value. In that case get_above() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound for querying |
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_all() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
[in] | callback | function to be called for every element stored in db |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db.
Callback can stop iteration by returning non-zero value. In that case get_all() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower than the given key.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_below() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the upper bound for querying |
[in] | callback | function to be called for each returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db, whose keys are less than the given key.
Callback can stop iteration by returning non-zero value. In that case get_below() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the upper bound for querying |
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater than the key1 and less than the key2.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_between() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key1 | sets the lower bound for querying |
[in] | key2 | sets the upper bound for querying |
[in] | callback | function to be called for each returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than the key1 and less than the key2.
Callback can stop iteration by returning non-zero value. In that case get_between() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key1 | sets the lower bound for querying |
[in] | key2 | sets the upper bound for querying |
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater than or equal to the given key.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_equal_above() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound for querying |
[in] | callback | function to be called for each returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db, whose keys are greater than or equal to the given key.
Callback can stop iteration by returning non-zero value. In that case get_equal_above()* returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the lower bound for querying |
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower than or equal to the given key.
Arguments passed to the callback function are: pointer to a key, size of the key, pointer to a value, size of the value and arg specified by the user. Callback can stop iteration by returning non-zero value. In that case get_equal_below() returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the upper bound for querying |
[in] | callback | function to be called for each returned element |
[in] | arg | additional arguments to be passed to callback |
|
inlinenoexcept |
Executes function for every record stored in pmem::kv::db, whose keys are lower than or equal to the given key.
Callback can stop iteration by returning non-zero value. In that case get_equal_below()* returns pmem::kv::status::STOPPED_BY_CB. Returning 0 continues iteration.
Keys are sorted in order specified by a comparator.
[in] | key | sets the upper bound for querying |
[in] | f | function called for each returned element, it is called with params: key and value |
|
inlinenoexcept |
Opens the pmemkv database without any configuration parameters.
[in] | engine_name | name of the engine to work with |
Opens the pmemkv database with specified config.
[in] | engine_name | name of the engine to work with |
[in] | cfg | pmem::kv::config with parameters specified for the engine |
Move assignment operator.
Deletes previous database and replaces it with another database. Ownership is being transferred to a class that assign operator was called on.
[in] | other | another database, to be assigned from |
|
inlinenoexcept |
Inserts a key-value pair into pmemkv database.
This function is guaranteed to be implemented by all engines.
[in] | key | record's key; record will be put into database under its name |
[in] | value | data to be inserted into this new database record |
|
inlinenoexcept |
Removes from database record with given key.
This function is guaranteed to be implemented by all engines.
[in] | key | record's key to query for, to be removed |
|
private |