table_database.sc

table_database.sc

Module for working with table databases.

Functions:

Error codes

Table database error codes.

Constants

int64

SHAREMIND_TDB_OK = 0

int64

SHAREMIND_TDB_UNKNOWN_ERROR = 1

int64

SHAREMIND_TDB_GENERAL_ERROR = 2

int64

SHAREMIND_TDB_CONSENSUS_ERROR = 3

int64

SHAREMIND_TDB_IO_ERROR = 4

int64

SHAREMIND_TDB_INVALID_ARGUMENT = 5

int64

SHAREMIND_TDB_TABLE_NOT_FOUND = 6

int64

SHAREMIND_TDB_TABLE_ALREADY_EXISTS = 7

tdbCloseConnection

Close connection to a data source.

Detailed Description

Parameters

datasource

- data source name

Function Overloads

void tdbCloseConnection(string datasource)

tdbGetColumnCount

Get the number of columns in a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

returns the number of columns in the table

Function Overloads

uint64 tdbGetColumnCount(string datasource, string table)

tdbGetColumnNames

Get the column names of a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

returns the id of a vector map where the string vector "names" contains the names of the columns in the table

Function Overloads

uint64 tdbGetColumnNames(string datasource, string table)

tdbGetColumnTypes

Get the column types of a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

returns the id of a vector map where the type vector "types" contains the types of the columns in the table

Function Overloads

uint64 tdbGetColumnTypes(string datasource, string table)

tdbGetRowCount

Get the number of rows in a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

returns the number of rows in the table

Function Overloads

uint64 tdbGetRowCount(string datasource, string table)

tdbGetTableNames

Get the names of tables in a data source.

Detailed Description

Parameters

datasource

- data source name

returns a vector map with the vector "names" consisting of the table names

Function Overloads

uint64 tdbGetTableNames(string datasource)

tdbInsertRow

Insert a row into a table.

Detailed Description

Parameters

datasource

- name of the data source containing the table

table

- table name

parameters

- id of the vector map containing values to be inserted. The vector "values" should contain a value for each column.

Function Overloads

void tdbInsertRow(string datasource, string table, uint64 parameters)

tdbOpenConnection

Open connection to a data source.

Detailed Description

Parameters

datasource

- data source name

Function Overloads

void tdbOpenConnection(string datasource)

tdbReadColumn(index, value vector)

Read a column from a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

index

- index of the column in the table

returns a vector with the values in the column

Function Overloads

T tdbReadColumn(string datasource, string table, uint index)

tdbReadColumn(index, vector map)

Read a column from a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

index

- index of the column in the table

Returns a vector map id. The first value of the "values" value vector in the vector map contains the values in the column.

Function Overloads

uint64 tdbReadColumn(string datasource, string table, uint64 index)

tdbReadColumn(string, vector map)

Read a column from a table.

Detailed Description

Parameters

datasource

- data source name

table

- table name

column

- column name

Returns a vector map id. The first value of the "values" value vector in the vector map contains the values in the column.

Function Overloads

uint tdbReadColumn(string datasource, string table, string column)

tdbTableCreate

Create a table.

Detailed Description

Parameters

datasource

- name of the data source that will contain the table

table

- table name

parameters

- id of the vector map containing parameters for creating the table. The vectors "types" and "names" should contain the types and names of the columns.

Function Overloads

void tdbTableCreate(string datasource, string table, uint64 parameters)

tdbTableCreateWithErrorCode

Create a table.

Detailed Description

Parameters

datasource

- name of the data source that will contain the table

table

- table name

parameters

- id of the vector map containing parameters for creating the table. The vectors "types" and "names" should contain the types and names of the columns.

Function Overloads

int tdbTableCreateWithErrorCode(string datasource, string table, uint parameters)

tdbTableDelete

Delete a table.

Detailed Description

Parameters

datasource

- name of the data source containing the table

table

- table name

Function Overloads

void tdbTableDelete(string datasource, string table)

tdbTableExists

Check if a table exists.

Detailed Description

Parameters

datasource

- name of the data source that is expected to contain the table

table

- table name

returns true if the table exists

Function Overloads

bool tdbTableExists(string datasource, string table)

tdbTableGetAttributes

Get user defined attributes of a table.

Detailed Description

Parameters

ds

- name of the data source containing the table

table

- table name

returns a vector map with two string vectors - "keys" and "values"

Function Overloads

uint tdbTableGetAttributes(string ds, string table)

tdbTableSetAttributes

Set user defined attributes of a table.

Detailed Description

Parameters

ds

- name of the data source containing the table

table

- table name

vmap

- vector map containing the key-value attribute pairs as two string vectors - "keys" and "values"

Function Overloads

void tdbTableSetAttributes(string ds, string table, uint vmap)

tdbVmapAddBatch

Add a batch to a vector map.

Detailed Description

A vector map always contains at least one batch. Batches are used for combining multiple database operations. For instance, to insert two rows at once, add values of the first row to a vector map, call this function, add values of the second row and call tdbInsertRow.

Parameters

id

- vector map id

Function Overloads

void tdbVmapAddBatch(uint64 id)

tdbVmapAddIndex

Add an unsigned integer value to a vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector to which the string is added

value

- value to be added

Function Overloads

void tdbVmapAddIndex(uint64 id, string paramname, uint64 value)

tdbVmapAddString

Add a string to a vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector to which the string is added

str

- string to be added

Function Overloads

void tdbVmapAddString(uint64 id, string paramname, string str)

tdbVmapAddType

