112 bool defragment =
true,
124 bool defragment =
true,
Partition * next
Definition table.h:180
static constexpr uint CAPACITY
Definition table.h:176
Util::Array< ColumnBuffer > columns
holds all the column buffers. This excludes non-typed attributes
Definition table.h:192
friend Table
Definition table.h:201
Table * table
Definition table.h:178
Util::BitField< CAPACITY > modifiedRows
check a bit if the row has been modified, and you need to track it.
Definition table.h:195
void FreeIndex(uint16_t instance)
Free an index.
Definition table.cc:758
uint16_t partitionId
Definition table.h:184
uint16_t AllocateRowIndex()
recycle free row or allocate new row
Definition table.cc:730
Partition * previous
Definition table.h:182
void EraseSwapIndex(uint16_t instance)
erase row by swapping with last row and reducing number of rows in table
Definition table.cc:769
uint32_t numRows
number of rows
Definition table.h:186
uint64_t version
Definition table.h:188
Util::Array< uint16_t > freeIds
Definition table.h:190
Util::BitField< CAPACITY > validRows
bits are set if the row is occupied.
Definition table.h:198
~Partition()
Definition table.cc:714
void Reset()
Reset table. Deallocate all data.
Definition table.cc:383
SizeT GetNumRows() const
Get total number of rows in a table.
Definition table.cc:239
uint16_t numActivePartitions
number of active partitions
Definition table.h:158
ColumnIndex GetAttributeIndex(AttributeId attribute) const
Returns the index of the attribute or invalid if attribute is missing from table.
Definition table.cc:123
void * ColumnBuffer
Definition table.h:45
void RemoveRow(RowId row)
Deallocate a row from a table. This only frees the row for recycling. See Defragment.
Definition table.cc:229
SizeT Defragment(std::function< void(Partition *, RowId, RowId)> const &moveCallback)
Defragment table.
Definition table.cc:277
uint32_t totalNumRows
sum of all rows in all partitions of this table,
Definition table.h:146
bool HasAttribute(AttributeId attribute) const
Check if a column exists in the table.
Definition table.cc:105
void SetToDefault(RowId row)
Set all row values to default.
Definition table.cc:257
uint16_t GetNumActivePartitions() const
Get number of partitions that contain entities.
Definition table.cc:414
Partition * GetPartition(uint16_t partitionId)
Definition table.cc:441
Util::Array< Partition * > freePartitions
free partitions for recycling allocated partitions
Definition table.h:152
Util::StringAtom name
name of the table
Definition table.h:134
Util::Array< Partition * > partitions
All partitions, even null partitions.
Definition table.h:150
uint16_t GetNumPartitions() const
Get number of partitions in table.
Definition table.cc:423
ColumnIndex AddAttribute(AttributeId attribute, bool updateSignature=true)
Add an attribute to the table.
Definition table.cc:154
void DeserializeInstance(Util::Blob const &data, RowId row)
deserialize a blob into a row
Definition table.cc:514
Partition * currentPartition
Current partition that we'll be using when allocating data.
Definition table.h:148
Util::HashTable< AttributeId, IndexT, 32, 1 > columnRegistry
maps attr id -> index in columns array
Definition table.h:162
Partition * firstActivePartition
First partition that has entities. You can use this to iterate over all active partitions with entiti...
Definition table.h:156
void SetNumRows(SizeT value)
set total number of rows in a table. This does not allocate any memory or create instaces,...
Definition table.cc:248
TableId tid
table identifier
Definition table.h:144
Partition * GetFirstActivePartition()
Get first active partition with entities.
Definition table.cc:405
Util::Blob SerializeInstance(RowId row) const
Serialize a row into a blob.
Definition table.cc:479
static void DuplicateInstances(Table &src, Util::Array< RowId > const &srcRows, Table &dst, Util::FixedArray< RowId > &dstRows)
duplicate instance from one row into destination table.
Definition table.cc:662
void * GetBuffer(uint16_t partition, ColumnIndex cid)
get a buffer. Might be invalidated if rows are allocated or deallocated
Definition table.cc:469
Partition * GetCurrentPartition()
Get current partition.
Definition table.cc:432
Util::Array< uint16_t > nullPartitions
indices to null partitions
Definition table.h:154
static RowId DuplicateInstance(Table const &src, RowId srcRow, Table &dst)
duplicate instance from one row into destination table.
Definition table.cc:580
Util::Array< AttributeId > attributes
all attributes that this table has
Definition table.h:160
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.
Definition table.cc:625
void * GetValuePointer(ColumnIndex cid, RowId row)
get a buffer. Might be invalidated if rows are allocated or deallocated
Definition table.cc:451
TableSignature signature
the signature of this table. Contains one bit set to true for every attribute that exists in the tabl...
Definition table.h:142
Util::Array< AttributeId > const & GetAttributes() const
Get the all descriptors for a table.
Definition table.cc:136
~Table()
Definition table.cc:39
RowId AddRow()
Add/Get a free row from the table.
Definition table.cc:200
TableSignature const & GetSignature() const
Get the table signature.
Definition table.cc:145
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.
Definition table.cc:544
static constexpr Memory::HeapType HEAP_MEMORY_TYPE
allocation heap used for the column buffers
Definition table.h:131
void Clean()
Clean table. Does not deallocate anything; just sets the size of the table to zero.
Definition table.cc:365
Partition * NewPartition()
Create a new partition for this table. Adds it to the list of partitions and the vacancy list.
Definition table.cc:48
Basically a bitfield with packed ComponentIds.
Definition tablesignature.h:26
Nebula's dynamic array class.
Definition array.h:60
Implements large bit field.
Definition bitfield.h:24
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
Organizes key/value pairs by a hash code.
Definition hashtable.h:42
A StringAtom.
Definition stringatom.h:22
Attribute.
Definition attribute.h:26
AttributeId GetAttributeId()
Definition attributeregistry.h:67
HeapType
Heap types are defined here.
Definition osxmemoryconfig.h:25
Definition attributeid.h:19
column id
Definition tableid.h:38
row identifier
Definition tableid.h:18
information for creating a table
Definition table.h:31
SizeT numAttributes
number of columns
Definition table.h:37
AttributeId const * attributeIds
array of attributes the table should initially have
Definition table.h:35
Util::String name
name to be given to the table
Definition table.h:33
Table identifier.
Definition tableid.h:14
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48