Data_deduplication_service
Service that will use hashes to deduplicate files
|
db_services namespace More...
Classes | |
class | dbManager |
Database manager that handles database management. More... | |
struct | myConnString |
Structure to store and format connection string. More... | |
Typedefs | |
using | indexType = int64_t |
using | trasnactionType = pqxx::transaction< pqxx::isolation_level::read_committed > |
using | connectionType = pqxx::connection |
using | conPtr = std::shared_ptr< connectionType > |
using | resType = pqxx::result |
using | nonTransType = pqxx::nontransaction |
Functions | |
std::string | toSpacedPath (std::string_view path) |
std::string | fromSpacedPath (std::string_view path) |
std::string | toTsquerablePath (std::string_view path) |
bool | checkConnection (const conPtr &conn) |
bool | checkConnString (const myConnString &connString) |
tl::expected< conPtr, returnCodes > | connectIfPossible (std::string_view cString) |
resType | terminateAllDbConnections (nonTransType &noTransExec, std::string_view dbName) |
resType | checkDatabaseExistence (nonTransType &noTransExec, std::string_view dbName) |
resType | checkSchemas (trasnactionType &txn) |
indexType | checkSegmentCount (trasnactionType &txn) |
resType | deleteUnusedSegments (trasnactionType &txn) |
resType | checkFileExistence (trasnactionType &txn, std::string_view fileName) |
resType | checkFilesExistence (trasnactionType &txn, const std::vector< std::filesystem::path > &files) |
indexType | getFileId (trasnactionType &txn, std::string_view fileName) |
bool | doesFileExist (trasnactionType &txn, std::string_view fileName) |
resType | getEntriesForDirectory (trasnactionType &txn, std::string_view dirPath) |
std::vector< indexType > | getFileIdVector (trasnactionType &txn, std::string_view dirPath) |
tl::expected< indexType, int > | getTotalFileSize (trasnactionType &txn) |
resType | getTotalSchemaSizes (trasnactionType &txn) |
resType | getDedupCharacteristics (trasnactionType &txn) |
resType | getFileSizes (trasnactionType &txn) |
void | printRes (resType &rss, std::ostream &out) |
template<printable T> | |
std::string | vecToString (std::vector< T > &vec) |
void | printRowsAffected (const resType &res) |
resType | checkTExistence (db_services::trasnactionType &txn, std::string_view fileName) |
myConnString | loadConfiguration (std::string_view filename) |
template<typename T , unsigned long size> | |
std::array< T, size > | fromString (std::basic_string< T > &string) |
template<typename ResultType , typename ... Args> | |
tl::expected< ResultType, int > | executeInTransaction (conPtr &conn, ResultType(*call)(trasnactionType &, Args ...), Args &&... args) |
template<typename ResultType , typename ... Args> | |
tl::expected< ResultType, int > | executeInTransaction (conPtr &conn, const std::function< ResultType(trasnactionType &, Args ...)> &call, Args &&... args) |
void | diconnect (conPtr &conn) |
db_services namespace
using db_services::connectionType = typedef pqxx::connection |
using db_services::conPtr = typedef std::shared_ptr<connectionType> |
using db_services::indexType = typedef int64_t |
using db_services::nonTransType = typedef pqxx::nontransaction |
using db_services::resType = typedef pqxx::result |
using db_services::trasnactionType = typedef pqxx::transaction<pqxx::isolation_level::read_committed> |
bool db_services::checkConnection | ( | const conPtr & | conn | ) |
Checks that conn is not null and opened
conn |
bool db_services::checkConnString | ( | const myConnString & | connString | ) |
Checks connection for connString
connString |
resType db_services::checkDatabaseExistence | ( | nonTransType & | noTransExec, |
std::string_view | dbName | ||
) |
Checks database existence
noTransExec | |
dbName |
resType db_services::checkFileExistence | ( | trasnactionType & | txn, |
std::string_view | fileName | ||
) |
Checks file existence
txn | |
fileName |
resType db_services::checkFilesExistence | ( | trasnactionType & | txn, |
const std::vector< std::filesystem::path > & | files | ||
) |
Multifile variant for checkFileExistence
txn | |
files |
resType db_services::checkSchemas | ( | trasnactionType & | txn | ) |
Returns all schemas for database
txn |
indexType db_services::checkSegmentCount | ( | trasnactionType & | txn | ) |
Compares segments counts from segments table to total counst from data table
txn |
resType db_services::checkTExistence | ( | db_services::trasnactionType & | txn, |
std::string_view | fileName | ||
) |
Checks whether temporary table was created for file
txn | |
fileName |
tl::expected< conPtr, returnCodes > db_services::connectIfPossible | ( | std::string_view | cString | ) |
Connects to database with cString
cString |
resType db_services::deleteUnusedSegments | ( | trasnactionType & | txn | ) |
Deletes segments with count=0
txn |
void db_services::diconnect | ( | db_services::conPtr & | conn | ) |
Closes and deletes connection
conn |
bool db_services::doesFileExist | ( | trasnactionType & | txn, |
std::string_view | fileName | ||
) |
Bool variant for existence checks
txn | |
fileName |
tl::expected<ResultType, int> db_services::executeInTransaction | ( | conPtr & | conn, |
const std::function< ResultType(trasnactionType &, Args ...)> & | call, | ||
Args &&... | args | ||
) |
Functional variant of previous call
ResultType | |
Args |
conn | not null connection |
call | |
args |
tl::expected<ResultType, int> db_services::executeInTransaction | ( | conPtr & | conn, |
ResultType(*)(trasnactionType &, Args ...) | call, | ||
Args &&... | args | ||
) |
Wraps function in transaction block
ResultType | |
Args |
conn | not null connection |
call | |
args |
std::string db_services::fromSpacedPath | ( | std::string_view | path | ) |
Swaps space syblos for /
path |
std::array<T, size> db_services::fromString | ( | std::basic_string< T > & | string | ) |
resType db_services::getDedupCharacteristics | ( | trasnactionType & | txn | ) |
Calculates main deduplication characteristics for files
txn |
resType db_services::getEntriesForDirectory | ( | trasnactionType & | txn, |
std::string_view | dirPath | ||
) |
Returns resType that contains all file/subdirectory entries for the selected directory
txn | |
dirPath |
indexType db_services::getFileId | ( | trasnactionType & | txn, |
std::string_view | fileName | ||
) |
Parses one file id from request
txn | |
fileName |
std::vector< indexType > db_services::getFileIdVector | ( | trasnactionType & | txn, |
std::string_view | dirPath | ||
) |
Vector returning wrapper for getEntriesForDirectory
txn | |
dirPath |
resType db_services::getFileSizes | ( | trasnactionType & | txn | ) |
tl::expected< indexType, int > db_services::getTotalFileSize | ( | trasnactionType & | txn | ) |
Calculates sum of files sizes
txn |
resType db_services::getTotalSchemaSizes | ( | trasnactionType & | txn | ) |
Gets table thta contains schemas sizes for database
txn |
myConnString db_services::loadConfiguration | ( | std::string_view | filename | ) |
Loads configuration from file
filename |
void db_services::printRes | ( | resType & | rss, |
std::ostream & | out | ||
) |
Peinrst resType to ostream
rss | |
out |
void db_services::printRowsAffected | ( | const resType & | res | ) |
Gets affected rows for delete/update query result
res |
resType db_services::terminateAllDbConnections | ( | nonTransType & | noTransExec, |
std::string_view | dbName | ||
) |
Terminates all connections to dbName via sql query
noTransExec | |
dbName |
std::string db_services::toSpacedPath | ( | std::string_view | path | ) |
Swaps / symbols for spaces
path |
std::string db_services::toTsquerablePath | ( | std::string_view | path | ) |
Replaces symbols in path to cast it to tsquery
path |
std::string db_services::vecToString | ( | std::vector< T > & | vec | ) |
T |
vec |