Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
be4671d5
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,发现更多精彩内容 >>
未验证
提交
be4671d5
编写于
4月 09, 2021
作者:
H
haojun Liao
提交者:
GitHub
4月 09, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5741 from taosdata/hotfix/TD-3721
[TD-3721]asyncdemo crash and other issue
上级
7f38af18
3da3b0de
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
16 deletion
+28
-16
tests/examples/c/asyncdemo.c
tests/examples/c/asyncdemo.c
+28
-16
未找到文件。
tests/examples/c/asyncdemo.c
浏览文件 @
be4671d5
...
@@ -28,7 +28,8 @@
...
@@ -28,7 +28,8 @@
int
points
=
5
;
int
points
=
5
;
int
numOfTables
=
3
;
int
numOfTables
=
3
;
int
tablesProcessed
=
0
;
int
tablesInsertProcessed
=
0
;
int
tablesSelectProcessed
=
0
;
int64_t
st
,
et
;
int64_t
st
,
et
;
typedef
struct
{
typedef
struct
{
...
@@ -134,6 +135,9 @@ int main(int argc, char *argv[])
...
@@ -134,6 +135,9 @@ int main(int argc, char *argv[])
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
tablesInsertProcessed
=
0
;
tablesSelectProcessed
=
0
;
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
// insert records in asynchronous API
// insert records in asynchronous API
sprintf
(
sql
,
"insert into %s values(%ld, 0)"
,
tableList
[
i
].
name
,
1546300800000
+
i
);
sprintf
(
sql
,
"insert into %s values(%ld, 0)"
,
tableList
[
i
].
name
,
1546300800000
+
i
);
...
@@ -143,10 +147,20 @@ int main(int argc, char *argv[])
...
@@ -143,10 +147,20 @@ int main(int argc, char *argv[])
printf
(
"once insert finished, presse any key to query
\n
"
);
printf
(
"once insert finished, presse any key to query
\n
"
);
getchar
();
getchar
();
while
(
1
)
{
if
(
tablesInsertProcessed
<
numOfTables
)
{
printf
(
"wait for process finished
\n
"
);
sleep
(
1
);
continue
;
}
break
;
}
printf
(
"start to query...
\n
"
);
printf
(
"start to query...
\n
"
);
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
tablesProcessed
=
0
;
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
// select records in asynchronous API
// select records in asynchronous API
...
@@ -157,14 +171,8 @@ int main(int argc, char *argv[])
...
@@ -157,14 +171,8 @@ int main(int argc, char *argv[])
printf
(
"
\n
once finished, press any key to exit
\n
"
);
printf
(
"
\n
once finished, press any key to exit
\n
"
);
getchar
();
getchar
();
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
printf
(
"%s inserted:%d retrieved:%d
\n
"
,
tableList
[
i
].
name
,
tableList
[
i
].
rowsInserted
,
tableList
[
i
].
rowsRetrieved
);
}
getchar
();
while
(
1
)
{
while
(
1
)
{
if
(
tablesProcessed
<
numOfTables
)
{
if
(
tables
Select
Processed
<
numOfTables
)
{
printf
(
"wait for process finished
\n
"
);
printf
(
"wait for process finished
\n
"
);
sleep
(
1
);
sleep
(
1
);
continue
;
continue
;
...
@@ -173,6 +181,10 @@ int main(int argc, char *argv[])
...
@@ -173,6 +181,10 @@ int main(int argc, char *argv[])
break
;
break
;
}
}
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
printf
(
"%s inserted:%d retrieved:%d
\n
"
,
tableList
[
i
].
name
,
tableList
[
i
].
rowsInserted
,
tableList
[
i
].
rowsRetrieved
);
}
taos_close
(
taos
);
taos_close
(
taos
);
free
(
tableList
);
free
(
tableList
);
...
@@ -214,8 +226,8 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code)
...
@@ -214,8 +226,8 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code)
}
}
else
{
else
{
printf
(
"%d rows data are inserted into %s
\n
"
,
points
,
pTable
->
name
);
printf
(
"%d rows data are inserted into %s
\n
"
,
points
,
pTable
->
name
);
tablesProcessed
++
;
tables
Insert
Processed
++
;
if
(
tablesProcessed
>=
numOfTables
)
{
if
(
tables
Insert
Processed
>=
numOfTables
)
{
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
printf
(
"%lld mseconds to insert %d data points
\n
"
,
(
et
-
st
)
/
1000
,
points
*
numOfTables
);
printf
(
"%lld mseconds to insert %d data points
\n
"
,
(
et
-
st
)
/
1000
,
points
*
numOfTables
);
...
@@ -251,15 +263,17 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -251,15 +263,17 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
//taos_free_result(tres);
//taos_free_result(tres);
printf
(
"%d rows data retrieved from %s
\n
"
,
pTable
->
rowsRetrieved
,
pTable
->
name
);
printf
(
"%d rows data retrieved from %s
\n
"
,
pTable
->
rowsRetrieved
,
pTable
->
name
);
tablesProcessed
++
;
tables
Select
Processed
++
;
if
(
tablesProcessed
>=
numOfTables
)
{
if
(
tables
Select
Processed
>=
numOfTables
)
{
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
printf
(
"%lld mseconds to query %d data rows
\n
"
,
(
et
-
st
)
/
1000
,
points
*
numOfTables
);
printf
(
"%lld mseconds to query %d data rows
\n
"
,
(
et
-
st
)
/
1000
,
points
*
numOfTables
);
}
}
}
taos_free_result
(
tres
);
taos_free_result
(
tres
);
}
}
}
void
taos_select_call_back
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
void
taos_select_call_back
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
...
@@ -276,6 +290,4 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code)
...
@@ -276,6 +290,4 @@ void taos_select_call_back(void *param, TAOS_RES *tres, int code)
taos_cleanup
();
taos_cleanup
();
exit
(
1
);
exit
(
1
);
}
}
taos_free_result
(
tres
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录