SwatDB
Classes | Typedefs | Enumerations | Variables
swatdb_types.h File Reference
#include <cstdint>
Include dependency graph for swatdb_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PageId
 
struct  RecordId
 

Typedefs

typedef std::uint32_t FileId
 
typedef std::uint32_t PageNum
 
typedef std::uint32_t FrameId
 Index of each frame in the bufferpool of BufferManager.
 
typedef std::uint32_t SlotId
 
typedef std::uint32_t FieldId
 

Enumerations

enum  FieldType { IntFieldT, FloatFieldT, StringFieldT }
 
enum  CatType {
  INVALID_CAT_TYPE, HeapFileT, SortedFileT, BPlusTreeT,
  HashIndexT
}
 

Variables

const std::uint32_t FILE_MAX_CAPACITY = 10000000
 
const std::uint32_t MAX_FILE_NUM = 1000
 
const std::uint32_t PAGE_SIZE = 1024
 
const std::uint32_t MAX_RECORD_SIZE = PAGE_SIZE - (8 * sizeof(std::uint32_t))
 
const std::uint32_t MAX_PAGE_NUM
 
const std::uint32_t MAX_FILE_NAME_LEN = 511
 
const std::uint32_t BUF_SIZE = 1024
 
const std::uint32_t INVALID_PAGE_NUM = MAX_PAGE_NUM+1
 
const std::uint32_t HEADER_PAGE_NUM = 0
 
const std::uint32_t INVALID_FILE_ID = MAX_FILE_NUM+1
 
const PageId INVALID_PAGE_ID = {INVALID_FILE_ID, INVALID_PAGE_NUM}
 
const std::uint32_t INVALID_SLOT_OFFSET = PAGE_SIZE+1
 
const SlotId INVALID_SLOT_ID = INVALID_SLOT_OFFSET
 
const RecordId INVALID_RECORD_ID = {INVALID_PAGE_NUM, INVALID_SLOT_ID}
 
const float MAX_HEAP_PAGE_LOAD = 0.9
 

Typedef Documentation

◆ FieldId

typedef std::uint32_t FieldId

Unique identifer of each field in a record

◆ FileId

typedef std::uint32_t FileId

SwatDB Types and Configuration. Definition of commonly used data types and constants used throughout the system Types defined by specific layers may be defined in interface .h files. Runtime unique identifer of each file. Reset everytime the system is rebooted.

◆ PageNum

typedef std::uint32_t PageNum

Unique identifer of each page in a single Unix file.

Enumeration Type Documentation

◆ CatType

enum CatType

Catalog entry types: one for each type of file or index in the system IMPORTANT: since the type is encoded in saved meta files on disk, you should ONLY APPEND to this list (don't remove a type, nor add a new one in the middle)

◆ FieldType

enum FieldType

Record field types

Variable Documentation

◆ BUF_SIZE

const std::uint32_t BUF_SIZE = 1024

Number of pages that can be held in the buffer pool.

◆ FILE_MAX_CAPACITY

const std::uint32_t FILE_MAX_CAPACITY = 10000000

SwatDB Constants Maximum capacity of each Unix file in bytes

◆ HEADER_PAGE_NUM

const std::uint32_t HEADER_PAGE_NUM = 0

PageNum of header page. Is 0 by default per the current implementation, but may change in the future.

◆ INVALID_FILE_ID

const std::uint32_t INVALID_FILE_ID = MAX_FILE_NUM+1

Default constant for PageNum that exceeds its maximum.

◆ INVALID_PAGE_ID

const PageId INVALID_PAGE_ID = {INVALID_FILE_ID, INVALID_PAGE_NUM}

Used for initializing a PageId to a default value that is not used

◆ INVALID_PAGE_NUM

const std::uint32_t INVALID_PAGE_NUM = MAX_PAGE_NUM+1

Default constant for FileId that exceeds its maximum.

◆ INVALID_RECORD_ID

const RecordId INVALID_RECORD_ID = {INVALID_PAGE_NUM, INVALID_SLOT_ID}

Default value of RecordId.

◆ INVALID_SLOT_ID

const SlotId INVALID_SLOT_ID = INVALID_SLOT_OFFSET

Default value of SlotId.

◆ INVALID_SLOT_OFFSET

const std::uint32_t INVALID_SLOT_OFFSET = PAGE_SIZE+1

Value slot offset of SlotInfo is set to when the slot is not valid. Used by inherited classes of Page class

◆ MAX_FILE_NAME_LEN

const std::uint32_t MAX_FILE_NAME_LEN = 511

Maximum length of a file name string in the system (not counting \0)

◆ MAX_FILE_NUM

const std::uint32_t MAX_FILE_NUM = 1000

Maximum number of Unix files that can be created during one run of SwatDB (a real long running system would have much larger value for this)

◆ MAX_HEAP_PAGE_LOAD

const float MAX_HEAP_PAGE_LOAD = 0.9

Maximum load factor (free space/total space) of heap page. If the load factor of a heappage exceeds this value, it is considered full.

◆ MAX_PAGE_NUM

const std::uint32_t MAX_PAGE_NUM
Initial value:
= ((8*(FILE_MAX_CAPACITY -sizeof(std::uint32_t)
*2))/(8*PAGE_SIZE+1))-1
const std::uint32_t FILE_MAX_CAPACITY
Definition: swatdb_types.h:115
const std::uint32_t PAGE_SIZE
Definition: swatdb_types.h:129

Maximum number of pages that could fit in a single Unix file, excluding the file header metadata. If the size of the SerializedFileHeader struct is modified, this equation also has to be modified. This equation accounts for extra space occupied by 2 std::uint32_t (size and capacity) fields of the header metadata and space occupied by bitmap (1 bit per Page, but 8 is multiplied to prevent truncation due to int division). Finally, the MAX_PAGE_NUM is "rounded down" as the disk header information has to fit in units of PAGE_SIZE.

◆ MAX_RECORD_SIZE

const std::uint32_t MAX_RECORD_SIZE = PAGE_SIZE - (8 * sizeof(std::uint32_t))

The maximum record size that can fit in a single page. It accounts for the minimum space taken by the metadata of HeapPage, so if metadata structures are modified, this value should also be modified.

◆ PAGE_SIZE

const std::uint32_t PAGE_SIZE = 1024

The size of a page in bytes