Data_deduplication_service
Service that will use hashes to deduplicate files
|
Database manager that handles database management. More...
#include <dbManager.h>
Public Member Functions | |
dbManager () | |
dbManager (myConnString &ss) | |
void | setCString (myConnString &ss) |
const myConnString & | getCString () const |
int | connectToDb () |
void | disconnect () |
int | createDatabase (std::string_view dbName) |
int | dropDatabase (std::string_view dbName) |
int | fillSchemas () |
int | clearSegments () |
std::vector< std::pair< indexType, std::string > > | getAllFiles (std::string_view dirPath) |
indexType | createFile (std::string_view filePath, uintmax_t fileSize=0, size_t segmentSize=0, hash_function hash=SHA_256) |
indexType | createDirectory (std::string_view dirPath) |
int | deleteFile (std::string_view filePath, indexType fileId=paramType::EmptyParameterValue) |
int | deleteDirectory (std::string_view directoryPath) |
int | getFileStreamed (std::string_view fileName, std::ostream &output, indexType fileId=paramType::EmptyParameterValue) |
int | insertFileFromStream (std::string_view fileName, std::istream &in, size_t segmentSize, std::size_t fileSize, const hash_function &hash=SHA_256) |
int | finishFileProcessing (std::string_view filePath, indexType fileId) |
bool | checkConnection () |
~dbManager () | |
template<typename ResultType , typename ... Args> | |
tl::expected< ResultType, int > | executeInTransaction (ResultType(*call)(trasnactionType &, Args ...), Args &&... args) |
template<typename ResultType , typename ... Args> | |
tl::expected< ResultType, int > | executeInTransaction (const std::function< ResultType(trasnactionType &, Args ...)> &call, Args &&... args) |
Database manager that handles database management.
This class is designed to handle main interactions for database.
You can connect/create/deelte databases.
You can send requests for file load/delete/export.
Some external helper functions can be found in dbCommon.h
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
int db_services::dbManager::clearSegments | ( | ) |
Removes segments that are not used in files
int db_services::dbManager::connectToDb | ( | ) |
int db_services::dbManager::createDatabase | ( | std::string_view | dbName | ) |
Creates database entry and connect to it
dbName |
indexType db_services::dbManager::createDirectory | ( | std::string_view | dirPath | ) |
Creates entry for directory
dirPath |
indexType db_services::dbManager::createFile | ( | std::string_view | filePath, |
uintmax_t | fileSize = 0 , |
||
size_t | segmentSize = 0 , |
||
hash_function | hash = SHA_256 |
||
) |
Creates entry for a given file
filePath | |
fileSize |
int db_services::dbManager::deleteDirectory | ( | std::string_view | directoryPath | ) |
Recursively deletes all file data for selected directory
directoryPath |
int db_services::dbManager::deleteFile | ( | std::string_view | filePath, |
indexType | fileId = paramType::EmptyParameterValue |
||
) |
Recursively deletes all file data
filePath | |
fileId |
|
inline |
int db_services::dbManager::dropDatabase | ( | std::string_view | dbName | ) |
Deletes database entry
dbName |
|
inline |
Functional variant of previous function
ResultType | |
Args |
call | |
args |
|
inline |
Wraps function in transaction block
ResultType | |
Args |
call | |
args |
int db_services::dbManager::fillSchemas | ( | ) |
Create main database tables and indexes
int db_services::dbManager::finishFileProcessing | ( | std::string_view | filePath, |
indexType | fileId | ||
) |
Process bulk inserted file data
filePath | |
fileId |
std::vector< std::pair< indexType, std::string > > db_services::dbManager::getAllFiles | ( | std::string_view | dirPath | ) |
Get vector of pairs of file_names and file ids for directory
dirPath |
|
inline |
int db_services::dbManager::getFileStreamed | ( | std::string_view | fileName, |
std::ostream & | output, | ||
indexType | fileId = paramType::EmptyParameterValue |
||
) |
Recreates file contents and bulk insert them in out stream
fileName | |
output | |
fileId |
int db_services::dbManager::insertFileFromStream | ( | std::string_view | fileName, |
std::istream & | in, | ||
size_t | segmentSize, | ||
std::size_t | fileSize, | ||
const hash_function & | hash = SHA_256 |
||
) |
Bulk insert file segments into temporary table
fileName | |
in | |
fileSize | |
hash | hash function that will be used for hashing |
|
inline |