PMEMKV
1.4.1-git1.g7db5b8f
This is the C++ documentation for PMEMKV.
|
Iterator provides methods to iterate over records in db. More...
#include <libpmemkv.hpp>
Classes | |
class | OutputIterator |
OutputIterator provides iteration through elements without a possibility of reading them. It is only allowed to modify them. More... | |
Public Member Functions | |
iterator (iterator_type *it) | |
status | seek (string_view key) noexcept |
Changes iterator position to the record with given key. More... | |
status | seek_lower (string_view key) noexcept |
Changes iterator position to the record with key lower than given key. More... | |
status | seek_lower_eq (string_view key) noexcept |
Changes iterator position to the record with key equal or lower than given key. More... | |
status | seek_higher (string_view key) noexcept |
Changes iterator position to the record with key higher than given key. More... | |
status | seek_higher_eq (string_view key) noexcept |
Changes iterator position to the record with key equal or higher than given key. More... | |
status | seek_to_first () noexcept |
Changes iterator position to the first record. More... | |
status | seek_to_last () noexcept |
Changes iterator position to the last record. More... | |
status | is_next () noexcept |
Checks if there is a next record available. More... | |
status | next () noexcept |
Changes iterator position to the next record. More... | |
status | prev () noexcept |
Changes iterator position to the previous record. More... | |
result< string_view > | key () noexcept |
Returns record's key (pmem::kv::string_view), in pmem::kv::result<pmem::kv::string_view>. More... | |
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. More... | |
template<bool IC = IsConst> | |
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 |
template<bool IC = IsConst> | |
std::enable_if<!IC, status >::type | commit () noexcept |
template<bool IC = IsConst> | |
std::enable_if<!IC >::type | abort () noexcept |
iterator (iterator_type *it) | |
iterator (iterator_type *it) | |
result< pmem::obj::slice< db::iterator< false >::OutputIterator< char > > > | write_range (size_t pos, size_t n) noexcept |
Returns value's range (pmem::obj::slice<db::iterator::OutputIterator<char>>) to modify, in pmem::kv::result. More... | |
status | commit () noexcept |
Commits modifications made on the current record. More... | |
void | abort () noexcept |
Aborts uncommitted modifications made on the current record. More... | |
Private Types | |
using | iterator_type = typename std::conditional< IsConst, pmemkv_iterator, pmemkv_write_iterator >::type |
Private Member Functions | |
pmemkv_iterator * | get_raw_it () |
pmemkv_iterator * | get_raw_it () |
pmemkv_iterator * | get_raw_it () |
Private Attributes | |
std::unique_ptr< iterator_type, typename std::conditional< IsConst, decltype(&pmemkv_iterator_delete), decltype(&pmemkv_write_iterator_delete)>::type > | it_ |
Iterator provides methods to iterate over records in db.
This API is EXPERIMENTAL and might change.
It can be only created by methods in db (db::new_read_iterator() - for a read iterator, and db::new_write_iterator() for a write iterator).
Both iterator types (write_iterator and read_iterator) allow reading record's key and value. A write_iterator additionally can modify record's value transactionally.
Holding simultaneously in the same thread more than one iterator is undefined behavior.
Example usage of iterators with single-threaded engines:
Example usage of iterators with concurrent engines:
|
private |
pmem::kv::db::iterator< IsConst >::iterator | ( | iterator_type * | it | ) |
|
inline |
|
inline |
|
noexcept |
|
inlinenoexcept |
Aborts uncommitted modifications made on the current record.
|
noexcept |
|
inlinenoexcept |
Commits modifications made on the current record.
Calling this method is the only way to save modifications made by the iterator on the current record. You need to call this method before changing the iterator position, otherwise modifications will be automatically aborted.
|
private |
|
inlineprivate |
|
inlineprivate |
|
inlinenoexcept |
Checks if there is a next record available.
If true is returned, it is guaranteed that iterator.next() will return status::OK, otherwise iterator is already on the last element and iterator.next() will return status::NOT_FOUND.
If the iterator is on an undefined position, calling this method is undefined behaviour.
|
inlinenoexcept |
Returns record's key (pmem::kv::string_view), in pmem::kv::result<pmem::kv::string_view>.
If the iterator is on an undefined position, calling this method is undefined behaviour.
|
inlinenoexcept |
Changes iterator position to the next record.
If the next record exists, returns pmem::kv::status::OK, otherwise pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
If the iterator is on an undefined position, calling this method is undefined behaviour.
|
inlinenoexcept |
Changes iterator position to the previous record.
If the previous record exists, returns pmem::kv::status::OK, otherwise pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
If the iterator is on an undefined position, calling this method is undefined behaviour.
|
inlinenoexcept |
Returns value's range (pmem::kv::string_view) to read, in pmem::kv::result.
It is only used to read a value. If you want to modify the value, use db::iterator::write_range instead.
If the iterator is on an undefined position, calling this method is undefined behaviour.
[in] | pos | position of the element in a value which will be the first element in the returned range (default = 0) |
[in] | n | number of elements in range (default = std::numeric_limits<size_t>::max(), if n is bigger than the length of a value it's automatically shrinked) |
|
inlinenoexcept |
Changes iterator position to the record with given key.
If the record is present and no errors occurred, returns pmem::kv::status::OK. If the record does not exist, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
[in] | key | key that will be equal to the key of the record on the new iterator position |
|
inlinenoexcept |
Changes iterator position to the record with key higher than given key.
If the record is present and no errors occurred, returns pmem::kv::status::OK. If the record does not exist, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
[in] | key | key that will be lower than the key of the record on the new iterator position |
|
inlinenoexcept |
Changes iterator position to the record with key equal or higher than given key.
If the record is present and no errors occurred, returns pmem::kv::status::OK. If the record does not exist, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
[in] | key | key that will be equal or lower than the key of the record on the new iterator position |
|
inlinenoexcept |
Changes iterator position to the record with key lower than given key.
If the record is present and no errors occurred, returns pmem::kv::status::OK. If the record does not exist, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
[in] | key | key that will be higher than the key of the record on the new iterator position |
|
inlinenoexcept |
Changes iterator position to the record with key equal or lower than given key.
If the record is present and no errors occurred, returns pmem::kv::status::OK. If the record does not exist, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
[in] | key | key that will be equal or higher than the key of the record on the new iterator position |
|
inlinenoexcept |
Changes iterator position to the first record.
If db isn't empty, and no errors occurred, returns pmem::kv::status::OK. If db is empty, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
|
inlinenoexcept |
Changes iterator position to the last record.
If db isn't empty, and no errors occurred, returns pmem::kv::status::OK. If db is empty, pmem::kv::status::NOT_FOUND is returned and the iterator position is undefined. Other possible return values are described in pmem::kv::status.
It internally aborts all changes made to an element previously pointed by the iterator.
|
inlinenoexcept |
Returns value's range (pmem::obj::slice<db::iterator::OutputIterator<char>>) to modify, in pmem::kv::result.
It is only used to modify a value. If you want to read the value, use db::iterator::read_range instead.
Changes made on a requested range are not persistent until db::iterator::commit is called.
If iterator is on an undefined position, calling this method is undefined behaviour.
[in] | pos | position of the element in a value which will be the first element in the returned range (default = 0) |
[in] | n | number of elements in range (default = std::numeric_limits<size_t>::max(), if n is bigger than the length of a value it's automatically shrinked) |
|
noexcept |
|
private |