|
pstore2
|
Public Types | |
| enum | access_mode { read_only, writable, writeable_no_create } |
Public Member Functions | |
| database (std::string const &path, access_mode am, bool access_tick_enabled=true) | |
| Creates a database instance give the path of the file to use. More... | |
| template<typename File > | |
| database (std::shared_ptr< File > file, std::unique_ptr< system_page_size_interface > &&page_size, std::unique_ptr< region::factory > &®ion_factory, bool access_tick_enabled=true) | |
| Create a database from a pre-opened file. More... | |
| template<typename File > | |
| database (std::shared_ptr< File > file, bool access_tick_enabled=true) | |
| database (database &&)=delete | |
| database (database const &)=delete | |
| database & | operator= (database &&)=delete |
| database & | operator= (database const &)=delete |
| std::uint64_t | size () const noexcept |
| Returns the logical size of the data store. More... | |
| std::string | path () const |
| Returns the path of the file in which this database is contained. | |
| void | sync (unsigned revision=head_revision) |
| Update to a specified revision of the data. | |
| typed_address< trailer > | older_revision_footer_pos (unsigned revision) const |
| Returns the address of the footer of a specified revision. More... | |
| std::unique_lock< file::range_lock > * | upgrade_to_write_lock () |
| std::time_t | latest_time () const |
| bool | is_writable () const noexcept |
| virtual auto | get (address addr, std::size_t size, bool initialized, bool writable) const -> std::shared_ptr< void const > |
| class storage const & | storage () const noexcept |
| For unit testing. | |
| void | close () |
| header const & | get_header () const noexcept |
| typed_address< trailer > | footer_pos () const noexcept |
| unsigned | get_current_revision () const |
| Returns the generation number to which the database is synced. More... | |
| std::string | get_sync_name () const |
| Returns the name of the store's synchronisation object. More... | |
| std::string | shared_memory_name () const |
| virtual address | allocate (std::uint64_t bytes, unsigned align) |
| Appends an amount of storage to the database. More... | |
| virtual void | truncate (std::uint64_t size) |
| void | set_new_footer (typed_address< trailer > new_footer_pos) |
| Call as part of completing a transaction. More... | |
| void | protect (address const first, address const last) |
| void | set_id (uuid const &id) noexcept |
| shared const * | get_shared () const |
| shared * | get_shared () |
| std::shared_ptr< index::index_base > & | get_mutable_index (enum pstore::trailer::indices const which) const |
| Returns a pointer to an index base. More... | |
| std::shared_ptr< trailer const > | get_footer () const |
| template<typename File > | |
| auto | get_footer_pos (File &file) -> typed_address< trailer > |
| file::file_base const * | file () const |
| Returns the file in which this database is contained. | |
| file::file_base * | file () |
| std::shared_ptr< void const > | getro (address const addr, std::size_t const size) const |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T const > | getro (extent< T > const &ex) const |
Load a block of data starting at the address and size specified by ex. More... | |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T const > | getro (typed_address< T > const addr) const |
| Returns a pointer to a immutable instance of type T. More... | |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T const > | getro (typed_address< T > const addr, std::size_t const elements) const |
| Returns a pointer to a read-only array of instances of type T. More... | |
| std::shared_ptr< void > | getrw (address const addr, std::size_t const size) |
Load a block of data starting at address addr and of size bytes. More... | |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T > | getrw (extent< T > const &ex) |
Loads a block of storage at the address and size given by ex. More... | |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T > | getrw (typed_address< T > addr) |
| Returns a pointer to a mutable instance of type T. More... | |
| template<typename T , typename = typename std::enable_if<std::is_standard_layout<T>::value>::type> | |
| std::shared_ptr< T > | getrw (typed_address< T > const addr, std::size_t const elements) |
| Returns a pointer to a mutable array of instances of type T. More... | |
Static Public Member Functions | |
| static void | build_new_store (file::file_base &file) |
| Constructs the basic data store structures in an empty file. More... | |
| static constexpr bool | small_files_enabled () noexcept |
| static bool | crc_checks_enabled () |
| Returns true if CRC checks are enabled. More... | |
| enum | vacuum_mode { disabled, immediate, background } |
| void | set_vacuum_mode (vacuum_mode const mode) noexcept |
| vacuum_mode | get_vacuum_mode () const noexcept |
|
explicit |
Creates a database instance give the path of the file to use.
| path | The path of the file containing the database. |
| am | The requested access mode. If the file does not exist and writable access is requested, a new empty database is created. If read-only access is requested and the file does not exist, an error is raised. |
|
explicit |
Create a database from a pre-opened file.
This interface is intended to enable the database class to be unit tested.
|
virtual |
Appends an amount of storage to the database.
As an append-only system, this function provides the means by which data is recorded in the underlying storage; it is responsible for increasing the amount of available storage when necessary.
| bytes | The number of bytes to be allocated. |
| align | The alignment of the allocated storage. Must be a power of 2. |
OCLINT(PH - don't warn that this is a constant)
|
static |
Constructs the basic data store structures in an empty file.
On return, the file will contain the correct header and a single, empty, transaction.
|
static |
Returns true if CRC checks are enabled.
The library uses simple CRC checks to ensure the validity of its internal data structures. When fuzz testing, these can be disabled to increase the probability of the fuzzer uncovering a real bug. Always enabled otherwise.
|
inline |
Returns the generation number to which the database is synced.
|
inline |
Returns a pointer to an index base.
| which | An index type from which the index will be read. |
|
inline |
Returns the name of the store's synchronisation object.
This is set of 20 letters (sync_name_length) from a 32 character alphabet whose value is derived from the store's ID. Assuming a truly uniform distribution, we have a collision probability of 1/32^20 which should be more than small enough for our purposes.
|
inline |
Load a block of data starting at address addr and of size bytes.
| addr | The starting address of the data block to be loaded. |
| size | The size of the data block to be loaded. |
|
inline |
Load a block of data starting at the address and size specified by ex.
| ex | The extent of of the data to be loaded. |
|
inline |
Returns a pointer to a immutable instance of type T.
| T | The type to be loaded. Must be standard-layout. |
| addr | The address at which the data begins. |
|
inline |
Returns a pointer to a read-only array of instances of type T.
| T | The type to be loaded. Must be standard-layout. |
| addr | The address at which the data begins. |
| elements | The number of elements in the T[] array. |
|
inline |
Load a block of data starting at address addr and of size bytes.
A collection of functions which obtain a non-const pointer to database storage. These functions should only be called by the transaction code. Data outside of an open transaction is always read-only and the underlying memory is marked read-only. Writing through the pointer returned by these functions may cause client code to crash if the address lies outside the range of the expected range.
| addr | The starting address of the data block to be loaded. |
| size | The size of the data block to be loaded. |
|
inline |
Loads a block of storage at the address and size given by ex.
| ex | The extent of the data. |
|
inline |
Returns a pointer to a mutable instance of type T.
| addr | The address at which the data begins. |
|
inline |
Returns a pointer to a mutable array of instances of type T.
| addr | The address at which the data begins. |
| elements | The number of elements in the T[] array. |
| typed_address< trailer > pstore::database::older_revision_footer_pos | ( | unsigned | revision | ) | const |
Returns the address of the footer of a specified revision.
| revision | The revision number. Should not be pstore::head_revision and should be less than or equal to the current revision number (as returned by database::get_current_revision(). In this event, an unknown_revision error is raised. |
| void pstore::database::set_new_footer | ( | typed_address< trailer > | new_footer_pos | ) |
Call as part of completing a transaction.
We update the database records to that the new footer is recorded.
|
inlinenoexcept |
Returns the logical size of the data store.
The local size of the data store is the number of bytes used, including both the data and meta-data. This may be less than the size of the physical disk file.
|
virtual |
OCLINT(PH - don't warn that this is a constant)
1.8.13