Add a type to a vector in a vector map.

Detailed Description

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64

Parameters

id

- vector map id

paramname

- name of the vector to which the type is added

t

- a value of the type that’s added to the vector

Function Overloads

void tdbVmapAddType(uint id, string paramname, T t)

tdbVmapAddValue(scalar)

Add a scalar value to a vector in a vector map.

Detailed Description

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64

Parameters

id

- vector map id

paramname

- name of the vector to which the value is added

value

- value to be added

Function Overloads

void tdbVmapAddValue(uint64 id, string paramname, T value)

tdbVmapAddValue(vector)

Add a vector to a vector in a vector map.

Detailed Description

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64

Parameters

id

- vector map id

paramname

- name of the vector to which the argument vector is added

values

- vector to be added

Function Overloads

void tdbVmapAddValue(uint64 id, string paramname, T[[1]] values)

tdbVmapAddVlenType

Add a variable length type to a vector in a vector map.

Detailed Description

This is used to create a table with a column that contains vectors with arbitrary length.

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 / string

Parameters

id

- vector map id

paramname

- name of the vector to which the type is added

t

- a value of the type that’s added to the vector

Function Overloads

void tdbVmapAddVlenType(uint64 id, string paramname, T t)

tdbVmapAddVlenValue

Add a variable length vector to a vector in a vector map.

Detailed Description

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64

Parameters

id

- vector map id

paramname

- name of the vector to which the value is added

values

- vector to be added

Function Overloads

void tdbVmapAddVlenValue(uint64 id, string paramname, T[[1]] values)

tdbVmapClear

Clears the current batch in a vector map.

Detailed Description

Parameters

id

- vector map id

Function Overloads

void tdbVmapClear(uint64 id)

tdbVmapCount

Get the number of vectors in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector to count

returns the number of vectors with the name paramname in the vector map (one or zero)

Function Overloads

uint64 tdbVmapCount(uint64 id, string paramname)

tdbVmapDelete

Delete a vector map.

Detailed Description

Parameters

id

- vector map id

Function Overloads

void tdbVmapDelete(uint64 id)

tdbVmapErase

Remove a vector from a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the removed vector

returns true if a vector was removed, false otherwise

Function Overloads

bool tdbVmapErase(uint64 id, string paramname)

tdbVmapGetBatchCount

Get number of batches in a vector map.

Detailed Description

Parameters

id

- vector map id

returns the number of batches in the vector map

Function Overloads

uint64 tdbVmapGetBatchCount(uint64 id)

tdbVmapGetIndex

Get an unsigned integer from a string vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- string vector name

index

- index of the value in the vector

returns the unsigned integer value in the vector at the specified index

Function Overloads

uint64 tdbVmapGetIndex(uint64 id, string paramname, uint index)

tdbVmapGetString

Get a string from a string vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- string vector name

index

- index of the string in the string vector

returns the string in the string vector at the specified index

Function Overloads

string tdbVmapGetString(uint64 id, string paramname, uint64 index)

tdbVmapGetTypeName

Get the name of a type in a type vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- type vector name

index

- index of the type in the type vector

returns the name of the type in the type vector at the specified index

Function Overloads

string tdbVmapGetTypeName(uint id, string paramname, uint index)

tdbVmapGetValue

Get a value from a vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector from which to retrieve the value

index

- index of the value in the vector

returns the value in the vector at the specified index

Function Overloads

T tdbVmapGetValue(uint id, string paramname, uint index)

tdbVmapGetValue(string)

Get a string from a value vector in a vector map.

Detailed Description

Parameters

id

- id of the vector map

paramname

- name of the value vector

index

- index of the element in the value vector

returns the string in the value vector at the specified index

Function Overloads

string tdbVmapGetValue(uint64 id, string paramname, uint64 index)

tdbVmapGetVlenValue

Get a variable length value from a vector in a vector map.

Detailed Description

This function is used when the table column contains variable length vectors

Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64

Parameters

id

- vector map id

paramname

- name of the vector from which to retrieve the value

index

- index of the value in the vector

Function Overloads

T tdbVmapGetVlenValue(uint64 id, string paramname, uint64 index)

tdbVmapNew

Create a vector map.

Detailed Description

returns an identifier that can be used for working with the vector map

Function Overloads

uint64 tdbVmapNew()

tdbVmapReset

Resets the vector map to the initial state.

Detailed Description

Parameters

id

- vector map id

Function Overloads

void tdbVmapReset(uint64 id)

tdbVmapSetBatch

Sets the current active batch.

Detailed Description

Useful for iterating through the batches of the result returned by a database operation.

Parameters

id

- vector map id

index

- index of the batch in the vector map

Function Overloads

void tdbVmapSetBatch(uint64 id, uint64 index)

tdbVmapSetValueAsColumn

Configure the vector map to accept values as column vectors. This can be used to insert multiple rows at a time by providing a vector for each column in the table.

Detailed Description

Parameters

id

- vector map id

Function Overloads

void tdbVmapSetValueAsColumn(uint64 id)

tdbVmapStringVectorSize

Get the size of a vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector in the vector map

returns the number of values in the vector

Function Overloads

uint64 tdbVmapStringVectorSize(uint64 id, string paramname)

tdbVmapValueVectorSize

Get the size of a vector in a vector map.

Detailed Description

Parameters

id

- vector map id

paramname

- name of the vector in the vector map

returns the number of values in the vector

Function Overloads

uint64 tdbVmapValueVectorSize(uint64 id, string paramname)