publishTable

Syntax

publishTable(host, port, tableName, [actionName], [offset=-1], [filter], [allowExists=false])

Details

This function is executed on the server where the stream table is located. It instructs the server to publish data from a stream table to a client. The client may or may not be a DolphinDB data node or API. In comparison, when we use function subscribeTable, the client must be a DolphinDB data node.

This function returns a string vector, including the list of column names of the stream table.

The function throws an exception if the specified table doesn’t exist or it is not a stream table, or if the subscription already exists on the client and allowExists=false.

Use command stopPublishTable to stop publishing data.

Arguments

host the host name of the client node.

port the subscription port number of the client. If the client is the DolphinDB data node, port is specified by the parameter subPort. If the client is an API, port is subscription port number enabled by the client.

tableName a string indicating the name of the shared stream table on the local server.

actionName a string indicating the name assigned to the subscription task. It can have letters, digits and underscores.

offset the position of the first message to subscribe. A message is row of the stream table. If offset is unspecified, or negative, or above the number of rows of the stream table, the subscription starts from the next incoming record. The offset is relative to the first row of the stream table when it is created. If some rows were cleared from memory due to cache size limit, they are still considered in determining where the subscription starts.

filter a vector of selected values in the filtering column. Only the messages with specified filtering column values are published. The filtering column is set with function setStreamTableFilterColumn. filter does not support Boolean types.

allowExists a Boolean value. When allowExists=true, if the subscription already exists before function publishTable is executed, the system will not throw an exception.

resetOffset a Boolean value indicating whether to reset the offset to -1, the default value is false. When resetOffset = true, the offset will be reset if the row specified by the offset in the stream table has no data and the subscription will start from the next incoming record.

Examples

$ n=100000
$ t=streamTable(rand(100,n) as id, rand(100.0,n) as val)
$ share t as st;

$ publishTable("localhost",8848,"st");
["id","val"]