SwatDB
Public Member Functions | Private Attributes | List of all members
SwatDB Class Reference

#include <swatdb.h>

Collaboration diagram for SwatDB:
Collaboration graph
[legend]

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...
 
CataloggetCatalog ()
 Gets the SwatDB Catalog.
 
DiskManagergetDiskMgr ()
 Gets the SwatDB DiskManager.
 
BufferManagergetBufMgr ()
 Gets the SwatDB BufferManager.
 
FileManagergetFileMgr ()
 Gets the SwatDB FileManager.
 

Private Attributes

Catalogcat
 
DiskManagerdisk_mgr
 
BufferManagerbuf_mgr
 
FileManagerfile_mgr
 
bool saved
 
std::string inited_file_name
 
std::string saved_file_name
 

Detailed Description

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

Constructor & Destructor Documentation

◆ SwatDB() [1/2]

SwatDB::SwatDB ( )

Constructor.

Initialize/boot swatDB. Initializes an empty swatDB and creates default manager objects for all the layers

◆ SwatDB() [2/2]

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.

Parameters
metadata_filenamethe name of the input file containing information about the DB state to init SwatDB with
Exceptions
exceptionsfrom system layers with init errors

◆ ~SwatDB()

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

Precondition
: SwatDB may have some relation and index files
Postcondition
: Based on if saveDB or destroyDB was invoked prior to the destructory either all index and relation files are saved and metadata about them is written out or all files and indexes removed from the system, and their associated storage on "disk" is also removed from the system. Any state created is removed from the system.

Member Function Documentation

◆ setDestroyDB()

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.

◆ setSaveDB()

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

Parameters
filenamename of swatDB meta data file to which to save db metadata state on shutdown of swatDB
Precondition
: a file with filename does or does not already exist in the system (or an existing one's contents will be replaced)
Postcondition
: flag is set to trigger saving db metadata to file on shutdown

Member Data Documentation

◆ buf_mgr

BufferManager* SwatDB::buf_mgr
private

SwatDB's Buffer Manager

◆ cat

Catalog* SwatDB::cat
private

◆ disk_mgr

DiskManager* SwatDB::disk_mgr
private

SwatDB's Disk Manager

◆ file_mgr

FileManager* SwatDB::file_mgr
private

SwatDB's Buffer Manager

◆ inited_file_name

std::string SwatDB::inited_file_name
private

name of file from which DB was booted, may be nullptr

◆ saved

bool SwatDB::saved
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.

◆ saved_file_name

std::string SwatDB::saved_file_name
private

name of file to save DB to on exit


The documentation for this class was generated from the following file: