Class ComponentTable
Stores all instances of a single component type with MVCC revision tracking.
public class ComponentTable : ResourceNode, IResource, IDisposable, IMetricSource, IDebugPropertiesProvider
- Inheritance
-
ComponentTable
- Implements
- Inherited Members
- Extension Methods
Remarks
ComponentTable registers as a child of its owning DatabaseEngine in the resource tree. Segments (ComponentSegment, CompRevTableSegment, etc.) are NOT registered as children — they follow the "Owner Aggregates" pattern where ComponentTable will aggregate their metrics.
Constructors
ComponentTable(DatabaseEngine, DBComponentDefinition, IResource, StorageMode, ExhaustionPolicy, ChangeSet)
Creates a new (empty) component table, allocating its data, revision, and index segments. For Transient the segments are heap-backed and no MVCC revision chain is allocated.
public ComponentTable(DatabaseEngine dbe, DBComponentDefinition definition, IResource parent, StorageMode storageMode = StorageMode.Versioned, ExhaustionPolicy exhaustionPolicy = ExhaustionPolicy.None, ChangeSet changeSet = null)
Parameters
dbeDatabaseEngineOwning database engine.
definitionDBComponentDefinitionSchema definition of the component type stored here.
parentIResourceResource-tree parent (the owning DatabaseEngine).
storageModeStorageModeStorage discipline: Versioned (default, MVCC), SingleVersion, or Transient.
exhaustionPolicyExhaustionPolicyResource-exhaustion policy forwarded to the base ResourceNode.
changeSetChangeSetChange set threading segment-growth dirty marks through the allocation; may be
null.
Properties
CompRevTableSegment
Segment holding the MVCC revision chains. Non-null only for Versioned storage.
public ChunkBasedSegment<PersistentStore> CompRevTableSegment { get; }
Property Value
- ChunkBasedSegment<PersistentStore>
ComponentSegment
Segment holding the component data chunks (the field payloads). Null in Transient mode.
public ChunkBasedSegment<PersistentStore> ComponentSegment { get; }
Property Value
- ChunkBasedSegment<PersistentStore>
ComponentStorageSize
Size in bytes of a single component's field payload (excludes MVCC and index overhead).
public int ComponentStorageSize { get; }
Property Value
Count
Surfaces the entity count as Count so the Workbench can render a live badge on the ComponentTable tree node without a second round-trip.
public override int? Count { get; }
Property Value
- int?
DefaultIndexSegment
Segment backing the primary-key B+Tree and every non-String64 secondary index.
public ChunkBasedSegment<PersistentStore> DefaultIndexSegment { get; }
Property Value
- ChunkBasedSegment<PersistentStore>
Definition
Schema definition (fields, indexes, layout) of the component type stored in this table.
public DBComponentDefinition Definition { get; }
Property Value
Discipline
Default durability discipline for this component, resolved from [Component(DefaultDiscipline=…)].
Only consulted for SingleVersion; a transaction writing a
Commit component is committed-durable for all of its writes (CM-02).
public DurabilityDiscipline Discipline { get; }
Property Value
EstimatedEntityCount
Estimated total entity count. Sums EntityMap entry counts across archetypes that include this component.
public int EstimatedEntityCount { get; }
Property Value
Flags
Optional storage features enabled on this table (see ComponentTableFlags).
public ComponentTableFlags Flags { get; }
Property Value
HasCollections
true when the component declares at least one collection-typed field (HasCollections is set).
public bool HasCollections { get; }
Property Value
StorageMode
Storage discipline for this component, fixed at construction: Versioned (MVCC revision chains), SingleVersion (in-place, tick-boundary maintenance), or Transient (heap-backed, not persisted).
public StorageMode StorageMode { get; }
Property Value
String64IndexSegment
Segment backing the String64-keyed secondary indexes.
public ChunkBasedSegment<PersistentStore> String64IndexSegment { get; }
Property Value
- ChunkBasedSegment<PersistentStore>
TailIndexSegment
Segment backing the version-history tail for AllowMultiple secondary indexes. Null when the component has no multi-value index.
public ChunkBasedSegment<PersistentStore> TailIndexSegment { get; }
Property Value
- ChunkBasedSegment<PersistentStore>
Methods
Dispose(bool)
Releases the table's owned persistent and transient segments (and the heap-backed transient stores). Idempotent — a second call is a no-op.
protected override void Dispose(bool disposing)
Parameters
disposingbooltruewhen disposing deterministically;falsewhen running from the finalizer.
GetDebugProperties()
Gets detailed debug properties for diagnostic drill-down.
public IReadOnlyDictionary<string, object> GetDebugProperties()
Returns
- IReadOnlyDictionary<string, object>
A dictionary of property names to values. Values should be primitives, strings, or types that have meaningful
ToString()implementations.
Remarks
This method may allocate (returns new dictionary) since it's called infrequently. Callers should cache results if needed across multiple accesses.
Property naming convention: Use dot-notation for nested concepts (e.g., "ComponentSegment.Allocated", "Contention.MaxWaitUs").
ReadMetrics(IMetricWriter)
Writes current metric values to the provided writer.
public void ReadMetrics(IMetricWriter writer)
Parameters
writerIMetricWriterThe writer to report metrics to. Call one or more Write* methods.
Remarks
Called during snapshot collection (every 1-5 seconds). Implementations should:
- Read fields and write to writer quickly (target < 100ns)
- Not allocate (no new objects, no LINQ, no string formatting)
- Not acquire locks (read fields directly, accept slight inconsistency)
- Not call other IMetricSource.ReadMetrics() — the graph handles recursion
Only report metric kinds that are relevant to this resource. For example, a TransactionPool might only report Capacity and Throughput, not Memory or DiskIO.
ResetPeaks()
Resets all high-water mark metrics (PeakBytes, MaxWaitUs, MaxUs, etc.) to current values.
public void ResetPeaks()
Remarks
Called by ResetAllPeaks() to enable windowed peak measurements. After displaying or exporting peak values, this method resets them so subsequent peaks represent new maxima since the last reset.
If this node has no high-water marks, implement as an empty method. Plain writes are sufficient — snapshots are taken every 1-5 seconds, so eventual visibility is acceptable.