Skip to content

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.

(get-splayed "/tmp/db/tab/" "/tmp/db/tab.sym")

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.

(set-splayed "/tmp/db/tab/" t)
(set-splayed "/tmp/db/tab/" t "/tmp/db/sym")

Optionally accepts a string path to a symfile. If provided, symbol columns will use this shared symfile.

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.

(get-parted "/tmp/db/" 'tab)

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.

(set-parted "/tmp/db/" t)

Read CSV

Reads a CSV file and converts it into a Table.

(read-csv [I64 Symbol F64] "/path/to/file.csv")
(read-csv [I64 Symbol F64] "/path/to/file.csv" ';')

Takes a vector of type symbols specifying the column types, a file path, and optionally a separator character (defaults to comma).

Next: Table Queries