Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
577cf92f
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
577cf92f
编写于
5月 12, 2020
作者:
weixin_48148422
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
single table subscribe is done
上级
a3693762
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
31 deletion
+56
-31
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+12
-2
tests/examples/c/subscribe.c
tests/examples/c/subscribe.c
+44
-29
未找到文件。
src/query/src/queryExecutor.c
浏览文件 @
577cf92f
...
...
@@ -4185,6 +4185,12 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
tsdb
,
&
cond
,
&
pQInfo
->
tableIdGroupInfo
);
}
else
if
(
!
isSTableQuery
||
isIntervalQuery
(
pQuery
)
||
isFixedOutputQuery
(
pQuery
))
{
if
(
pQInfo
->
groupInfo
.
numOfTables
==
1
)
{
SArray
*
pa
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
0
);
SGroupItem
*
pItem
=
taosArrayGet
(
pa
,
0
);
cond
.
twindow
=
pItem
->
info
->
win
;
}
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryTables
(
tsdb
,
&
cond
,
&
pQInfo
->
tableIdGroupInfo
);
}
}
...
...
@@ -4903,6 +4909,12 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
if
(
Q_STATUS_EQUAL
(
pQuery
->
status
,
QUERY_RESBUF_FULL
))
{
qTrace
(
"QInfo:%p query paused due to output limitation, next qrange:%"
PRId64
"-%"
PRId64
,
pQInfo
,
pQuery
->
current
->
lastKey
,
pQuery
->
window
.
ekey
);
}
else
if
(
Q_STATUS_EQUAL
(
pQuery
->
status
,
QUERY_COMPLETED
))
{
STableIdInfo
tidInfo
;
tidInfo
.
uid
=
pQuery
->
current
->
id
.
uid
;
tidInfo
.
tid
=
pQuery
->
current
->
id
.
tid
;
tidInfo
.
key
=
pQuery
->
current
->
lastKey
;
taosArrayPush
(
pQInfo
->
arrTableIdInfo
,
&
tidInfo
);
}
if
(
!
isTSCompQuery
(
pQuery
))
{
...
...
@@ -5195,7 +5207,6 @@ static char *createTableIdList(SQueryTableMsg *pQueryMsg, char *pMsg, SArray **p
pTableIdInfo
->
uid
=
htobe64
(
pTableIdInfo
->
uid
);
pTableIdInfo
->
key
=
htobe64
(
pTableIdInfo
->
key
);
printf
(
"createTableIdList: uid = %ld, key = %ld
\n
"
,
pTableIdInfo
->
uid
,
pTableIdInfo
->
key
);
taosArrayPush
(
*
pTableIdList
,
pTableIdInfo
);
pMsg
+=
sizeof
(
STableIdInfo
);
}
...
...
@@ -5759,7 +5770,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
// not a problem at present because we only use their 1st int64_t field
STableIdInfo
*
pTableId
=
taosArraySearch
(
pTableIdList
,
compareTableIdInfo
,
&
id
);
if
(
pTableId
!=
NULL
)
{
printf
(
"create QInfoImpl: %ld %ld
\n
"
,
pTableId
->
uid
,
pTableId
->
key
);
window
.
skey
=
pTableId
->
key
;
}
else
{
window
.
skey
=
INT64_MIN
;
...
...
tests/examples/c/subscribe.c
浏览文件 @
577cf92f
...
...
@@ -56,32 +56,46 @@ void run_test(TAOS* taos) {
taos_query
(
taos
,
"drop database if exists test;"
);
usleep
(
100000
);
taos_query
(
taos
,
"create database test tables 5;"
);
//taos_query(taos, "create database test tables 5;");
taos_query
(
taos
,
"create database test;"
);
usleep
(
100000
);
taos_query
(
taos
,
"use test;"
);
usleep
(
100000
);
taos_query
(
taos
,
"create table meters(ts timestamp, a int, b binary(20)) tags(loc binary(20), area int);"
);
taos_query
(
taos
,
"insert into t0 using meters tags('beijing', 0) values('2020-01-01 00:00:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t0 using meters tags('beijing', 0) values('2020-01-01 00:01:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t0 using meters tags('beijing', 0) values('2020-01-01 00:02:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t1 using meters tags('shanghai', 0) values('2020-01-01 00:00:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t1 using meters tags('shanghai', 0) values('2020-01-01 00:01:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t1 using meters tags('shanghai', 0) values('2020-01-01 00:02:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t1 using meters tags('shanghai', 0) values('2020-01-01 00:03:00.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t2 using meters tags('london', 0) values('2020-01-01 00:00:00.000', 0, 'UK');"
);
taos_query
(
taos
,
"insert into t2 using meters tags('london', 0) values('2020-01-01 00:01:00.000', 0, 'UK');"
);
taos_query
(
taos
,
"insert into t2 using meters tags('london', 0) values('2020-01-01 00:01:01.000', 0, 'UK');"
);
taos_query
(
taos
,
"insert into t2 using meters tags('london', 0) values('2020-01-01 00:01:02.000', 0, 'UK');"
);
taos_query
(
taos
,
"insert into t3 using meters tags('tianjin', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t4 using meters tags('wuhan', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t5 using meters tags('jinan', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t6 using meters tags('haikou', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t7 using meters tags('nanjing', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t8 using meters tags('lanzhou', 0) values('2020-01-01 00:01:02.000', 0, 'china');"
);
taos_query
(
taos
,
"insert into t9 using meters tags('tokyo', 0) values('2020-01-01 00:01:02.000', 0, 'japan');"
);
taos_query
(
taos
,
"create table meters(ts timestamp, a int) tags(area int);"
);
taos_query
(
taos
,
"create table t0 using meters tags(0);"
);
taos_query
(
taos
,
"create table t1 using meters tags(1);"
);
taos_query
(
taos
,
"create table t2 using meters tags(2);"
);
taos_query
(
taos
,
"create table t3 using meters tags(3);"
);
taos_query
(
taos
,
"create table t4 using meters tags(4);"
);
taos_query
(
taos
,
"create table t5 using meters tags(5);"
);
taos_query
(
taos
,
"create table t6 using meters tags(6);"
);
taos_query
(
taos
,
"create table t7 using meters tags(7);"
);
taos_query
(
taos
,
"create table t8 using meters tags(8);"
);
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:01:00.000', 0);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.000', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:00:00.000', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:01:00.000', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:02:00.000', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.000', 0);"
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:00:00.000', 0);"
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:00.000', 0);"
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:01.000', 0);"
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t3 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t4 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t5 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t6 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t7 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:02.000', 0);"
);
taos_query
(
taos
,
"insert into t9 values('2020-01-01 00:01:02.000', 0);"
);
// super tables subscription
usleep
(
1000000
);
TAOS_SUB
*
tsub
=
taos_subscribe
(
taos
,
0
,
"test"
,
"select * from meters;"
,
NULL
,
NULL
,
0
);
TAOS_RES
*
res
=
taos_consume
(
tsub
);
...
...
@@ -90,23 +104,23 @@ void run_test(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:0
3:00.000', 0, 'china'
);"
);
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0
, 'china'
);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:0
2:00.001', 0
);"
);
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0
, 'UK'
);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0
, 'UK'
);"
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0);"
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0
, 'china'
);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0);"
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
// keep progress information and restart subscription
taos_unsubscribe
(
tsub
,
1
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0
, 'china'
);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0);"
);
tsub
=
taos_subscribe
(
taos
,
1
,
"test"
,
"select * from meters;"
,
NULL
,
NULL
,
0
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
24
);
...
...
@@ -133,7 +147,7 @@ void run_test(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0
, 'china'
);"
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0);"
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
...
...
@@ -197,7 +211,7 @@ int main(int argc, char *argv[]) {
// init TAOS
taos_init
();
TAOS
*
taos
=
taos_connect
(
host
,
user
,
passwd
,
"
test
"
,
0
);
TAOS
*
taos
=
taos_connect
(
host
,
user
,
passwd
,
""
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
...
...
@@ -209,6 +223,7 @@ int main(int argc, char *argv[]) {
exit
(
0
);
}
taos_query
(
taos
,
"use test;"
);
TAOS_SUB
*
tsub
=
NULL
;
if
(
async
)
{
// create an asynchronized subscription, the callback function will be called every 1s
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录