mvccTable

Syntax

mvccTable(X, [X1], [X2], …..)

or

mvccTable(capacity:size, colNames, colTypes, [path], [tableName])

Arguments

For the first scenario:

X, X1, X2 …are vectors.

For the second scenario:

capacity is the amount of memory (in terms of the number of rows) allocated to the table. When the number of rows exceeds capacity, the system will first allocate memory of 1.2~2 times of capacity, copy the data to the new memory space, and release the original memory. For large tables, these steps may use significant amount of memory.

size is the initial size (in terms of the number of rows) of the table. If size = 0, create an empty table.

colNames is a string vector of column names.

colTypes is a string vector of column types.

path is a string indicating the absolute path of the table on disk. The DFS path is not supported.

tableName is a string indicating the name of the table on disk.

Details

Create an MVCC (Multi Version Concurrency Control) table. When appending, updating or deleting rows of a table, another version of the table is created so that concurrent read will not be blocked. The mvcc table is optimal for the use case with frequent read and append, but few update and delete operations.

If parameters path and tableName are specified, the table will be persisted to disk. The table on disk can be loaded into memory with function loadMvccTable.

Note: The MVCC table does not support addColumn, dropColumns!, replaceColumn!, reorderColumns!, upsert!, drop, erase!.

Examples

$ id=`XOM`GS`AAPL
$ x=102.1 33.4 73.6
$ mvccTable(id, x);

id

x

XOM

102.1

GS

33.4

AAPL

73.6

$ mvccTable(200:10, `name`id`value, [STRING,INT,DOUBLE],"C:/DolphinDB/Data","t1");

name

id

value

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

There will be files named “t1.tbl”, “t1.sym” and a folder named “t1” under path “C:/DolphinDB/Data”. You should delete all these files before deleting a disk table.