Nebula
|
#include <table.h>
Represents a partition within a Table in MemDb.
A Partition is a segment of a Table that contains a fixed number of rows and manages memory for attribute data through column buffers. Each Partition has a unique partition ID and maintains metadata about its contents, such as the number of rows it currently holds.
Partitions are linked together in a chain within a Table, starting from the first active partition, which allows efficient iteration over all partitions that contain valid rows. Each Partition keeps track of free indices using an array, enabling reuse of memory for deleted rows.
Column buffers in a Partition store data for each attribute defined in the Table. The columns array contains these buffers, and a bitfield tracks whether each row is valid (i.e., not deleted) or modified. This information is used for operations like defragmentation and garbage collection within the partition.
Public Attributes | |
Table * | table = nullptr |
Partition * | next = nullptr |
Partition * | previous = nullptr |
uint16_t | partitionId = 0xFFFF |
uint32_t | numRows = 0 |
number of rows | |
uint64_t | version = 0 |
Util::Array< uint16_t > | freeIds |
Util::Array< ColumnBuffer > | columns |
holds all the column buffers. This excludes non-typed attributes | |
Util::BitField< CAPACITY > | modifiedRows |
check a bit if the row has been modified, and you need to track it. | |
Util::BitField< CAPACITY > | validRows |
bits are set if the row is occupied. | |
Static Public Attributes | |
static constexpr uint | CAPACITY = 256 |
Private Member Functions | |
Partition ()=default | |
~Partition () | |
uint16_t | AllocateRowIndex () |
recycle free row or allocate new row | |
void | FreeIndex (uint16_t instance) |
Free an index. | |
void | EraseSwapIndex (uint16_t instance) |
erase row by swapping with last row and reducing number of rows in table | |
Private Attributes | |
friend | Table |
|
privatedefault |
|
private |
|
private |
recycle free row or allocate new row
|
private |
erase row by swapping with last row and reducing number of rows in table
|
private |
Free an index.
|
staticconstexpr |
Util::Array<ColumnBuffer> MemDb::Table::Partition::columns |
holds all the column buffers. This excludes non-typed attributes
Util::Array<uint16_t> MemDb::Table::Partition::freeIds |
Util::BitField<CAPACITY> MemDb::Table::Partition::modifiedRows |
check a bit if the row has been modified, and you need to track it.
bits are reset when partition is defragged
Partition* MemDb::Table::Partition::next = nullptr |
uint32_t MemDb::Table::Partition::numRows = 0 |
number of rows
uint16_t MemDb::Table::Partition::partitionId = 0xFFFF |
Partition* MemDb::Table::Partition::previous = nullptr |
|
private |
Table* MemDb::Table::Partition::table = nullptr |
Util::BitField<CAPACITY> MemDb::Table::Partition::validRows |
bits are set if the row is occupied.
If the row is removed, the bit is set to zero. this is kept up to date if defragging the partition.
uint64_t MemDb::Table::Partition::version = 0 |