haMvccTable
Syntax
haMvccTable(capacity:size, table, tableName, raftGroup, [defaultValues],
[allowNull])
Details
Creates a high-availability version of MVCC table (HA MVCC table).
The creation, deletion, and write operations of HA MVCC table must be executed on
the Leader node of the corresponding Raft group. The Leader node of a Raft group
can be obtained via the getHaMvccLeader function.
Parameters
capacity is a positive integer indicating the table capacity (in number of records). When the number of records exceeds capacity, the system automatically expands the capacity. The system first allocates memory that is about 1.2 to 2 times the current capacity, then copies the data to the new memory space, and finally releases the original memory. For large-scale tables, memory usage will be very high during capacity expansion. Therefore, it is recommended to pre-allocate a reasonable capacity when creating an in-memory table.
size is a positive integer indicating the initial number of rows at table creation. If size=0, an empty table is created; if size>0, initial values are determined by defaultValues.
table is a table indicating the schema of HA MVCC table. It must be an empty
table created with the table function.
tableName is a STRING scalar indicating the name of the HA MVCC table.
raftGroup is an integer greater than 1 indicating the Raft group ID used by HA
MVCC. This ID must be preconfigured in the mvccTableRaftGroups
configuration parameter.
defaultValues is a tuple of the same length as the number of table columns indicating the default values for each column at table creation. The default value is NULL.
allowNull is a BOOLEAN vector of the same length as the number of table columns indicating whether each column is allowed to contain null values. The default value is true (all columns allow null values).
Returns
Returns a table handle of HA MVCC table.
Examples
schemaTb = table(1:0, `name`id`value, [STRING, INT, DOUBLE])
t = haMvccTable(1:0, schemaTb, "demoHaMvcc", 2)
Related functions: loadHaMvccTable, dropHaMvccTable, setHaMvccColumnNullability, setHaMvccColumnDefaultValue, getHaMvccRaftGroups, getHaMvccLeader, getHaMvccTableInfo, checkpointHaMvcc, isCheckpointingHaMvcc
