setStreamTableFilterColumn

Syntax

setStreamTableFilterColumn(streamTable, columnName)

Parameters

streamTable is a stream table object.

columnName is a string indicating a column name. The column must be of type SYMBOL, STRING or INT.

Details

Specify the filtering column of a stream table. It is related to parameter filter in function subscribeTable The value of parameter filter is a vector. Only the rows with values of the filtering column in filter are published to the subscriber. A stream table can have only one filtering column.

Examples

In the following example, the filter column of the stream table "trades" is "symbol". The table "trades_slave" on the same node subscribes to "trades" and the filter is set to ["IBM", "GOOG"]. Only when the column "symbol" is "IBM" or "GOOG", the corresponding data will be published.

share streamTable(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT]) as trades
setStreamTableFilterColumn(trades, `symbol)
trades_1=table(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT])

filter=symbol(`IBM`GOOG)

subscribeTable(tableName=`trades, actionName=`trades_1, handler=append!{trades_1}, msgAsTable=true, filter=filter);

For range filtering, the filter value is a pair. The streaming table trades on the publisher side only publishes data where price is greater than or equal to 1 and less than 100:

share streamTable(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT]) as trades
setStreamTableFilterColumn(trades, `price)
trades_1=table(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT])

subscribeTable(tableName="trades", actionName="trades_1", handler=append!{trades_1}, msgAsTable=true, filter=1:100)

For hash filtering, the filter value is a tuple. The streaming table trades on the publisher side applies a hash function to the symbol column to divide the data into 10 buckets (with bucket indices starting from 0), and only publishes data with bucket indices greater than or equal to 1 and less than 5:

share streamTable(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT]) as trades
setStreamTableFilterColumn(trades, `symbol)
trades_1=table(10000:0,`time`symbol`price, [TIMESTAMP,SYMBOL,INT])

subscribeTable(tableName="trades", actionName="trades_1", handler=append!{trades_1}, msgAsTable=true, filter=(10,1:5))