Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
19fc8eb8
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,发现更多精彩内容 >>
提交
19fc8eb8
编写于
3月 09, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3147] <fix>: support insert interval. add verbose print.
上级
b8bc8759
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
27 deletion
+35
-27
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+35
-27
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
19fc8eb8
...
...
@@ -185,6 +185,7 @@ typedef struct SArguments_S {
bool
insert_only
;
bool
answer_yes
;
bool
debug_print
;
bool
verbose_print
;
char
*
output_file
;
int
mode
;
char
*
datatype
[
MAX_NUM_DATATYPE
+
1
];
...
...
@@ -489,6 +490,7 @@ SArguments g_args = {
false
,
// use_metric
false
,
// insert_only
false
,
// debug_print
false
,
// verbose_print
false
,
// answer_yes;
"./output.txt"
,
// output_file
0
,
// mode : sync or async
...
...
@@ -526,7 +528,11 @@ static SQueryMetaInfo g_queryInfo;
static
FILE
*
g_fpOfInsertResult
=
NULL
;
#define debugPrint(fmt, ...) \
do { if (g_args.debug_print) fprintf(stderr, fmt, __VA_ARGS__); } while(0)
do { if (g_args.debug_print || g_args.verbose_print) \
fprintf(stderr, "DEBG: "fmt, __VA_ARGS__); } while(0)
#define verbosePrint(fmt, ...) \
do { if (g_args.verbose_print) fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0)
///////////////////////////////////////////////////
void
printHelp
()
{
...
...
@@ -691,6 +697,8 @@ void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
answer_yes
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
arguments
->
debug_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-gg"
)
==
0
)
{
arguments
->
verbose_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
...
...
@@ -805,7 +813,7 @@ static int queryDbExec(TAOS *taos, char *command, int type) {
}
if
(
code
!=
0
)
{
debugPrint
(
"
DEBUG
%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
debugPrint
(
"%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
res
));
taos_free_result
(
res
);
//taos_close(taos);
...
...
@@ -1986,7 +1994,7 @@ static int createSuperTable(TAOS * taos, char* dbName, SSuperTable* superTbls,
exit
(
-
1
);
}
snprintf
(
superTbls
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
debugPrint
(
"
DEBUG -
%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
superTbls
->
colsOfCreateChildTable
);
debugPrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
superTbls
->
colsOfCreateChildTable
);
if
(
use_metric
)
{
char
tags
[
STRING_LEN
]
=
"
\0
"
;
...
...
@@ -2039,13 +2047,13 @@ static int createSuperTable(TAOS * taos, char* dbName, SSuperTable* superTbls,
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.%s (ts timestamp%s) tags %s"
,
dbName
,
superTbls
->
sTblName
,
cols
,
tags
);
debugPrint
(
"
DEBUG -
%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
command
);
debugPrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
))
{
fprintf
(
stderr
,
"create supertable %s failed!
\n\n
"
,
superTbls
->
sTblName
);
return
-
1
;
}
debugPrint
(
"
DEBUG -
create supertable %s success!
\n\n
"
,
superTbls
->
sTblName
);
debugPrint
(
"create supertable %s success!
\n\n
"
,
superTbls
->
sTblName
);
}
return
0
;
}
...
...
@@ -2064,7 +2072,7 @@ static int createDatabases() {
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
db
[
i
].
drop
)
{
sprintf
(
command
,
"drop database if exists %s;"
,
g_Dbs
.
db
[
i
].
dbName
);
debugPrint
(
"DEBUG
%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
verbosePrint
(
"
%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
))
{
taos_close
(
taos
);
return
-
1
;
...
...
@@ -2132,7 +2140,7 @@ static int createDatabases() {
"precision
\'
%s
\'
;"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
debugPrint
(
"
DEBUG
%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
debugPrint
(
"%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
))
{
taos_close
(
taos
);
printf
(
"
\n
create database %s failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
...
...
@@ -2140,11 +2148,11 @@ static int createDatabases() {
}
printf
(
"
\n
create database %s success!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
debugPrint
(
"
DEBUG
%s() %d supertbl count:%d
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTblCount
);
debugPrint
(
"%s() %d supertbl count:%d
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTblCount
);
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
// describe super table, if exists
sprintf
(
command
,
"describe %s.%s;"
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sTblName
);
debugPrint
(
"DEBUG
%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
verbosePrint
(
"
%s() %d command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
superTblExists
=
TBL_NO_EXISTS
;
ret
=
createSuperTable
(
taos
,
g_Dbs
.
db
[
i
].
dbName
,
&
g_Dbs
.
db
[
i
].
superTbls
[
j
],
g_Dbs
.
use_metric
);
...
...
@@ -2232,7 +2240,7 @@ static void* createTable(void *sarg)
}
len
=
0
;
debugPrint
(
"
DEBUG
%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
debugPrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
if
(
0
!=
queryDbExec
(
winfo
->
taos
,
buffer
,
NO_INSERT_TYPE
)){
free
(
buffer
);
return
NULL
;
...
...
@@ -2247,7 +2255,7 @@ static void* createTable(void *sarg)
}
if
(
0
!=
len
)
{
debugPrint
(
"
DEBUG
%s() %d buffer: %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
debugPrint
(
"%s() %d buffer: %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
(
void
)
queryDbExec
(
winfo
->
taos
,
buffer
,
NO_INSERT_TYPE
);
}
...
...
@@ -2285,7 +2293,7 @@ int startMultiThreadCreateChildTable(
t_info
->
threadID
=
i
;
tstrncpy
(
t_info
->
db_name
,
db_name
,
MAX_DB_NAME_SIZE
);
t_info
->
superTblInfo
=
superTblInfo
;
debugPrint
(
"DEBUG
%s() %d db_name: %s
\n
"
,
__func__
,
__LINE__
,
db_name
);
verbosePrint
(
"
%s() %d db_name: %s
\n
"
,
__func__
,
__LINE__
,
db_name
);
t_info
->
taos
=
taos_connect
(
g_Dbs
.
host
,
g_Dbs
.
user
,
...
...
@@ -2336,7 +2344,7 @@ static void createChildTables() {
continue
;
}
debugPrint
(
"DEBUG -
%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
verbosePrint
(
"
%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
startMultiThreadCreateChildTable
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
,
...
...
@@ -2362,7 +2370,7 @@ static void createChildTables() {
len
=
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
")"
);
debugPrint
(
"DEBUG -
%s() LN%d: dbName: %s num of tb: %d schema: %s
\n
"
,
__func__
,
__LINE__
,
verbosePrint
(
"
%s() LN%d: dbName: %s num of tb: %d schema: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
dbName
,
g_args
.
num_of_tables
,
tblColsBuf
);
startMultiThreadCreateChildTable
(
tblColsBuf
,
...
...
@@ -3586,7 +3594,7 @@ PARSE_OVER:
}
static
bool
getInfoFromJsonFile
(
char
*
file
)
{
debugPrint
(
"
DEBUG -
%s %d %s
\n
"
,
__func__
,
__LINE__
,
file
);
debugPrint
(
"%s %d %s
\n
"
,
__func__
,
__LINE__
,
file
);
FILE
*
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
{
...
...
@@ -3938,7 +3946,7 @@ send_to_server:
int64_t
endTs
;
startTs
=
taosGetTimestampUs
();
debugPrint
(
"
DEBUG
%s() LN%d buff: %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
debugPrint
(
"%s() LN%d buff: %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
...
...
@@ -4145,7 +4153,7 @@ static void* syncWrite(void *sarg) {
if
(
g_args
.
insert_interval
)
{
st
=
taosGetTimestampMs
();
}
debugPrint
(
"
DEBUG -
%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
debugPrint
(
"%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
if
(
0
<=
affectedRows
){
...
...
@@ -4237,7 +4245,7 @@ static void* syncWriteWithStb(void *sarg) {
uint64_t
st
=
0
;
uint64_t
et
=
0
;
/*
debugPrint("
DEBUG -
%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__,
debugPrint("%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__,
superTblInfo->insertRows);
for (int i = 0; i < superTblInfo->insertRows;) {
*/
...
...
@@ -4261,7 +4269,7 @@ static void* syncWriteWithStb(void *sarg) {
int
sampleUsePos
=
samplePos
;
int
k
=
0
;
debugPrint
(
"DEBUG -
%s() LN%d num_of_RPR=%d
\n
"
,
__func__
,
__LINE__
,
g_args
.
num_of_RPR
);
verbosePrint
(
"
%s() LN%d num_of_RPR=%d
\n
"
,
__func__
,
__LINE__
,
g_args
.
num_of_RPR
);
for
(
k
=
0
;
k
<
g_args
.
num_of_RPR
;)
{
int
len
=
0
;
memset
(
buffer
,
0
,
superTblInfo
->
maxSqlLen
);
...
...
@@ -4345,7 +4353,7 @@ static void* syncWriteWithStb(void *sarg) {
k
++
;
i
++
;
totalRowsInserted
++
;
debugPrint
(
"
DEBUG -
%s() LN%d totalInserted=%"
PRId64
" inserted=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
totalRowsInserted
,
inserted
);
debugPrint
(
"%s() LN%d totalInserted=%"
PRId64
" inserted=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
totalRowsInserted
,
inserted
);
// if (inserted > superTblInfo->insertRows)
if
(
inserted
>
g_args
.
num_of_RPR
)
...
...
@@ -4362,7 +4370,7 @@ static void* syncWriteWithStb(void *sarg) {
int64_t
endTs
;
startTs
=
taosGetTimestampUs
();
debugPrint
(
"DEBUG
%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
verbosePrint
(
"
%s() LN%d %s
\n
"
,
__func__
,
__LINE__
,
buffer
);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
INSERT_TYPE
);
if
(
0
>
affectedRows
){
...
...
@@ -4848,7 +4856,7 @@ int insertTestProcess() {
if
(
ret
==
-
1
)
exit
(
EXIT_FAILURE
);
debugPrint
(
"
DEBUG -
%d result file: %s
\n
"
,
__LINE__
,
g_Dbs
.
resultFile
);
debugPrint
(
"%d result file: %s
\n
"
,
__LINE__
,
g_Dbs
.
resultFile
);
g_fpOfInsertResult
=
fopen
(
g_Dbs
.
resultFile
,
"a"
);
if
(
NULL
==
g_fpOfInsertResult
)
{
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
g_Dbs
.
resultFile
);
...
...
@@ -5085,7 +5093,7 @@ static int queryTestProcess() {
char
sqlStr
[
MAX_TB_NAME_SIZE
*
2
];
sprintf
(
sqlStr
,
"use %s"
,
g_queryInfo
.
dbName
);
debugPrint
(
"DEBUG
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
verbosePrint
(
"
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
(
void
)
queryDbExec
(
t_info
->
taos
,
sqlStr
,
NO_INSERT_TYPE
);
}
else
{
t_info
->
taos
=
NULL
;
...
...
@@ -5196,7 +5204,7 @@ void *subSubscribeProcess(void *sarg) {
char
sqlStr
[
MAX_TB_NAME_SIZE
*
2
];
sprintf
(
sqlStr
,
"use %s"
,
g_queryInfo
.
dbName
);
debugPrint
(
"DEBUG
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
debugPrint
(
"
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
if
(
0
!=
queryDbExec
(
winfo
->
taos
,
sqlStr
,
NO_INSERT_TYPE
)){
return
NULL
;
}
...
...
@@ -5262,7 +5270,7 @@ void *superSubscribeProcess(void *sarg) {
char
sqlStr
[
MAX_TB_NAME_SIZE
*
2
];
sprintf
(
sqlStr
,
"use %s"
,
g_queryInfo
.
dbName
);
debugPrint
(
"DEBUG
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
debugPrint
(
"
%s() %d sqlStr: %s
\n
"
,
__func__
,
__LINE__
,
sqlStr
);
if
(
0
!=
queryDbExec
(
winfo
->
taos
,
sqlStr
,
NO_INSERT_TYPE
))
{
return
NULL
;
}
...
...
@@ -5627,7 +5635,7 @@ void querySqlFile(TAOS* taos, char* sqlFile)
}
memcpy
(
cmd
+
cmd_len
,
line
,
read_len
);
debugPrint
(
"DEBUG
%s() LN%d cmd: %s
\n
"
,
__func__
,
__LINE__
,
cmd
);
verbosePrint
(
"
%s() LN%d cmd: %s
\n
"
,
__func__
,
__LINE__
,
cmd
);
queryDbExec
(
taos
,
cmd
,
NO_INSERT_TYPE
);
memset
(
cmd
,
0
,
MAX_SQL_SIZE
);
cmd_len
=
0
;
...
...
@@ -5715,7 +5723,7 @@ static void testCmdLine() {
int
main
(
int
argc
,
char
*
argv
[])
{
parse_args
(
argc
,
argv
,
&
g_args
);
debugPrint
(
"
DEBUG -
meta file: %s
\n
"
,
g_args
.
metaFile
);
debugPrint
(
"meta file: %s
\n
"
,
g_args
.
metaFile
);
if
(
g_args
.
metaFile
)
{
initOfInsertMeta
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录