SwatDB
|
#include <swatdb.h>
Public Member Functions | |
SwatDB () | |
Constructor. More... | |
SwatDB (std::string metadata_filename) | |
Constructor to init SwatDB from a metadata file. More... | |
~SwatDB () | |
Shutdown SwatDB. More... | |
void | setDestroyDB () |
sets the DB to be destroyed on shutdown. More... | |
void | setSaveDB (std::string filename) |
sets the DB to be saved on shutdown. More... | |
Catalog * | getCatalog () |
Gets the SwatDB Catalog. | |
DiskManager * | getDiskMgr () |
Gets the SwatDB DiskManager. | |
BufferManager * | getBufMgr () |
Gets the SwatDB BufferManager. | |
FileManager * | getFileMgr () |
Gets the SwatDB FileManager. | |
Private Attributes | |
Catalog * | cat |
DiskManager * | disk_mgr |
BufferManager * | buf_mgr |
FileManager * | file_mgr |
bool | saved |
std::string | inited_file_name |
std::string | saved_file_name |
SwatDB. This is the class definition of the high-level SwatDB object that stores all state about the Swat DBMS system as it runs. This includes:
It contains methods to boot SwatDB and to save or delete SwatDB, as well as to access layer manager objects for the different parts of the system.
On (or before) shutdown a caller should decide if they want to save or destroy the db and do so before invoking the destructor (the default is to destroy if neither have been invoked):
swatdb->setSaveDB() swatdb->setDestroyDB() delete swatdb delete swatdb
SwatDB::SwatDB | ( | ) |
Constructor.
Initialize/boot swatDB. Initializes an empty swatDB and creates default manager objects for all the layers
SwatDB::SwatDB | ( | std::string | metadata_filename | ) |
Constructor to init SwatDB from a metadata file.
This method creates RelationFile and IndexFile objects associated with each stored file listed in the metadata. SwatDB creates the diskmgr before the file manager, and it opens the relation and index files on disk and checks that they exist.
metadata_filename | the name of the input file containing information about the DB state to init SwatDB with |
exceptions | from system layers with init errors |
SwatDB::~SwatDB | ( | ) |
Shutdown SwatDB.
If saveDB is not called before the destructor is invoked then the destructor calls destroyDB to remove all relation and index files from the system
void SwatDB::setDestroyDB | ( | ) |
sets the DB to be destroyed on shutdown.
This method can be called prior to shuting down swatDB if the current state of swatDB does not want to be saved (destroy on exit is the default). This method does not actually remove db files from the system but sets a flag to trigger the right actions by the destructor on shutdown.
void SwatDB::setSaveDB | ( | std::string | filename | ) |
sets the DB to be saved on shutdown.
This method should be called prior to shuting down swatDB to save the state of the db on shutdown. This method does not actually save the state at the point it is called but set up the system to save the state on shutdown
filename | name of swatDB meta data file to which to save db metadata state on shutdown of swatDB |
|
private |
SwatDB's Buffer Manager
|
private |
SwatDB's Disk Manager
|
private |
SwatDB's Buffer Manager
|
private |
name of file from which DB was booted, may be nullptr
|
private |
Flag to indicate if swatDB metadata should be saved to a file on shutdown (if setSaveDB has been called) true: save it on shutdown, If false, destroies its state on shutdown.
|
private |
name of file to save DB to on exit