SwatDB
heapfile.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 <mutex>
19 #include "swatdb_types.h"
20 #include "file.h" //for inheritance
21 
22 class BufferManager;
23 class HeapPage;
24 class HeapPageScanner;
25 class Schema;
26 class Record;
27 
31 class HeapFile;
32 
38 
43 
48 
52  std::uint32_t free_size;
53 
57  std::uint32_t full_size;
58 
62  std::uint64_t num_records;
63 };
64 
71 class HeapFile : public File {
72 
73  friend class HeapFileScanner;
74 
75  public:
76 
90  HeapFile(Catalog *catalog, BufferManager *buf_mgr, Schema *schema);
91 
98  ~HeapFile() { }
99 
112  void createHeader();
113 
125  void flushHeader();
126 
153  RecordId insertRecord(Record record);
154 
175  void getRecord(RecordId record_id, Record* record);
176 
205  void updateRecord(RecordId record_id, Record record);
206 
228  void deleteRecord(RecordId record_id);
229 
234  HeapFileHeader getHeader();
235 
236  private:
237 
262  void _addPage(HeapPage* page, PageId page_id, bool full);
287  void _removePage(HeapPage* page, PageId page_id, bool full);
289 };
~HeapFile()
HeapFile destructor.
Definition: heapfile.h:98
std::uint32_t PageNum
Definition: swatdb_types.h:34
Definition: swatdb_types.h:66
Definition: heapfilescanner.h:31
BufferManager * buf_mgr
Definition: heapfilescanner.h:82
std::uint32_t full_size
Definition: heapfile.h:57
Definition: schema.h:27
Definition: heappage.h:89
std::uint64_t num_records
Definition: heapfile.h:62
Definition: bufmgr.h:248
std::uint32_t free_size
Definition: heapfile.h:52
Definition: heapfile.h:37
Definition: swatdb_types.h:50
PageNum free
Definition: heapfile.h:42
Definition: record.h:28
Definition: heapfile.h:71
Definition: catalog.h:134
Definition: file.h:43
Definition: heappagescanner.h:31
PageNum full
Definition: heapfile.h:47