Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BreakingJia
TDengine
提交
c23043c0
T
TDengine
项目概览
BreakingJia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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,发现更多精彩内容 >>
提交
c23043c0
编写于
5月 28, 2021
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix child table exists or auto create logic.
上级
6fe3b972
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
108 addition
and
99 deletion
+108
-99
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+108
-99
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
c23043c0
...
...
@@ -240,13 +240,13 @@ typedef struct SColumn_S {
typedef
struct
SSuperTable_S
{
char
sTblName
[
MAX_TB_NAME_SIZE
+
1
];
char
dataSource
[
MAX_TB_NAME_SIZE
+
1
];
// rand_gen or sample
char
childTblPrefix
[
MAX_TB_NAME_SIZE
];
char
insertMode
[
MAX_TB_NAME_SIZE
];
// taosc, rest
uint16_t
childTblExists
;
int64_t
childTblCount
;
bool
childTblExists
;
// 0: no, 1: yes
uint64_t
batchCreateTableNum
;
// 0: no batch, > 0: batch table number in one sql
uint8_t
autoCreateTable
;
// 0: create sub table, 1: auto create sub table
char
childTblPrefix
[
MAX_TB_NAME_SIZE
];
char
dataSource
[
MAX_TB_NAME_SIZE
+
1
];
// rand_gen or sample
char
insertMode
[
MAX_TB_NAME_SIZE
];
// taosc, rest
int64_t
childTblLimit
;
uint64_t
childTblOffset
;
...
...
@@ -793,7 +793,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-q need a number following!
\n
Query mode -- 0: SYNC,
1
: ASYNC. Default is SYNC.
\n
"
);
errorPrint
(
"%s"
,
"
\n\t
-q need a number following!
\n
Query mode -- 0: SYNC,
not-0
: ASYNC. Default is SYNC.
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
async_mode
=
atoi
(
argv
[
++
i
]);
...
...
@@ -1417,7 +1417,8 @@ static int printfInsertMeta() {
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
}
else
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
}
else
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"yes"
);
}
else
{
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"error"
);
...
...
@@ -3007,60 +3008,61 @@ static void createChildTables() {
char
tblColsBuf
[
MAX_SQL_SIZE
];
int
len
;
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
use_metric
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
// with super table
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
if
(
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
continue
;
}
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
use_metric
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
// with super table
for
(
int
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
if
((
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
||
(
TBL_ALREADY_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
))
{
continue
;
}
verbosePrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
uint64_t
startFrom
=
0
;
g_totalChildTables
+=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
;
verbosePrint
(
"%s() LN%d: create %"
PRId64
" child tables from %"
PRIu64
"
\n
"
,
__func__
,
__LINE__
,
g_totalChildTables
,
startFrom
);
startMultiThreadCreateChildTable
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
,
g_Dbs
.
threadCountByCreateTbl
,
startFrom
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
,
g_Dbs
.
db
[
i
].
dbName
,
&
(
g_Dbs
.
db
[
i
].
superTbls
[
j
]));
}
}
}
else
{
// normal table
len
=
snprintf
(
tblColsBuf
,
MAX_SQL_SIZE
,
"(TS TIMESTAMP"
);
for
(
int
j
=
0
;
j
<
g_args
.
num_of_CPR
;
j
++
)
{
if
((
strncasecmp
(
g_args
.
datatype
[
j
],
"BINARY"
,
strlen
(
"BINARY"
))
==
0
)
||
(
strncasecmp
(
g_args
.
datatype
[
j
],
"NCHAR"
,
strlen
(
"NCHAR"
))
==
0
))
{
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
", COL%d %s(%d)"
,
j
,
g_args
.
datatype
[
j
],
g_args
.
len_of_binary
);
}
else
{
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
", COL%d %s"
,
j
,
g_args
.
datatype
[
j
]);
}
len
=
strlen
(
tblColsBuf
);
}
verbosePrint
(
"%s() LN%d: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
uint64_t
startFrom
=
0
;
g_totalChildTables
+=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
;
verbosePrint
(
"%s() LN%d: create %"
PRId64
" child tables from %"
PRIu64
"
\n
"
,
__func__
,
__LINE__
,
g_totalChildTables
,
startFrom
);
startMultiThreadCreateChildTable
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
,
g_Dbs
.
threadCountByCreateTbl
,
startFrom
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
,
g_Dbs
.
db
[
i
].
dbName
,
&
(
g_Dbs
.
db
[
i
].
superTbls
[
j
]));
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
")"
);
verbosePrint
(
"%s() LN%d: dbName: %s num of tb: %"
PRId64
" schema: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
dbName
,
g_args
.
num_of_tables
,
tblColsBuf
);
startMultiThreadCreateChildTable
(
tblColsBuf
,
g_Dbs
.
threadCountByCreateTbl
,
0
,
g_args
.
num_of_tables
,
g_Dbs
.
db
[
i
].
dbName
,
NULL
);
}
}
}
else
{
// normal table
len
=
snprintf
(
tblColsBuf
,
MAX_SQL_SIZE
,
"(TS TIMESTAMP"
);
for
(
int
j
=
0
;
j
<
g_args
.
num_of_CPR
;
j
++
)
{
if
((
strncasecmp
(
g_args
.
datatype
[
j
],
"BINARY"
,
strlen
(
"BINARY"
))
==
0
)
||
(
strncasecmp
(
g_args
.
datatype
[
j
],
"NCHAR"
,
strlen
(
"NCHAR"
))
==
0
))
{
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
", COL%d %s(%d)"
,
j
,
g_args
.
datatype
[
j
],
g_args
.
len_of_binary
);
}
else
{
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
", COL%d %s"
,
j
,
g_args
.
datatype
[
j
]);
}
len
=
strlen
(
tblColsBuf
);
}
snprintf
(
tblColsBuf
+
len
,
MAX_SQL_SIZE
-
len
,
")"
);
verbosePrint
(
"%s() LN%d: dbName: %s num of tb: %"
PRId64
" schema: %s
\n
"
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
dbName
,
g_args
.
num_of_tables
,
tblColsBuf
);
startMultiThreadCreateChildTable
(
tblColsBuf
,
g_Dbs
.
threadCountByCreateTbl
,
0
,
g_args
.
num_of_tables
,
g_Dbs
.
db
[
i
].
dbName
,
NULL
);
}
}
}
/*
...
...
@@ -3773,19 +3775,19 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
autoCreateTbl
&&
autoCreateTbl
->
type
==
cJSON_String
&&
autoCreateTbl
->
valuestring
!=
NULL
)
{
if
((
0
==
strncasecmp
(
autoCreateTbl
->
valuestring
,
"yes"
,
3
))
&&
(
TBL_ALREADY_EXISTS
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
AUTO_CREATE_SUBTBL
;
}
else
if
(
0
==
strncasecmp
(
autoCreateTbl
->
valuestring
,
"no"
,
2
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
}
else
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
}
if
((
0
==
strncasecmp
(
autoCreateTbl
->
valuestring
,
"yes"
,
3
))
&&
(
TBL_ALREADY_EXISTS
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
AUTO_CREATE_SUBTBL
;
}
else
if
(
0
==
strncasecmp
(
autoCreateTbl
->
valuestring
,
"no"
,
2
))
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
}
else
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
}
}
else
if
(
!
autoCreateTbl
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
}
else
{
printf
(
"ERROR: failed to read json, auto_create_table not found
\n
"
);
goto
PARSE_OVER
;
printf
(
"ERROR: failed to read json, auto_create_table not found
\n
"
);
goto
PARSE_OVER
;
}
cJSON
*
batchCreateTbl
=
cJSON_GetObjectItem
(
stbInfo
,
"batch_create_tbl_num"
);
...
...
@@ -4863,26 +4865,29 @@ static int64_t execInsert(threadInfo *pThreadInfo, char *buffer, uint64_t k)
static
void
getTableName
(
char
*
pTblName
,
threadInfo
*
pThreadInfo
,
uint64_t
tableSeq
)
{
SSuperTable
*
superTblInfo
=
pThreadInfo
->
superTblInfo
;
if
((
superTblInfo
)
&&
(
AUTO_CREATE_SUBTBL
!=
superTblInfo
->
autoCreateTable
))
{
if
(
superTblInfo
->
childTblLimit
>
0
)
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
superTblInfo
->
childTblName
+
(
tableSeq
-
superTblInfo
->
childTblOffset
)
*
TSDB_TABLE_NAME_LEN
);
SSuperTable
*
superTblInfo
=
pThreadInfo
->
superTblInfo
;
if
(
superTblInfo
)
{
if
(
AUTO_CREATE_SUBTBL
!=
superTblInfo
->
autoCreateTable
)
{
if
(
superTblInfo
->
childTblLimit
>
0
)
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
superTblInfo
->
childTblName
+
(
tableSeq
-
superTblInfo
->
childTblOffset
)
*
TSDB_TABLE_NAME_LEN
);
}
else
{
verbosePrint
(
"[%d] %s() LN%d: from=%"
PRIu64
" count=%"
PRId64
" seq=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
ntables
,
tableSeq
);
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
superTblInfo
->
childTblName
+
tableSeq
*
TSDB_TABLE_NAME_LEN
);
}
}
else
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
superTblInfo
->
childTblPrefix
,
tableSeq
);
}
}
else
{
verbosePrint
(
"[%d] %s() LN%d: from=%"
PRIu64
" count=%"
PRId64
" seq=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
ntables
,
tableSeq
);
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
superTblInfo
->
childTblName
+
tableSeq
*
TSDB_TABLE_NAME_LEN
);
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
g_args
.
tb_prefix
,
tableSeq
);
}
}
else
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
g_args
.
tb_prefix
,
tableSeq
);
}
}
static
int64_t
generateDataTail
(
...
...
@@ -6195,7 +6200,7 @@ static int insertTestProcess() {
}
}
taosMsleep
(
1000
);
//
taosMsleep(1000);
// create sub threads for inserting data
//start = taosGetTimestampMs();
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
...
...
@@ -6839,11 +6844,14 @@ static void *specifiedSubscribe(void *sarg) {
g_queryInfo
.
specifiedQueryInfo
.
res
[
pThreadInfo
->
threadID
]
=
taos_consume
(
g_queryInfo
.
specifiedQueryInfo
.
tsub
[
pThreadInfo
->
threadID
]);
if
(
g_queryInfo
.
specifiedQueryInfo
.
res
[
pThreadInfo
->
threadID
])
{
if
(
g_queryInfo
.
specifiedQueryInfo
.
result
[
pThreadInfo
->
querySeq
][
0
]
!=
0
)
{
if
(
g_queryInfo
.
specifiedQueryInfo
.
result
[
pThreadInfo
->
querySeq
][
0
]
!=
0
)
{
sprintf
(
pThreadInfo
->
filePath
,
"%s-%d"
,
g_queryInfo
.
specifiedQueryInfo
.
result
[
pThreadInfo
->
querySeq
],
pThreadInfo
->
threadID
);
fetchResult
(
g_queryInfo
.
specifiedQueryInfo
.
res
[
pThreadInfo
->
threadID
],
pThreadInfo
);
fetchResult
(
g_queryInfo
.
specifiedQueryInfo
.
res
[
pThreadInfo
->
threadID
],
pThreadInfo
);
}
g_queryInfo
.
specifiedQueryInfo
.
consumed
[
pThreadInfo
->
threadID
]
++
;
...
...
@@ -6856,16 +6864,17 @@ static void *specifiedSubscribe(void *sarg) {
g_queryInfo
.
specifiedQueryInfo
.
consumed
[
pThreadInfo
->
threadID
]
=
0
;
taos_unsubscribe
(
g_queryInfo
.
specifiedQueryInfo
.
tsub
[
pThreadInfo
->
threadID
],
g_queryInfo
.
specifiedQueryInfo
.
subscribeKeepProgress
);
g_queryInfo
.
specifiedQueryInfo
.
tsub
[
pThreadInfo
->
threadID
]
=
subscribeImpl
(
SPECIFIED_CLASS
,
pThreadInfo
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
],
g_queryInfo
.
specifiedQueryInfo
.
topic
[
pThreadInfo
->
threadID
],
g_queryInfo
.
specifiedQueryInfo
.
subscribeRestart
,
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
);
g_queryInfo
.
specifiedQueryInfo
.
tsub
[
pThreadInfo
->
threadID
]
=
subscribeImpl
(
SPECIFIED_CLASS
,
pThreadInfo
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
],
g_queryInfo
.
specifiedQueryInfo
.
topic
[
pThreadInfo
->
threadID
],
g_queryInfo
.
specifiedQueryInfo
.
subscribeRestart
,
g_queryInfo
.
specifiedQueryInfo
.
subscribeInterval
);
if
(
NULL
==
g_queryInfo
.
specifiedQueryInfo
.
tsub
[
pThreadInfo
->
threadID
])
{
taos_close
(
pThreadInfo
->
taos
);
return
NULL
;
taos_close
(
pThreadInfo
->
taos
);
return
NULL
;
}
}
}
...
...
@@ -7078,7 +7087,7 @@ static void setParaFromArg(){
g_Dbs
.
threadCountByCreateTbl
=
g_args
.
num_of_threads
;
g_Dbs
.
dbCount
=
1
;
g_Dbs
.
db
[
0
].
drop
=
1
;
g_Dbs
.
db
[
0
].
drop
=
true
;
tstrncpy
(
g_Dbs
.
db
[
0
].
dbName
,
g_args
.
database
,
MAX_DB_NAME_SIZE
);
g_Dbs
.
db
[
0
].
dbCfg
.
replica
=
g_args
.
replica
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录