Table¶
Type Code: 98. Internal Name: Table
A Table is an object that consists of columns, forming the core structure for relational operations in RayforceDB.
Structure¶
Column headers are a Vector of Symbols, and they serve as the names of the columns.
Column values are Vectors or Lists of any type.
(table [id name age] (list ['001 '002 '003] (list "Alice" "Bob" "Charlie") [20 30 40]))
┌─────┬─────────┬──────────────────────┐
│ id │ name │ age │
├─────┼─────────┼──────────────────────┤
│ 001 │ Alice │ 20 │
│ 002 │ Bob │ 30 │
│ 003 │ Charlie │ 40 │
├─────┴─────────┴──────────────────────┤
│ 3 rows (3 shown) 3 columns (3 shown) │
└──────────────────────────────────────┘
Table Storage and Loading¶
Tables can be stored and loaded from disk in different formats for efficient access and persistence.
Get Splayed¶
Loads a splayed table from disk. A splayed table stores each column as a separate file for efficient columnar access.
The second argument (symfile path) is optional. If not provided, the symfile will be inferred from the table path.
Pay attention to the trailing slash in the path to the table. It is required.
Set Splayed¶
Stores a Table as a splayed table on disk. Each column is saved as a separate file.
Optionally accepts a string path to a symfile. If provided, symbol columns will use this shared symfile.
Understanding Symfiles
The symfile is crucial for persisting symbol columns. See the Symbols, Enums, and Symfiles Guide for a detailed explanation of why symfiles are needed and how they enable data to be loaded across different processes.
The table path must end with a trailing slash to indicate it's a directory.
Get Parted¶
Loads a parted table from disk. A parted table is organized by partitions.
Takes two arguments: the root path to the parted tables directory and a symbol representing the table name.
Set Parted¶
Stores a Table as a parted table on disk, organized by partitions.
Important: Shared Symfiles for Parted Tables
When creating parted tables, always use a shared symfile across all partitions. This ensures consistent symbol-to-index mapping, which is required for cross-partition queries. See the Symbols, Enums, and Symfiles Guide for details.
Read CSV¶
Reads a CSV file and converts it into a Table.
Takes a vector of type symbols specifying the column types, a file path, and optionally a separator character (defaults to comma).
Write CSV¶
Writes a Table to a CSV file.
Takes a file path, a table, and optionally a separator character (defaults to comma). The first row of the output file contains column names.