Nebula
Loading...
Searching...
No Matches
MemDb::Table::Partition Class Reference

#include <table.h>

Detailed Description

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

Tabletable = nullptr
 
Partitionnext = nullptr
 
Partitionprevious = nullptr
 
uint16_t partitionId = 0xFFFF
 
uint32_t numRows = 0
 number of rows
 
uint64_t version = 0
 
Util::Array< uint16_t > freeIds
 
Util::Array< ColumnBuffercolumns
 holds all the column buffers. This excludes non-typed attributes
 
Util::BitField< CAPACITYmodifiedRows
 check a bit if the row has been modified, and you need to track it.
 
Util::BitField< CAPACITYvalidRows
 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
 

Constructor & Destructor Documentation

◆ Partition()

MemDb::Table::Partition::Partition ( )
privatedefault

◆ ~Partition()

MemDb::Table::Partition::~Partition ( )
private

Member Function Documentation

◆ AllocateRowIndex()

uint16_t MemDb::Table::Partition::AllocateRowIndex ( )
private

recycle free row or allocate new row

◆ EraseSwapIndex()

void MemDb::Table::Partition::EraseSwapIndex ( uint16_t instance)
private

erase row by swapping with last row and reducing number of rows in table

◆ FreeIndex()

void MemDb::Table::Partition::FreeIndex ( uint16_t instance)
private

Free an index.

Member Data Documentation

◆ CAPACITY

uint MemDb::Table::Partition::CAPACITY = 256
staticconstexpr

◆ columns

Util::Array<ColumnBuffer> MemDb::Table::Partition::columns

holds all the column buffers. This excludes non-typed attributes

◆ freeIds

Util::Array<uint16_t> MemDb::Table::Partition::freeIds

◆ modifiedRows

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

◆ next

Partition* MemDb::Table::Partition::next = nullptr

◆ numRows

uint32_t MemDb::Table::Partition::numRows = 0

number of rows

◆ partitionId

uint16_t MemDb::Table::Partition::partitionId = 0xFFFF

◆ previous

Partition* MemDb::Table::Partition::previous = nullptr

◆ Table

friend MemDb::Table::Partition::Table
private

◆ table

Table* MemDb::Table::Partition::table = nullptr

◆ validRows

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.

◆ version

uint64_t MemDb::Table::Partition::version = 0

The documentation for this class was generated from the following files: