Overview
TDataItem is the fundamental class in TeeBI that represents a column of data. Unlike traditional row-based table structures, TeeBI uses a column-oriented architecture where each TDataItem can own sub-columns, enabling you to build complex in-memory structures of tables and trees.TDataItem is defined in
BI.DataItem.pas and serves as the foundation for all data operations in TeeBI.Column-Based Storage
TeeBI stores data in columns rather than rows. Each TDataItem represents a single column with a specific data type, and multiple TDataItem instances can be combined to form table structures.Key Characteristics
- Column-oriented: Data is stored vertically by column, not horizontally by row
- Type-specific arrays: Each data type has its own optimized array storage
- Hierarchical structure: TDataItem can contain child items (sub-columns)
- Memory efficient: Direct array access without boxing/unboxing overhead
Creating Data Items
You can create TDataItem instances in several ways:Basic Construction
Data Kinds
Every TDataItem has aKind property that determines its data type:
Data Storage Arrays
Each TDataItem contains type-specific arrays for storing values:Accessing Data
Managing Data
Adding Rows
Use theAppend method to add new rows:
Resizing
Change the number of rows withResize:
Inserting and Deleting
Working with Sub-Items
TDataItem can contain child items through theItems property:
Properties and Methods
Key Properties
| Property | Type | Description |
|---|---|---|
Count | TInteger | Number of rows (read-only) |
Kind | TDataKind | Data type (read-only) |
Name | String | Column name |
Parent | TDataItem | Parent data item |
Items | TDataItems | Child items collection |
AsTable | Boolean | True when item represents a table |
Missing | TMissingData | Null/missing value tracking |
Stats | TDataStats | Statistical information |
Essential Methods
Append
Append
Add a new row with values:
Resize
Resize
Change the number of rows:
Insert
Insert
Insert a row at a specific position:
Delete
Delete
Remove rows:
Clear
Clear
Remove all data and reset the item:
SortBy
SortBy
Sort rows by a column:
Missing Values
TeeBI tracks null/missing values separately from the data arrays:Persistence
Save and load TDataItem to/from disk:Best Practices
Use Appropriate Types
Choose the smallest data type that fits your needs (e.g., dkInt32 instead of dkInt64 when possible) to minimize memory usage.
Resize Once
When you know the final size, call
Resize once instead of repeatedly calling Append for better performance.Table Mode
Set
AsTable := True when creating multi-column structures to enable proper recursive operations.Check Missing Values
Always check the
Missing property before using data values to avoid working with null data.Next Steps
Data Types
Learn about TDataKind enumeration and type handling
Arrays
Explore array-based storage and performance
Relationships
Understand master-detail relationships
