SwatDB
include
file.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
21
class
Catalog
;
22
class
BufferManager
;
23
class
Schema
;
24
25
/* The class heirarchy:
26
*
27
* File
28
*
29
* / | \
30
* HeapFile Sorted File IndexFile
31
* / \
32
* BTreeIndex HashIndex
33
*/
34
42
// TODO: not fully implemented
43
class
File
{
44
45
public
:
46
61
File
(
Catalog
*
catalog
,
BufferManager
*
buf_mgr
,
Schema
*
schema
);
62
68
virtual
~File
();
69
74
virtual
void
createHeader
() = 0;
75
80
virtual
void
flushHeader
() = 0;
81
87
FileId
getMyFid
();
88
89
// TODO add this method: maybe protected with Catalog friend
90
// void setMyFID(FileId *file_id);
91
92
98
Schema
*
getSchema
();
99
108
PageId
getHeaderId
();
109
110
protected
:
111
115
FileId
file_id
;
116
120
Catalog
*
catalog
;
121
125
BufferManager
*
buf_mgr
;
126
132
Schema
*
schema
;
133
137
PageId
header_id
;
138
157
void
_setMyFid
(
FileId
file_id);
158
159
friend
class
Catalog
;
160
friend
class
FileManager
;
161
};
File::createHeader
virtual void createHeader()=0
Allocates and initializes the header. Is a virtual method to be overridden at each derived class...
File::_setMyFid
void _setMyFid(FileId file_id)
Sets the file_id and the schema fields of this File.
Schema
Definition:
schema.h:27
FileManager
Definition:
filemgr.h:31
File::catalog
Catalog * catalog
Definition:
file.h:120
File::flushHeader
virtual void flushHeader()=0
Flushes Header Page to disk. Is a virtual method to be overridden at each derived class...
BufferManager
Definition:
bufmgr.h:248
File::getHeaderId
PageId getHeaderId()
Returns Header PageId.
File::header_id
PageId header_id
Definition:
file.h:137
PageId
Definition:
swatdb_types.h:50
swatdb_types.h
File::File
File(Catalog *catalog, BufferManager *buf_mgr, Schema *schema)
Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema.
File::getMyFid
FileId getMyFid()
Returns the FileId of the File.
File::getSchema
Schema * getSchema()
Returns the schema of the File.
File::file_id
FileId file_id
Definition:
file.h:115
File::~File
virtual ~File()
Destructor. Data members are cleaned up, but none of the dynamically allocated data members are not d...
Catalog
Definition:
catalog.h:134
FileId
std::uint32_t FileId
Definition:
swatdb_types.h:29
File
Definition:
file.h:43
File::buf_mgr
BufferManager * buf_mgr
Definition:
file.h:125
File::schema
Schema * schema
Definition:
file.h:132
Generated by
1.8.13