SwatDB
filemgr.h
Go to the documentation of this file.
1 /*
2  * SwatDB
3  *
4  * @authors: See Contributors.doc for code contributors
5  *
6  * Copyright (c) 2020 Swarthmore College Computer Science Department
7  * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8  */
9 
10 #pragma once
11 
16 #include <string>
17 #include <vector>
18 #include "swatdb_types.h"
19 
20 // too many circular includes, just define these types like
21 // this and include the .h file for them in the .cpp files:
22 class BufferManager;
23 class Catalog;
24 class Schema;
25 class File;
26 
31 class FileManager {
32 
33  public:
34 
55  bool load = false); // default value paramater
56 
63  ~FileManager();
64 
95  FileId createRelation(std::string name, Schema *schema, CatType type,
96  std::string file_name);
97 
110  void removeRelation(std::string name);
111 
125  void removeFile(FileId file_id);
126 
138  File* getRelation(std::string name);
139 
151  File* getFile(FileId file_id);
152 
153 
154  protected:
155 
166  void _removeAllFiles();
167 
180  void _closeAllFiles();
181 
182  friend class SwatDB;
183 
184  private:
185 
198  void _loadAllFiles();
199 
240  void _loadFile(FileId fid);
241 
246 
251 
252 };
File * getFile(FileId file_id)
Retuns File object identified by the given FileId.
CatType
Definition: swatdb_types.h:98
void _closeAllFiles()
Flushes and closes all underlying files in the system, saving db state.
void _removeAllFiles()
Removes all Files in the system and their underlying storage from the database.
void _loadFile(FileId fid)
Loads an existing relation into the system, whose contents are already stored in a file on disk...
Definition: schema.h:27
~FileManager()
Destructor.
Definition: filemgr.h:31
void removeFile(FileId file_id)
Deletes a File or Index from the system and removes its underlying storage from the database...
Definition: bufmgr.h:248
File * getRelation(std::string name)
Retuns File object identified by the relation name.
FileManager(Catalog *cat, BufferManager *buf_mgr, bool load=false)
Creates SwatDB FileManager, the interface to the File layer.
Catalog * catalog
Definition: filemgr.h:245
BufferManager * buf_mgr
Definition: filemgr.h:250
void _loadAllFiles()
Loads all Files listed in the Catalog.
FileId createRelation(std::string name, Schema *schema, CatType type, std::string file_name)
Creates a new Relation in the system. Adds an entry for the new file to the Catalog and creates the u...
Definition: catalog.h:134
Definition: swatdb.h:46
std::uint32_t FileId
Definition: swatdb_types.h:29
Definition: file.h:43
void removeRelation(std::string name)
Deletes relation from the system and removes its underlying storage from the database.