Nebula
|
#include <table.h>
Classes | |
class | Partition |
Public Member Functions | |
bool | HasAttribute (AttributeId attribute) const |
Check if a column exists in the table. | |
AttributeId | GetAttributeId (ColumnIndex columnIndex) const |
Returns the attribute located in given column. | |
ColumnIndex | GetAttributeIndex (AttributeId attribute) const |
Returns the index of the attribute or invalid if attribute is missing from table. | |
Util::Array< AttributeId > const & | GetAttributes () const |
Get the all descriptors for a table. | |
TableSignature const & | GetSignature () const |
Get the table signature. | |
ColumnIndex | AddAttribute (AttributeId attribute, bool updateSignature=true) |
Add an attribute to the table. | |
RowId | AddRow () |
Add/Get a free row from the table. | |
void | RemoveRow (RowId row) |
Deallocate a row from a table. This only frees the row for recycling. See Defragment. | |
SizeT | GetNumRows () const |
Get total number of rows in a table. | |
void | SetNumRows (SizeT value) |
set total number of rows in a table. This does not allocate any memory or create instaces, thus should pretty much never be used. | |
void | SetToDefault (RowId row) |
Set all row values to default. | |
SizeT | Defragment (std::function< void(Partition *, RowId, RowId)> const &moveCallback) |
Defragment table. | |
void | Clean () |
Clean table. Does not deallocate anything; just sets the size of the table to zero. | |
void | Reset () |
Reset table. Deallocate all data. | |
Partition * | GetFirstActivePartition () |
Get first active partition with entities. | |
uint16_t | GetNumActivePartitions () const |
Get number of partitions that contain entities. | |
uint16_t | GetNumPartitions () const |
Get number of partitions in table. | |
Partition * | GetCurrentPartition () |
Get current partition. | |
Partition * | GetPartition (uint16_t partitionId) |
void * | GetValuePointer (ColumnIndex cid, RowId row) |
get a buffer. Might be invalidated if rows are allocated or deallocated | |
void * | GetBuffer (uint16_t partition, ColumnIndex cid) |
get a buffer. Might be invalidated if rows are allocated or deallocated | |
Util::Blob | SerializeInstance (RowId row) const |
Serialize a row into a blob. | |
void | DeserializeInstance (Util::Blob const &data, RowId row) |
deserialize a blob into a row | |
Partition * | NewPartition () |
Create a new partition for this table. Adds it to the list of partitions and the vacancy list. | |
Static Public Member Functions | |
static RowId | MigrateInstance (Table &src, RowId srcRow, Table &dst, bool defragment=true, std::function< void(Partition *, RowId, RowId)> const &moveCallback=nullptr) |
move instance from one table to another. | |
static RowId | DuplicateInstance (Table const &src, RowId srcRow, Table &dst) |
duplicate instance from one row into destination table. | |
static void | MigrateInstances (Table &src, Util::Array< RowId > const &srcRows, Table &dst, Util::FixedArray< RowId > &dstRows, bool defragment=true, std::function< void(Partition *, IndexT, IndexT)> const &moveCallback=nullptr) |
move n instances from one table to another. | |
static void | DuplicateInstances (Table &src, Util::Array< RowId > const &srcRows, Table &dst, Util::FixedArray< RowId > &dstRows) |
duplicate instance from one row into destination table. | |
Public Attributes | |
Util::StringAtom | name |
name of the table | |
Static Public Attributes | |
static constexpr Memory::HeapType | HEAP_MEMORY_TYPE = Memory::HeapType::DefaultHeap |
allocation heap used for the column buffers | |
Private Types | |
using | ColumnBuffer = void* |
Private Member Functions | |
Table ()=default | |
~Table () | |
Private Attributes | |
TableSignature | signature |
the signature of this table. Contains one bit set to true for every attribute that exists in the table. | |
TableId | tid = TableId::Invalid() |
table identifier | |
uint32_t | totalNumRows = 0 |
sum of all rows in all partitions of this table, | |
Partition * | currentPartition = nullptr |
Current partition that we'll be using when allocating data. | |
Util::Array< Partition * > | partitions |
All partitions, even null partitions. | |
Util::Array< Partition * > | freePartitions |
free partitions for recycling allocated partitions | |
Util::Array< uint16_t > | nullPartitions |
indices to null partitions | |
Partition * | firstActivePartition = nullptr |
First partition that has entities. You can use this to iterate over all active partitions with entities by following the chain of partition->next. | |
uint16_t | numActivePartitions = 0 |
number of active partitions | |
Util::Array< AttributeId > | attributes |
all attributes that this table has | |
Util::HashTable< AttributeId, IndexT, 32, 1 > | columnRegistry |
maps attr id -> index in columns array | |
Friends | |
class | Database |
|
private |
|
privatedefault |
|
private |
ColumnIndex MemDb::Table::AddAttribute | ( | AttributeId | attribute, |
bool | updateSignature = true ) |
Add an attribute to the table.
RowId MemDb::Table::AddRow | ( | ) |
Add/Get a free row from the table.
void MemDb::Table::Clean | ( | ) |
Clean table. Does not deallocate anything; just sets the size of the table to zero.
SizeT MemDb::Table::Defragment | ( | std::function< void(Partition *, RowId, RowId)> const & | moveCallback | ) |
Defragment table.
void MemDb::Table::DeserializeInstance | ( | Util::Blob const & | data, |
RowId | row ) |
deserialize a blob into a row
duplicate instance from one row into destination table.
|
static |
duplicate instance from one row into destination table.
AttributeId MemDb::Table::GetAttributeId | ( | ColumnIndex | columnIndex | ) | const |
Returns the attribute located in given column.
ColumnIndex MemDb::Table::GetAttributeIndex | ( | AttributeId | attribute | ) | const |
Returns the index of the attribute or invalid if attribute is missing from table.
Util::Array< AttributeId > const & MemDb::Table::GetAttributes | ( | ) | const |
Get the all descriptors for a table.
void * MemDb::Table::GetBuffer | ( | uint16_t | partition, |
ColumnIndex | cid ) |
get a buffer. Might be invalidated if rows are allocated or deallocated
Table::Partition * MemDb::Table::GetCurrentPartition | ( | ) |
Get current partition.
Table::Partition * MemDb::Table::GetFirstActivePartition | ( | ) |
Get first active partition with entities.
uint16_t MemDb::Table::GetNumActivePartitions | ( | ) | const |
Get number of partitions that contain entities.
uint16_t MemDb::Table::GetNumPartitions | ( | ) | const |
Get number of partitions in table.
SizeT MemDb::Table::GetNumRows | ( | ) | const |
Get total number of rows in a table.
Table::Partition * MemDb::Table::GetPartition | ( | uint16_t | partitionId | ) |
TableSignature const & MemDb::Table::GetSignature | ( | ) | const |
Get the table signature.
void * MemDb::Table::GetValuePointer | ( | ColumnIndex | cid, |
RowId | row ) |
get a buffer. Might be invalidated if rows are allocated or deallocated
bool MemDb::Table::HasAttribute | ( | AttributeId | attribute | ) | const |
Check if a column exists in the table.
|
static |
move instance from one table to another.
|
static |
move n instances from one table to another.
Table::Partition * MemDb::Table::NewPartition | ( | ) |
Create a new partition for this table. Adds it to the list of partitions and the vacancy list.
void MemDb::Table::RemoveRow | ( | RowId | row | ) |
Deallocate a row from a table. This only frees the row for recycling. See Defragment.
void MemDb::Table::Reset | ( | ) |
Reset table. Deallocate all data.
Util::Blob MemDb::Table::SerializeInstance | ( | RowId | row | ) | const |
Serialize a row into a blob.
void MemDb::Table::SetNumRows | ( | SizeT | value | ) |
set total number of rows in a table. This does not allocate any memory or create instaces, thus should pretty much never be used.
void MemDb::Table::SetToDefault | ( | RowId | row | ) |
Set all row values to default.
|
friend |
|
private |
all attributes that this table has
|
private |
maps attr id -> index in columns array
|
private |
Current partition that we'll be using when allocating data.
|
private |
First partition that has entities. You can use this to iterate over all active partitions with entities by following the chain of partition->next.
|
private |
free partitions for recycling allocated partitions
|
staticconstexpr |
allocation heap used for the column buffers
Util::StringAtom MemDb::Table::name |
name of the table
|
private |
indices to null partitions
|
private |
number of active partitions
|
private |
All partitions, even null partitions.
|
private |
the signature of this table. Contains one bit set to true for every attribute that exists in the table.
|
private |
table identifier
|
private |
sum of all rows in all partitions of this table,