SQLite Containers
|
Template class for managing key-value pairs in a SQLite database, where each key can map to multiple values. More...
#include <KeyMultiValueDB.hpp>
Public Member Functions | |
KeyMultiValueDB () | |
Default constructor. | |
KeyMultiValueDB (const Config &config) | |
Constructor with configuration. | |
~KeyMultiValueDB () override final=default | |
Destructor. | |
template<template< class... > class ContainerT> | |
KeyMultiValueDB & | operator= (const ContainerT< KeyT, ValueT > &container) |
Assigns a container (e.g., std::multimap or std::unordered_multimap) to the database. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
KeyMultiValueDB & | operator= (const ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Assigns a container where each key maps to a collection of values to the database. | |
template<template< class... > class ContainerT = std::multimap> | |
ContainerT< KeyT, ValueT > | operator() () |
Loads all key-value pairs from the database into a container. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
ContainerT< KeyT, ValueContainerT< ValueT > > | operator() () |
Loads all key-value pairs, where each key maps to a collection of values, from the database. | |
template<template< class... > class ContainerT> | |
void | load (ContainerT< KeyT, ValueT > &container, const TransactionMode &mode) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT> | |
void | load (ContainerT< KeyT, ValueT > &container) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | load (ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | load (ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT> | |
ContainerT< KeyT, ValueT > | retrieve_all (const TransactionMode &mode) |
Retrieves all key-value pairs from the database with a transaction. | |
template<template< class... > class ContainerT> | |
ContainerT< KeyT, ValueT > | retrieve_all () |
Retrieves all key-value pairs from the database. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
ContainerT< KeyT, ValueContainerT< ValueT > > | retrieve_all (const TransactionMode &mode) |
Retrieves all key-value pairs from the database with a transaction. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
ContainerT< KeyT, ValueContainerT< ValueT > > | retrieve_all () |
Retrieves all key-value pairs from the database. | |
template<template< class... > class ContainerT> | |
void | append (const ContainerT< KeyT, ValueT > &container, const TransactionMode &mode) |
Appends the content of the container to the database with a transaction. | |
template<template< class... > class ContainerT> | |
void | append (const ContainerT< KeyT, ValueT > &container) |
Appends the content of the container to the database. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode) |
Appends the content of the container to the database with a transaction. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Appends the content of the container to the database. | |
template<template< class... > class ContainerT> | |
void | reconcile (const ContainerT< KeyT, ValueT > &container, const TransactionMode &mode) |
Reconciles the content of the container with the database with a transaction. | |
template<template< class... > class ContainerT> | |
void | reconcile (const ContainerT< KeyT, ValueT > &container) |
Reconciles the content of the container with the database. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode) |
Reconciles the content of the container with the database with a transaction. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Reconciles the content of the container with the database. | |
void | insert (const KeyT &key, const ValueT &value, const TransactionMode &mode) |
Inserts a key-value pair into the database with a transaction. | |
void | insert (const KeyT &key, const ValueT &value) |
Inserts a key-value pair into the database. | |
void | insert (const std::pair< KeyT, ValueT > &pair, const TransactionMode &mode) |
Inserts a key-value pair into the database with a transaction. | |
void | insert (const std::pair< KeyT, ValueT > &pair) |
Inserts a key-value pair into the database. | |
void | set_value_count (const KeyT &key, const ValueT &value, const std::size_t &value_count) |
Sets the count of values associated with a specific key-value pair in the database. | |
void | set_count (const KeyT &key, const ValueT &value, const std::size_t &value_count) |
Alias for set_value_count(). This method is an alias for set_value_count() and performs the same operation. | |
std::size_t | get_value_count (const KeyT &key, const ValueT &value) const |
Retrieves the count of values associated with a specific key-value pair from the database. This method returns the number of associations between a given key and value in the database. | |
std::size_t | count (const KeyT &key, const ValueT &value) const |
Alias for get_value_count(). This method is an alias for get_value_count() and performs the same operation. | |
template<template< class... > class ContainerT> | |
bool | find (const KeyT &key, ContainerT< ValueT > &values) |
Finds values by key in the database. | |
std::size_t | count () const |
Returns the number of elements in the database. This method returns the number of unique keys stored in the database, not the number of key-value pairs. | |
bool | empty () const |
Checks if the database is empty. This method checks if there are any keys stored in the database. | |
void | remove (const KeyT &key, const ValueT &value) |
Removes a specific key-value pair from the database. | |
void | remove (const KeyT &key) |
Removes all values associated with a key from the database. | |
void | clear (const TransactionMode &mode) |
Clears all key-value pairs from the database with a transaction. | |
void | clear () |
Clears all key-value pairs from the database. | |
Public Member Functions inherited from sqlite_containers::BaseDB | |
BaseDB ()=default | |
Default constructor. | |
virtual | ~BaseDB () |
Destructor. Disconnects from the database if connected. | |
void | set_config (const Config &config) |
Sets the configuration for the database. | |
Config | get_config () const |
Gets the current configuration of the database. | |
void | connect () |
Connects to the database using the current configuration. Initializes a connection to the database by creating necessary directories, opening the database, creating tables, and setting up database parameters. | |
void | connect (const Config &config) |
Connects to the database with the given configuration. | |
void | disconnect () |
Disconnects from the database. | |
void | begin (const TransactionMode &mode=TransactionMode::DEFERRED) |
Begins a database transaction. | |
void | commit () |
Commits the current transaction. | |
void | rollback () |
Rolls back the current transaction. | |
template<typename Func > | |
void | execute_in_transaction (Func operation, const TransactionMode &mode) |
Executes an operation inside a transaction. | |
virtual void | process () |
Processes asynchronous database requests (can be overridden). | |
Private Member Functions | |
void | db_create_table (const Config &config) override final |
Creates the tables in the database. This method creates both the main and temporary tables for keys, values, and key-value pairs. | |
template<template< class... > class ContainerT> | |
void | db_load (ContainerT< KeyT, ValueT > &container) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | db_load (ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Loads data from the database into the container. | |
template<template< class... > class ContainerT> | |
void | db_append (const ContainerT< KeyT, ValueT > &container) |
Appends the content of the container to the database. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | db_append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Appends the content of the container to the database. | |
void | db_insert (const KeyT &key, const ValueT &value) |
Inserts a key-value pair into the database. | |
template<template< class... > class ContainerT> | |
void | db_reconcile (const ContainerT< KeyT, ValueT > &container) |
Reconciles the database with the provided container. This method compares the content of the provided container with the database, ensuring that all key-value pairs are synchronized. If keys or values do not exist in the database, they are inserted. If old data exists in the database, it is removed. | |
template<typename T > | |
std::vector< std::pair< T, int > >::iterator | find_or_insert (std::vector< std::pair< T, int > > &vec, const T &value, typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, std::vector< char > >::value &&!std::is_same< T, std::vector< uint8_t > >::value &&std::is_trivially_copyable< T >::value >::type *=0) |
Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value. | |
template<typename T > | |
std::vector< std::pair< T, int > >::iterator | find_or_insert (std::vector< std::pair< T, int > > &vec, const T &value, typename std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||std::is_same< T, std::string >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< uint8_t > >::value >::type *=0) |
Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value. | |
template<template< class... > class ContainerT, template< class... > class ValueContainerT> | |
void | db_reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container) |
Reconciles the database with the provided container, ensuring data integrity. | |
template<template< class... > class ContainerT> | |
bool | db_find (const KeyT &key, ContainerT< ValueT > &container) |
Finds values by key in the database. | |
void | db_set_value_count_key_value (const KeyT &key, const ValueT &value, const size_t &value_count) |
Sets the value count for a key-value pair in the database. | |
void | db_remove_key_value (const KeyT &key, const ValueT &value) |
Removes a specific key-value pair from the database. | |
void | db_remove_all_values (const KeyT &key) |
Removes all values associated with a key from the database. | |
std::size_t | db_get_value_count_key_value (const KeyT &key, const ValueT &value) const |
Retrieves the count of a specific value associated with a key in the database. | |
std::size_t | db_count_key () const |
Returns the number of elements in the database. | |
void | db_clear () |
Clears all key-value pairs from the database. | |
void | db_insert_key (const KeyT &key) |
Inserts a key into the database. | |
int64_t | db_get_key_id (const KeyT &key) |
Retrieves the ID of a key from the database. | |
void | db_insert_value (const ValueT &value) |
Inserts a value into the database. | |
int64_t | db_get_value_id (const ValueT &value) |
Retrieves the ID of a value from the database. | |
void | db_insert_key_temp (const KeyT &key) |
Inserts a key into the temporary keys table. | |
void | db_insert_value_temp (const ValueT &value) |
Inserts a value into the temporary values table. | |
void | db_insert_key_value (const int64_t &key_id, const int64_t &value_id) |
Inserts a key-value pair into the key-value table. | |
std::size_t | db_get_value_count (const int64_t &key_id, const int64_t &value_id) |
Retrieves the count of values associated with a specific key-value pair. | |
void | db_set_value_count (const int64_t &key_id, const int64_t &value_id, const size_t &value_count) |
Sets the count of values associated with a specific key-value pair. | |
void | db_purge_old_data () |
Removes old keys and values that are no longer in the temporary tables. | |
void | db_clear_temp_tables () |
Clears the temporary keys and values tables. | |
Private Attributes | |
SqliteStmt | m_stmt_load |
Statement for loading data from the database. | |
SqliteStmt | m_stmt_insert_key |
Statement for inserting a key. | |
SqliteStmt | m_stmt_insert_value |
Statement for inserting a value. | |
SqliteStmt | m_stmt_insert_key_value |
Statement for inserting a key-value pair. | |
SqliteStmt | m_stmt_get_key_id |
Statement for retrieving key ID. | |
SqliteStmt | m_stmt_get_value_id |
Statement for retrieving value ID. | |
SqliteStmt | m_stmt_get_value_count |
Statement for retrieving the count of a value. | |
SqliteStmt | m_stmt_get_value_count_kv |
Statement for retrieving the count of a value by key-value pair. | |
SqliteStmt | m_stmt_count_key |
Statement for counting the number of keys. | |
SqliteStmt | m_stmt_insert_key_temp |
Statement for inserting keys into the temporary table. | |
SqliteStmt | m_stmt_insert_value_temp |
Statement for inserting values into the temporary table. | |
SqliteStmt | m_stmt_purge_keys |
Statement for purging old keys. | |
SqliteStmt | m_stmt_purge_values |
Statement for purging old values. | |
SqliteStmt | m_stmt_clear_keys_temp |
Statement for clearing the temporary keys table. | |
SqliteStmt | m_stmt_clear_values_temp |
Statement for clearing the temporary values table. | |
SqliteStmt | m_stmt_set_value_count |
Statement for setting value count for a key-value pair. | |
SqliteStmt | m_stmt_set_value_count_kv |
Statement for setting value count by key-value pair. | |
SqliteStmt | m_stmt_find |
Statement for finding values by key. | |
SqliteStmt | m_stmt_remove_key_value |
Statement for removing a specific key-value pair. | |
SqliteStmt | m_stmt_remove_all_values |
Statement for removing all values associated with a key. | |
SqliteStmt | m_stmt_clear_keys |
Statement for clearing the keys table. | |
SqliteStmt | m_stmt_clear_values |
Statement for clearing the values table. | |
SqliteStmt | m_stmt_clear_key_values |
Statement for clearing the key-value pairs table. | |
Additional Inherited Members | |
Protected Member Functions inherited from sqlite_containers::BaseDB | |
void | db_begin (const TransactionMode &mode=TransactionMode::DEFERRED) |
Begins a transaction with the given mode. | |
void | db_commit () |
Commits the current transaction. | |
void | db_rollback () |
Rolls back the current transaction. | |
void | db_handle_exception (std::exception_ptr ex, const std::vector< SqliteStmt * > &stmts, const std::string &message="Unknown error occurred.") const |
Handles an exception by resetting and clearing bindings of prepared SQL statements. | |
virtual void | on_db_open () |
Called after the database is opened. Can be overridden in derived classes. | |
virtual void | on_db_close () |
Called before the database is closed. Can be overridden in derived classes. | |
Protected Attributes inherited from sqlite_containers::BaseDB | |
sqlite3 * | m_sqlite_db = nullptr |
std::mutex | m_sqlite_mutex |
Template class for managing key-value pairs in a SQLite database, where each key can map to multiple values.
KeyT | Type of the keys. |
ValueT | Type of the values. |
This class allows managing key-value pairs where each key can have multiple associated values. It supports operations on containers like std::multimap
, std::unordered_multimap
, or containers where keys map to collections of values, such as std::map<KeyT, std::vector<ValueT>>
. The class provides methods for loading, appending, and reconciling key-value pairs with transactional integrity. It also supports custom containers for both keys and values, offering flexibility in data structures used for mapping. Temporary tables and bulk operations are employed for efficient reconciliation, with mechanisms to ensure data consistency between the database and in-memory structures.
Definition at line 22 of file KeyMultiValueDB.hpp.
|
inline |
Default constructor.
Definition at line 26 of file KeyMultiValueDB.hpp.
|
inline |
Constructor with configuration.
config | Configuration settings for the database. |
Definition at line 30 of file KeyMultiValueDB.hpp.
|
finaloverridedefault |
Destructor.
|
inline |
Appends the content of the container to the database.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
container | Container with content to be appended to the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 265 of file KeyMultiValueDB.hpp.
|
inline |
Appends the content of the container to the database with a transaction.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
container | Container with content to be appended to the database. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 251 of file KeyMultiValueDB.hpp.
|
inline |
Appends the content of the container to the database.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
container | Container with content to be appended to the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 238 of file KeyMultiValueDB.hpp.
|
inline |
Appends the content of the container to the database with a transaction.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
container | Container with content to be appended to the database. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 225 of file KeyMultiValueDB.hpp.
|
inline |
Clears all key-value pairs from the database.
mode | Transaction mode (defaults to the mode from the configuration). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 476 of file KeyMultiValueDB.hpp.
|
inline |
Clears all key-value pairs from the database with a transaction.
mode | Transaction mode (defaults to the mode from the configuration). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 467 of file KeyMultiValueDB.hpp.
|
inline |
Returns the number of elements in the database. This method returns the number of unique keys stored in the database, not the number of key-value pairs.
sqlite_exception | if an SQLite error occurs. |
Definition at line 434 of file KeyMultiValueDB.hpp.
|
inline |
Alias for get_value_count(). This method is an alias for get_value_count() and performs the same operation.
key | The key of the pair. |
value | The value of the pair. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 413 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Appends the content of the container to the database.
ContainerT | Template for the container type. |
ValueContainerT | Template for the container type used for values. |
container | Container with content to be appended to the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 754 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Appends the content of the container to the database.
ContainerT | Template for the container type. |
container | Container with content to be appended to the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 715 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Clears all key-value pairs from the database.
sqlite_exception | if an SQLite error occurs. |
Definition at line 1159 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Clears the temporary keys and values tables.
sqlite_exception | if an SQLite error occurs. |
Definition at line 1299 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Returns the number of elements in the database.
sqlite_exception | if an SQLite error occurs. |
Definition at line 1125 of file KeyMultiValueDB.hpp.
|
inlinefinaloverrideprivatevirtual |
Creates the tables in the database. This method creates both the main and temporary tables for keys, values, and key-value pairs.
config | Configuration settings for the database, such as table names. |
Implements sqlite_containers::BaseDB.
Definition at line 526 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Finds values by key in the database.
ContainerT | Template for the container type. |
key | The key to search for. |
values | The container to store the values associated with the key. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1021 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Retrieves the ID of a key from the database.
key | The key whose ID is to be retrieved. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1189 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Retrieves the count of values associated with a specific key-value pair.
key_id | The ID of the key. |
value_id | The ID of the value. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1262 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Retrieves the count of a specific value associated with a key in the database.
key | The key. |
value | The value. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1102 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Retrieves the ID of a value from the database.
value | The value whose ID is to be retrieved. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1214 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a key-value pair into the database.
key | The key to be inserted. |
value | The value to be inserted. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 794 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a key into the database.
key | The key to be inserted. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1178 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a key into the temporary keys table.
key | The key to be inserted into the temporary table. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1228 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a key-value pair into the key-value table.
key_id | The ID of the key. |
value_id | The ID of the value. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1249 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a value into the database.
value | The value to be inserted. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1203 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Inserts a value into the temporary values table.
value | The value to be inserted into the temporary table. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1238 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Loads data from the database into the container.
ContainerT | Template for the map container type. |
ValueContainerT | Template for the container type used for values. |
container | Container to load the data into. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 676 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Loads data from the database into the container.
ContainerT | Template for the container type. |
container | Container to load the data into. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 636 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Removes old keys and values that are no longer in the temporary tables.
sqlite_exception | if an SQLite error occurs. |
Definition at line 1290 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Reconciles the database with the provided container, ensuring data integrity.
ContainerT | Template for the container type. |
container | Container with content to reconcile with the database. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 948 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Reconciles the database with the provided container. This method compares the content of the provided container with the database, ensuring that all key-value pairs are synchronized. If keys or values do not exist in the database, they are inserted. If old data exists in the database, it is removed.
ContainerT | Template for the container type (e.g., std::map, std::unordered_map). |
container | The container with key-value pairs to reconcile with the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 835 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Removes all values associated with a key from the database.
key | The key of the pairs to be removed. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1083 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Removes a specific key-value pair from the database.
key | The key of the pair to be removed. |
value | The value of the pair to be removed. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1065 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Sets the count of values associated with a specific key-value pair.
key_id | The ID of the key. |
value_id | The ID of the value. |
value_count | The count to be set. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1279 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Sets the value count for a key-value pair in the database.
key | The key. |
value | The value. |
value_count | The count of the value associated with the key. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 1045 of file KeyMultiValueDB.hpp.
|
inline |
Checks if the database is empty. This method checks if there are any keys stored in the database.
sqlite_exception | if an SQLite error occurs. |
Definition at line 443 of file KeyMultiValueDB.hpp.
|
inline |
Finds values by key in the database.
ContainerT | Template for the container type. |
key | The key to search for. |
values | The container to store the values associated with the key. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 425 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.
T | The type of the value. |
vec | The vector where the value will be searched or inserted. |
value | The value to search or insert. |
Definition at line 899 of file KeyMultiValueDB.hpp.
|
inlineprivate |
Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.
T | The type of the value. |
vec | The vector where the value will be searched or inserted. |
value | The value to search or insert. |
Definition at line 926 of file KeyMultiValueDB.hpp.
|
inline |
Retrieves the count of values associated with a specific key-value pair from the database. This method returns the number of associations between a given key and value in the database.
key | The key of the pair. |
value | The value of the pair. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 402 of file KeyMultiValueDB.hpp.
|
inline |
Inserts a key-value pair into the database.
key | The key to be inserted. |
value | The value to be inserted. |
mode | Transaction mode (defaults to the mode from the configuration). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 341 of file KeyMultiValueDB.hpp.
|
inline |
Inserts a key-value pair into the database with a transaction.
key | The key to be inserted. |
value | The value to be inserted. |
mode | Transaction mode (defaults to the mode from the configuration). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 327 of file KeyMultiValueDB.hpp.
|
inline |
Inserts a key-value pair into the database.
pair | The key-value pair to be inserted. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 363 of file KeyMultiValueDB.hpp.
|
inline |
Inserts a key-value pair into the database with a transaction.
pair | The key-value pair to be inserted. |
mode | Transaction mode (defaults to the mode from the configuration). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 352 of file KeyMultiValueDB.hpp.
|
inline |
Loads data from the database into the container.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
container | Container to load the data into. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 157 of file KeyMultiValueDB.hpp.
|
inline |
Loads data from the database into the container.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
container | Container to load the data into. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 143 of file KeyMultiValueDB.hpp.
|
inline |
Loads data from the database into the container.
ContainerT | Template for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
container | Container to load the data into. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 130 of file KeyMultiValueDB.hpp.
|
inline |
Loads data from the database into the container.
ContainerT | Template for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
container | Container to load the data into. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 117 of file KeyMultiValueDB.hpp.
|
inline |
Loads all key-value pairs from the database into a container.
ContainerT | The type of the container (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 80 of file KeyMultiValueDB.hpp.
|
inline |
Loads all key-value pairs, where each key maps to a collection of values, from the database.
ContainerT | Template for the outer container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
ValueContainerT | Template for the inner container type used for values (e.g., std::vector, std::set). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 98 of file KeyMultiValueDB.hpp.
|
inline |
Assigns a container where each key maps to a collection of values to the database.
ContainerT | Template for the outer container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
ValueContainerT | Template for the inner container type used for values (e.g., std::vector, std::set). |
container | The container where each key maps to a collection of values. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 64 of file KeyMultiValueDB.hpp.
|
inline |
Assigns a container (e.g., std::multimap or std::unordered_multimap) to the database.
ContainerT | Template for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap). |
container | The container with key-value pairs to be inserted into the database. |
sqlite_exception | if an SQLite error occur. |
Definition at line 46 of file KeyMultiValueDB.hpp.
|
inline |
Reconciles the content of the container with the database.
ContainerT | Template for the container type (map or unordered_map). |
ValueContainerT | Template for the container type used for values. |
container | Container with content to be reconciled with the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 317 of file KeyMultiValueDB.hpp.
|
inline |
Reconciles the content of the container with the database with a transaction.
ContainerT | Template for the container type (map or unordered_map). |
ValueContainerT | Template for the container type used for values. |
container | Container with content to be reconciled with the database. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 303 of file KeyMultiValueDB.hpp.
|
inline |
Reconciles the content of the container with the database.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
container | Container with content to be reconciled with the database. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 290 of file KeyMultiValueDB.hpp.
|
inline |
Reconciles the content of the container with the database with a transaction.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
container | Container with content to be reconciled with the database. |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 277 of file KeyMultiValueDB.hpp.
|
inline |
Removes all values associated with a key from the database.
key | The key of the pairs to be removed. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 459 of file KeyMultiValueDB.hpp.
|
inline |
Removes a specific key-value pair from the database.
key | The key of the pair to be removed. |
value | The value of the pair to be removed. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 451 of file KeyMultiValueDB.hpp.
|
inline |
Retrieves all key-value pairs from the database.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 183 of file KeyMultiValueDB.hpp.
|
inline |
Retrieves all key-value pairs from the database.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
sqlite_exception | if an SQLite error occurs. |
Definition at line 212 of file KeyMultiValueDB.hpp.
|
inline |
Retrieves all key-value pairs from the database with a transaction.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 169 of file KeyMultiValueDB.hpp.
|
inline |
Retrieves all key-value pairs from the database with a transaction.
ContainerT | Template for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap). |
ValueContainerT | Template for the container type used for values (e.g., std::vector, std::set). |
mode | Transaction mode. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 197 of file KeyMultiValueDB.hpp.
|
inline |
Alias for set_value_count(). This method is an alias for set_value_count() and performs the same operation.
key | The key of the pair. |
value | The value of the pair. |
value_count | The count to set. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 388 of file KeyMultiValueDB.hpp.
|
inline |
Sets the count of values associated with a specific key-value pair in the database.
key | The key of the pair. |
value | The value of the pair. |
value_count | The count to set. |
sqlite_exception | if an SQLite error occurs. |
Definition at line 374 of file KeyMultiValueDB.hpp.
|
private |
Statement for clearing the key-value pairs table.
Definition at line 521 of file KeyMultiValueDB.hpp.
|
private |
Statement for clearing the keys table.
Definition at line 519 of file KeyMultiValueDB.hpp.
|
private |
Statement for clearing the temporary keys table.
Definition at line 506 of file KeyMultiValueDB.hpp.
|
private |
Statement for clearing the values table.
Definition at line 520 of file KeyMultiValueDB.hpp.
|
private |
Statement for clearing the temporary values table.
Definition at line 507 of file KeyMultiValueDB.hpp.
|
mutableprivate |
Statement for counting the number of keys.
Definition at line 495 of file KeyMultiValueDB.hpp.
|
private |
Statement for finding values by key.
Definition at line 513 of file KeyMultiValueDB.hpp.
|
private |
Statement for retrieving key ID.
Definition at line 490 of file KeyMultiValueDB.hpp.
|
private |
Statement for retrieving the count of a value.
Definition at line 492 of file KeyMultiValueDB.hpp.
|
mutableprivate |
Statement for retrieving the count of a value by key-value pair.
Definition at line 493 of file KeyMultiValueDB.hpp.
|
private |
Statement for retrieving value ID.
Definition at line 491 of file KeyMultiValueDB.hpp.
|
private |
Statement for inserting a key.
Definition at line 486 of file KeyMultiValueDB.hpp.
|
private |
Statement for inserting keys into the temporary table.
Definition at line 498 of file KeyMultiValueDB.hpp.
|
private |
Statement for inserting a key-value pair.
Definition at line 488 of file KeyMultiValueDB.hpp.
|
private |
Statement for inserting a value.
Definition at line 487 of file KeyMultiValueDB.hpp.
|
private |
Statement for inserting values into the temporary table.
Definition at line 499 of file KeyMultiValueDB.hpp.
|
private |
Statement for loading data from the database.
Definition at line 484 of file KeyMultiValueDB.hpp.
|
private |
Statement for purging old keys.
Definition at line 502 of file KeyMultiValueDB.hpp.
|
private |
Statement for purging old values.
Definition at line 503 of file KeyMultiValueDB.hpp.
|
private |
Statement for removing all values associated with a key.
Definition at line 517 of file KeyMultiValueDB.hpp.
|
private |
Statement for removing a specific key-value pair.
Definition at line 516 of file KeyMultiValueDB.hpp.
|
private |
Statement for setting value count for a key-value pair.
Definition at line 510 of file KeyMultiValueDB.hpp.
|
private |
Statement for setting value count by key-value pair.
Definition at line 511 of file KeyMultiValueDB.hpp.