SwatDB
include
heappage.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 <cstddef>
17
#include <mutex>
18
#include "
swatdb_types.h
"
19
#include "
page.h
"
20
21
class
Data
;
22
26
class
HeapPage
;
27
33
struct
HeapPageHeader
{
34
38
PageNum
prev_page
;
39
43
PageNum
next_page
;
44
48
std::uint32_t
free_space_begin
;
49
53
std::uint32_t
free_space_end
;
54
58
std::uint32_t
size
;
59
63
std::uint32_t
capacity
;
64
};
65
70
struct
SlotInfo
{
71
76
uint32_t
offset
;
77
81
uint32_t
length
;
82
};
83
89
class
HeapPage
:
public
Page
{
90
91
friend
class
HeapPageScanner
;
92
93
public
:
94
103
HeapPage
() =
delete
;
104
108
~HeapPage
() {}
109
119
void
initializeHeader();
120
129
void
setNext(
PageNum
page_num);
130
139
void
setPrev(
PageNum
page_num);
140
149
PageNum
getNext
();
150
159
PageNum
getPrev();
160
161
173
std::uint32_t getFreeSpace();
174
184
bool
isFull();
185
194
bool
isEmpty();
195
218
SlotId insertRecord(
Data
*record_data);
219
236
void
getRecord(SlotId slot_id,
Data
*data);
237
256
void
deleteRecord(SlotId slot_id);
257
278
void
updateRecord(SlotId slot_id,
Data
*record_data);
279
284
HeapPageHeader
getHeader();
285
290
SlotInfo
getSlotInfo(SlotId slot_id);
291
296
std::uint32_t getInvalidNum();
297
302
void
printHeapPageState();
303
304
private
:
305
311
HeapPageHeader
* _getPageHeader();
312
322
SlotInfo
* _getSlotDirectory();
323
343
SlotId _getFreeSlot();
360
SlotInfo
* _getSlotInfo(SlotId slot_id);
379
void
_insertRecord(SlotId slot_id,
Data
* record_data);
401
void
_deleteRecord(SlotId slot_id);
404
};
HeapPageScanner::getNext
SlotId getNext()
Returns SlotId of the next valid slot.
SlotInfo::offset
uint32_t offset
Definition:
heappage.h:76
HeapPageHeader::free_space_end
std::uint32_t free_space_end
Definition:
heappage.h:53
PageNum
std::uint32_t PageNum
Definition:
swatdb_types.h:34
HeapPageHeader::prev_page
PageNum prev_page
Definition:
heappage.h:38
HeapPageHeader
Definition:
heappage.h:33
SlotInfo::length
uint32_t length
Definition:
heappage.h:81
HeapPageHeader::capacity
std::uint32_t capacity
Definition:
heappage.h:63
page.h
HeapPageHeader::size
std::uint32_t size
Definition:
heappage.h:58
HeapPage::~HeapPage
~HeapPage()
Definition:
heappage.h:108
HeapPage
Definition:
heappage.h:89
HeapPageHeader::next_page
PageNum next_page
Definition:
heappage.h:43
SlotInfo
Definition:
heappage.h:70
HeapPageHeader::free_space_begin
std::uint32_t free_space_begin
Definition:
heappage.h:48
swatdb_types.h
Data
Definition:
data.h:25
HeapPageScanner
Definition:
heappagescanner.h:31
Page
Definition:
page.h:25
Generated by
1.8.13