多个流表的级联处理的代码是怎么写的呢? 这个在文档中没有找到

简单写一下,我需要知道这种方式是低效率的  避免自己写出这种,谢谢~

请先 登录 后评论

2 个回答

alex
像这种:
def h0(){
    tableInsert(t1
}
subscribeTable(tableName="t0", handler=h0, )
subscribeTable(tableName="t1", handler=....)

不过也有各种引擎无法表达想要的逻辑的时候,所以有时这样写也无法避免
请先 登录 后评论
Yating Xie

https://gitee.com/dolphindb/Tutorials_CN/blob/master/stream_aggregator.md 这个教程中【3. 多个引擎串联使用】有个代码示范 ,供参考。

简单来说,outputTable参数除了可以是表之外还可以是其他流数据计算引擎。

share streamTable(1000:0, `time`sym`price`volume, [TIMESTAMP, SYMBOL, DOUBLE, INT]) as trades

share streamTable(1000:0, `time`sym`open`close`high`low`volume, [TIMESTAMP, SYMBOL, DOUBLE, DOUBLE, DOUBLE, DOUBLE, INT]) as kline

outputTable=table(1000:0, `sym`factor1, [SYMBOL, DOUBLE])

Rengine=createReactiveStateEngine(name="reactive", metrics=<[mavg(open, 3)]>, dummyTable=kline, outputTable=outputTable, keyColumn="sym")

Tengine=createTimeSeriesEngine(name="timeseries", windowSize=6000, step=6000, metrics=<[first(price), last(price), max(price), min(price), sum(volume)]>, dummyTable=trades, outputTable=Rengine, timeColumn=`time, useSystemTime=false, keyColumn=`sym)
//时间序列引擎的结果输入响应式状态引擎

subscribeTable(server="", tableName="trades", actionName="timeseries", offset=0, handler=append!{Tengine}, msgAsTable=true)   
请先 登录 后评论
  • 2 关注
  • 0 收藏,843 浏览
  • ddbuserex 提出于 2022-02-09 09:51

相似问题