Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
6c72fc31
T
TDengine
项目概览
慢慢CG
/
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看板
提交
6c72fc31
编写于
9月 09, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge with develop branch.
上级
e14d3b7b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
2152 addition
and
1102 deletion
+2152
-1102
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+2148
-1098
tests/pytest/tools/taosdemoTestTblAlt.py
tests/pytest/tools/taosdemoTestTblAlt.py
+4
-4
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
6c72fc31
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <stdint.h>
#include <taos.h>
#include <taos.h>
#include <taoserror.h>
#define _GNU_SOURCE
#define _GNU_SOURCE
#define CURL_STATICLIB
#define CURL_STATICLIB
...
@@ -109,6 +110,14 @@ extern char configDir[];
...
@@ -109,6 +110,14 @@ extern char configDir[];
#define DEFAULT_CHILDTABLES 10000
#define DEFAULT_CHILDTABLES 10000
#define STMT_BIND_PARAM_BATCH 0
char
*
g_sampleDataBuf
=
NULL
;
#if STMT_BIND_PARAM_BATCH == 1
// bind param batch
char
*
g_sampleBindBatchArray
=
NULL
;
#endif
enum
TEST_MODE
{
enum
TEST_MODE
{
INSERT_TEST
,
// 0
INSERT_TEST
,
// 0
QUERY_TEST
,
// 1
QUERY_TEST
,
// 1
...
@@ -226,18 +235,20 @@ typedef struct SArguments_S {
...
@@ -226,18 +235,20 @@ typedef struct SArguments_S {
bool
performance_print
;
bool
performance_print
;
char
*
output_file
;
char
*
output_file
;
bool
async_mode
;
bool
async_mode
;
char
*
datatype
[
MAX_NUM_COLUMNS
+
1
];
char
data_type
[
MAX_NUM_COLUMNS
+
1
];
char
*
dataType
[
MAX_NUM_COLUMNS
+
1
];
uint32_t
binwidth
;
uint32_t
binwidth
;
uint32_t
num_of_CPR
;
uint32_t
columnCount
;
uint32_t
num_of_threads
;
uint64_t
lenOfOneRow
;
uint32_t
nthreads
;
uint64_t
insert_interval
;
uint64_t
insert_interval
;
uint64_t
timestamp_step
;
uint64_t
timestamp_step
;
int64_t
query_times
;
int64_t
query_times
;
uint32_t
interlace_rows
;
uint32_t
interlace_rows
;
uint32_t
num_of_RPR
;
// num_of_records_per_req
uint32_t
reqPerReq
;
// num_of_records_per_req
uint64_t
max_sql_len
;
uint64_t
max_sql_len
;
int64_t
n
um_of_
tables
;
int64_t
ntables
;
int64_t
num_of_DPT
;
int64_t
insertRows
;
int
abort
;
int
abort
;
uint32_t
disorderRatio
;
// 0: no disorder, >0: x%
uint32_t
disorderRatio
;
// 0: no disorder, >0: x%
int
disorderRange
;
// ms, us or ns. accordig to database precision
int
disorderRange
;
// ms, us or ns. accordig to database precision
...
@@ -248,14 +259,15 @@ typedef struct SArguments_S {
...
@@ -248,14 +259,15 @@ typedef struct SArguments_S {
}
SArguments
;
}
SArguments
;
typedef
struct
SColumn_S
{
typedef
struct
SColumn_S
{
char
field
[
TSDB_COL_NAME_LEN
];
char
field
[
TSDB_COL_NAME_LEN
];
char
dataType
[
DATATYPE_BUFF_LEN
];
char
data_type
;
uint32_t
dataLen
;
char
dataType
[
DATATYPE_BUFF_LEN
];
char
note
[
NOTE_BUFF_LEN
];
uint32_t
dataLen
;
char
note
[
NOTE_BUFF_LEN
];
}
StrColumn
;
}
StrColumn
;
typedef
struct
SSuperTable_S
{
typedef
struct
SSuperTable_S
{
char
s
Tbl
Name
[
TSDB_TABLE_NAME_LEN
];
char
s
tb
Name
[
TSDB_TABLE_NAME_LEN
];
char
dataSource
[
SMALL_BUFF_LEN
];
// rand_gen or sample
char
dataSource
[
SMALL_BUFF_LEN
];
// rand_gen or sample
char
childTblPrefix
[
TBNAME_PREFIX_LEN
];
char
childTblPrefix
[
TBNAME_PREFIX_LEN
];
uint16_t
childTblExists
;
uint16_t
childTblExists
;
...
@@ -297,6 +309,10 @@ typedef struct SSuperTable_S {
...
@@ -297,6 +309,10 @@ typedef struct SSuperTable_S {
uint32_t
tagSampleCount
;
uint32_t
tagSampleCount
;
uint32_t
tagUsePos
;
uint32_t
tagUsePos
;
#if STMT_BIND_PARAM_BATCH == 1
// bind param batch
char
*
sampleBindBatchArray
;
#endif
// statistics
// statistics
uint64_t
totalInsertRows
;
uint64_t
totalInsertRows
;
uint64_t
totalAffectedRows
;
uint64_t
totalAffectedRows
;
...
@@ -396,7 +412,7 @@ typedef struct SpecifiedQueryInfo_S {
...
@@ -396,7 +412,7 @@ typedef struct SpecifiedQueryInfo_S {
}
SpecifiedQueryInfo
;
}
SpecifiedQueryInfo
;
typedef
struct
SuperQueryInfo_S
{
typedef
struct
SuperQueryInfo_S
{
char
s
Tbl
Name
[
TSDB_TABLE_NAME_LEN
];
char
s
tb
Name
[
TSDB_TABLE_NAME_LEN
];
uint64_t
queryInterval
;
// 0: unlimit > 0 loop/s
uint64_t
queryInterval
;
// 0: unlimit > 0 loop/s
uint32_t
threadCnt
;
uint32_t
threadCnt
;
uint32_t
asyncMode
;
// 0: sync, 1: async
uint32_t
asyncMode
;
// 0: sync, 1: async
...
@@ -435,8 +451,17 @@ typedef struct SQueryMetaInfo_S {
...
@@ -435,8 +451,17 @@ typedef struct SQueryMetaInfo_S {
typedef
struct
SThreadInfo_S
{
typedef
struct
SThreadInfo_S
{
TAOS
*
taos
;
TAOS
*
taos
;
TAOS_STMT
*
stmt
;
TAOS_STMT
*
stmt
;
char
*
sampleBindArray
;
int64_t
*
bind_ts
;
#if STMT_BIND_PARAM_BATCH == 1
int64_t
*
bind_ts
;
int64_t
*
bind_ts_array
;
char
*
bindParams
;
char
*
is_null
;
#else
int64_t
*
bind_ts
;
char
*
sampleBindArray
;
#endif
int
threadID
;
int
threadID
;
char
db_name
[
TSDB_DB_NAME_LEN
];
char
db_name
[
TSDB_DB_NAME_LEN
];
uint32_t
time_precision
;
uint32_t
time_precision
;
...
@@ -612,22 +637,26 @@ SArguments g_args = {
...
@@ -612,22 +637,26 @@ SArguments g_args = {
false
,
// answer_yes;
false
,
// answer_yes;
"./output.txt"
,
// output_file
"./output.txt"
,
// output_file
0
,
// mode : sync or async
0
,
// mode : sync or async
{
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_FLOAT
},
{
{
"FLOAT"
,
// data
t
ype
"FLOAT"
,
// data
T
ype
"INT"
,
// data
t
ype
"INT"
,
// data
T
ype
"FLOAT"
,
// data
type. DEFAULT_DATATYPE_NUM is 3
"FLOAT"
,
// data
Type. demo mode has 3 columns
},
},
64
,
// binwidth
64
,
// binwidth
4
,
// num_of_CPR
4
,
// columnCount, timestamp + float + int + float
10
,
// num_of_connections/thread
20
+
FLOAT_BUFF_LEN
+
INT_BUFF_LEN
+
FLOAT_BUFF_LEN
,
// lenOfOneRow
8
,
// num_of_connections/thread
0
,
// insert_interval
0
,
// insert_interval
DEFAULT_TIMESTAMP_STEP
,
// timestamp_step
DEFAULT_TIMESTAMP_STEP
,
// timestamp_step
1
,
// query_times
1
,
// query_times
DEFAULT_INTERLACE_ROWS
,
// interlace_rows;
DEFAULT_INTERLACE_ROWS
,
// interlace_rows;
30000
,
//
num_of_RPR
30000
,
//
reqPerReq
(
1024
*
1024
),
// max_sql_len
(
1024
*
1024
),
// max_sql_len
DEFAULT_CHILDTABLES
,
// n
um_of_
tables
DEFAULT_CHILDTABLES
,
// ntables
10000
,
//
num_of_DPT
10000
,
//
insertRows
0
,
// abort
0
,
// abort
0
,
// disorderRatio
0
,
// disorderRatio
1000
,
// disorderRange
1000
,
// disorderRange
...
@@ -752,12 +781,11 @@ static void printHelp() {
...
@@ -752,12 +781,11 @@ static void printHelp() {
"Set the replica parameters of the database, Default 1, min: 1, max: 3."
);
"Set the replica parameters of the database, Default 1, min: 1, max: 3."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-m, --table-prefix=TABLEPREFIX"
,
"
\t
"
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-m, --table-prefix=TABLEPREFIX"
,
"
\t
"
,
"Table prefix name. Default is 'd'."
);
"Table prefix name. Default is 'd'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-s, --sql-file=FILE"
,
"
\t\t
"
,
"The select sql file."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-s, --sql-file=FILE"
,
"
\t\t
"
,
"The select sql file."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-N, --normal-table"
,
"
\t\t
"
,
"Use normal table flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-N, --normal-table"
,
"
\t\t
"
,
"Use normal table flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o, --output=FILE"
,
"
\t\t
"
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o, --output=FILE"
,
"
\t\t
"
,
"Direct output to the named file. Default is './output.txt'."
);
"Direct output to the named file. Default is './output.txt'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-s, --sql-file=FILE"
,
"
\t\t
"
,
"The select sql file."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q, --query-mode=MODE"
,
"
\t\t
"
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q, --query-mode=MODE"
,
"
\t\t
"
,
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."
);
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b, --data-type=DATATYPE"
,
"
\t
"
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b, --data-type=DATATYPE"
,
"
\t
"
,
...
@@ -829,6 +857,12 @@ static bool isStringNumber(char *input)
...
@@ -829,6 +857,12 @@ static bool isStringNumber(char *input)
return
true
;
return
true
;
}
}
static
void
errorWrongValue
(
char
*
program
,
char
*
wrong_arg
,
char
*
wrong_value
)
{
fprintf
(
stderr
,
"%s %s: %s is an invalid value
\n
"
,
program
,
wrong_arg
,
wrong_value
);
fprintf
(
stderr
,
"Try `taosdemo --help' or `taosdemo --usage' for more information.
\n
"
);
}
static
void
errorUnreconized
(
char
*
program
,
char
*
wrong_arg
)
static
void
errorUnreconized
(
char
*
program
,
char
*
wrong_arg
)
{
{
fprintf
(
stderr
,
"%s: unrecognized options '%s'
\n
"
,
program
,
wrong_arg
);
fprintf
(
stderr
,
"%s: unrecognized options '%s'
\n
"
,
program
,
wrong_arg
);
...
@@ -898,7 +932,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -898,7 +932,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
}
tstrncpy
(
configDir
,
argv
[
++
i
],
TSDB_FILENAME_LEN
);
tstrncpy
(
configDir
,
argv
[
++
i
],
TSDB_FILENAME_LEN
);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-c"
,
strlen
(
"-c"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-c"
,
strlen
(
"-c"
)))
{
tstrncpy
(
configDir
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-"
)),
TSDB_FILENAME_LEN
);
tstrncpy
(
configDir
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-
c
"
)),
TSDB_FILENAME_LEN
);
}
else
if
(
strlen
(
"--config-dir"
)
==
strlen
(
argv
[
i
]))
{
}
else
if
(
strlen
(
"--config-dir"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--config-dir"
);
errorPrintReqArg3
(
argv
[
0
],
"--config-dir"
);
...
@@ -981,7 +1015,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -981,7 +1015,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
{
}
else
{
error
PrintReqArg
(
argv
[
0
],
"I"
);
error
WrongValue
(
argv
[
0
],
"-I"
,
argv
[
i
+
1
]
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
i
++
;
i
++
;
...
@@ -1004,7 +1038,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1004,7 +1038,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)),
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
((
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)),
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
{
}
else
{
errorPrintReqArg3
(
argv
[
0
],
"-I"
);
errorWrongValue
(
argv
[
0
],
"-I"
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-I"
)));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
strlen
(
"--interface"
)
==
strlen
(
argv
[
i
]))
{
}
else
if
(
strlen
(
"--interface"
)
==
strlen
(
argv
[
i
]))
{
...
@@ -1019,7 +1054,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1019,7 +1054,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
}
else
if
(
0
==
strcasecmp
(
argv
[
i
+
1
],
"stmt"
))
{
arguments
->
iface
=
STMT_IFACE
;
arguments
->
iface
=
STMT_IFACE
;
}
else
{
}
else
{
error
PrintReqArg3
(
argv
[
0
],
"--interface"
);
error
WrongValue
(
argv
[
0
],
"--interface"
,
argv
[
i
+
1
]
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
i
++
;
i
++
;
...
@@ -1092,9 +1127,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1092,9 +1127,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
}
arguments
->
sqlFile
=
argv
[
++
i
];
arguments
->
sqlFile
=
argv
[
++
i
];
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--sql-file="
,
strlen
(
"--sql-file="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--sql-file="
,
strlen
(
"--sql-file="
)))
{
arguments
->
host
=
(
char
*
)(
argv
[
i
++
]
+
strlen
(
"--sql-file="
));
arguments
->
sqlFile
=
(
char
*
)(
argv
[
i
++
]
+
strlen
(
"--sql-file="
));
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-s"
,
strlen
(
"-s"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-s"
,
strlen
(
"-s"
)))
{
arguments
->
host
=
(
char
*
)(
argv
[
i
++
]
+
strlen
(
"-s"
));
arguments
->
sqlFile
=
(
char
*
)(
argv
[
i
++
]
+
strlen
(
"-s"
));
}
else
if
(
strlen
(
"--sql-file"
)
==
strlen
(
argv
[
i
]))
{
}
else
if
(
strlen
(
"--sql-file"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--sql-file"
);
errorPrintReqArg3
(
argv
[
0
],
"--sql-file"
);
...
@@ -1153,17 +1188,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1153,17 +1188,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"T"
);
errorPrintReqArg2
(
argv
[
0
],
"T"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
n
um_of_
threads
=
atoi
(
argv
[
++
i
]);
arguments
->
nthreads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--threads="
,
strlen
(
"--threads="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--threads="
,
strlen
(
"--threads="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--threads="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--threads="
))))
{
arguments
->
n
um_of_
threads
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--threads="
)));
arguments
->
nthreads
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--threads="
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--threads"
);
errorPrintReqArg2
(
argv
[
0
],
"--threads"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-T"
,
strlen
(
"-T"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-T"
,
strlen
(
"-T"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-T"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-T"
))))
{
arguments
->
n
um_of_
threads
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-T"
)));
arguments
->
nthreads
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-T"
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-T"
);
errorPrintReqArg2
(
argv
[
0
],
"-T"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1176,7 +1211,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1176,7 +1211,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"--threads"
);
errorPrintReqArg2
(
argv
[
0
],
"--threads"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
n
um_of_
threads
=
atoi
(
argv
[
++
i
]);
arguments
->
nthreads
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1313,17 +1348,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1313,17 +1348,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"r"
);
errorPrintReqArg2
(
argv
[
0
],
"r"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
arguments
->
reqPerReq
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--rec-per-req="
,
strlen
(
"--rec-per-req="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--rec-per-req="
,
strlen
(
"--rec-per-req="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--rec-per-req="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--rec-per-req="
))))
{
arguments
->
num_of_RPR
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--rec-per-req="
)));
arguments
->
reqPerReq
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--rec-per-req="
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--rec-per-req"
);
errorPrintReqArg2
(
argv
[
0
],
"--rec-per-req"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-r"
,
strlen
(
"-r"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-r"
,
strlen
(
"-r"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-r"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-r"
))))
{
arguments
->
num_of_RPR
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-r"
)));
arguments
->
reqPerReq
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-r"
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-r"
);
errorPrintReqArg2
(
argv
[
0
],
"-r"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1336,7 +1371,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1336,7 +1371,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"--rec-per-req"
);
errorPrintReqArg2
(
argv
[
0
],
"--rec-per-req"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
arguments
->
reqPerReq
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1351,17 +1386,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1351,17 +1386,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"t"
);
errorPrintReqArg2
(
argv
[
0
],
"t"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
n
um_of_
tables
=
atoi
(
argv
[
++
i
]);
arguments
->
ntables
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--tables="
,
strlen
(
"--tables="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--tables="
,
strlen
(
"--tables="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--tables="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--tables="
))))
{
arguments
->
n
um_of_
tables
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--tables="
)));
arguments
->
ntables
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--tables="
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--tables"
);
errorPrintReqArg2
(
argv
[
0
],
"--tables"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-t"
,
strlen
(
"-t"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-t"
,
strlen
(
"-t"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-t"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-t"
))))
{
arguments
->
n
um_of_
tables
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-t"
)));
arguments
->
ntables
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-t"
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-t"
);
errorPrintReqArg2
(
argv
[
0
],
"-t"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1374,13 +1409,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1374,13 +1409,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"--tables"
);
errorPrintReqArg2
(
argv
[
0
],
"--tables"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
n
um_of_
tables
=
atoi
(
argv
[
++
i
]);
arguments
->
ntables
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
g_totalChildTables
=
arguments
->
n
um_of_
tables
;
g_totalChildTables
=
arguments
->
ntables
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-n"
,
strlen
(
"-n"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-n"
,
strlen
(
"-n"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--records"
,
strlen
(
"--records"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--records"
,
strlen
(
"--records"
))))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
...
@@ -1391,17 +1426,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1391,17 +1426,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"n"
);
errorPrintReqArg2
(
argv
[
0
],
"n"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
arguments
->
insertRows
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--records="
,
strlen
(
"--records="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--records="
,
strlen
(
"--records="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--records="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--records="
))))
{
arguments
->
num_of_DPT
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--records="
)));
arguments
->
insertRows
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--records="
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--records"
);
errorPrintReqArg2
(
argv
[
0
],
"--records"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-n"
,
strlen
(
"-n"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-n"
,
strlen
(
"-n"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-n"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-n"
))))
{
arguments
->
num_of_DPT
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-n"
)));
arguments
->
insertRows
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-n"
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-n"
);
errorPrintReqArg2
(
argv
[
0
],
"-n"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1414,7 +1449,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1414,7 +1449,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"--records"
);
errorPrintReqArg2
(
argv
[
0
],
"--records"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
arguments
->
insertRows
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1452,17 +1487,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1452,17 +1487,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"l"
);
errorPrintReqArg2
(
argv
[
0
],
"l"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
arguments
->
columnCount
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--columns="
,
strlen
(
"--columns="
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--columns="
,
strlen
(
"--columns="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--columns="
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--columns="
))))
{
arguments
->
num_of_CPR
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--columns="
)));
arguments
->
columnCount
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--columns="
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--columns"
);
errorPrintReqArg2
(
argv
[
0
],
"--columns"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-l"
,
strlen
(
"-l"
)))
{
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-l"
,
strlen
(
"-l"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-l"
))))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-l"
))))
{
arguments
->
num_of_CPR
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-l"
)));
arguments
->
columnCount
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-l"
)));
}
else
{
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-l"
);
errorPrintReqArg2
(
argv
[
0
],
"-l"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -1475,23 +1510,25 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1475,23 +1510,25 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrintReqArg2
(
argv
[
0
],
"--columns"
);
errorPrintReqArg2
(
argv
[
0
],
"--columns"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
arguments
->
columnCount
=
atoi
(
argv
[
++
i
]);
}
else
{
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
arguments
->
num_of_CPR
>
MAX_NUM_COLUMNS
)
{
if
(
arguments
->
columnCount
>
MAX_NUM_COLUMNS
)
{
printf
(
"WARNING: max acceptible columns count is %d
\n
"
,
MAX_NUM_COLUMNS
);
printf
(
"WARNING: max acceptible columns count is %d
\n
"
,
MAX_NUM_COLUMNS
);
prompt
();
prompt
();
arguments
->
num_of_CPR
=
MAX_NUM_COLUMNS
;
arguments
->
columnCount
=
MAX_NUM_COLUMNS
;
}
}
for
(
int
col
=
DEFAULT_DATATYPE_NUM
;
col
<
arguments
->
num_of_CPR
;
col
++
)
{
for
(
int
col
=
DEFAULT_DATATYPE_NUM
;
col
<
arguments
->
columnCount
;
col
++
)
{
arguments
->
datatype
[
col
]
=
"INT"
;
arguments
->
dataType
[
col
]
=
"INT"
;
arguments
->
data_type
[
col
]
=
TSDB_DATA_TYPE_INT
;
}
}
for
(
int
col
=
arguments
->
num_of_CPR
;
col
<
MAX_NUM_COLUMNS
;
col
++
)
{
for
(
int
col
=
arguments
->
columnCount
;
col
<
MAX_NUM_COLUMNS
;
col
++
)
{
arguments
->
datatype
[
col
]
=
NULL
;
arguments
->
dataType
[
col
]
=
NULL
;
arguments
->
data_type
[
col
]
=
TSDB_DATA_TYPE_NULL
;
}
}
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-b"
,
strlen
(
"-b"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-b"
,
strlen
(
"-b"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--data-type"
,
strlen
(
"--data-type"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--data-type"
,
strlen
(
"--data-type"
))))
{
...
@@ -1535,8 +1572,32 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1535,8 +1572,32 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
datatype
[
0
]
=
dataType
;
arguments
->
dataType
[
0
]
=
dataType
;
arguments
->
datatype
[
1
]
=
NULL
;
if
(
0
==
strcasecmp
(
dataType
,
"INT"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"TINYINT"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"SMALLINT"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BIGINT"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"FLOAT"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"DOUBLE"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BINARY"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"NCHAR"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BOOL"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"TIMESTAMP"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_NULL
;
}
arguments
->
dataType
[
1
]
=
NULL
;
arguments
->
data_type
[
1
]
=
TSDB_DATA_TYPE_NULL
;
}
else
{
}
else
{
// more than one col
// more than one col
int
index
=
0
;
int
index
=
0
;
...
@@ -1559,11 +1620,37 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1559,11 +1620,37 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
errorPrint
(
"%s"
,
"-b: Invalid data_type!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
arguments
->
datatype
[
index
++
]
=
token
;
if
(
0
==
strcasecmp
(
token
,
"INT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"FLOAT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"SMALLINT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"BIGINT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"DOUBLE"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"TINYINT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"BINARY"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strcasecmp
(
token
,
"NCHAR"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strcasecmp
(
token
,
"BOOL"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strcasecmp
(
token
,
"TIMESTAMP"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_NULL
;
}
arguments
->
dataType
[
index
]
=
token
;
index
++
;
token
=
strsep
(
&
running
,
","
);
token
=
strsep
(
&
running
,
","
);
if
(
index
>=
MAX_NUM_COLUMNS
)
break
;
if
(
index
>=
MAX_NUM_COLUMNS
)
break
;
}
}
arguments
->
datatype
[
index
]
=
NULL
;
arguments
->
dataType
[
index
]
=
NULL
;
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_NULL
;
}
}
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-w"
,
strlen
(
"-w"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-w"
,
strlen
(
"-w"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--binwidth"
,
strlen
(
"--binwidth"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--binwidth"
,
strlen
(
"--binwidth"
))))
{
...
@@ -1642,6 +1729,54 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1642,6 +1729,54 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
debug_print
=
true
;
arguments
->
debug_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-gg"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-gg"
)
==
0
)
{
arguments
->
verbose_print
=
true
;
arguments
->
verbose_print
=
true
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-R"
,
strlen
(
"-R"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--disorder-range"
,
strlen
(
"--disorder-range"
))))
{
if
(
strlen
(
"-R"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg
(
argv
[
0
],
"R"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
errorPrintReqArg2
(
argv
[
0
],
"R"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--disorder-range="
,
strlen
(
"--disorder-range="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--disorder-range="
))))
{
arguments
->
disorderRange
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--disorder-range="
)));
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-R"
,
strlen
(
"-R"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-R"
))))
{
arguments
->
disorderRange
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-R"
)));
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-R"
);
exit
(
EXIT_FAILURE
);
}
if
(
arguments
->
disorderRange
<
0
)
{
errorPrint
(
"Invalid disorder range %d, will be set to %d
\n
"
,
arguments
->
disorderRange
,
1000
);
arguments
->
disorderRange
=
1000
;
}
}
else
if
(
strlen
(
"--disorder-range"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
errorPrintReqArg2
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
}
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-O"
,
strlen
(
"-O"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-O"
,
strlen
(
"-O"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--disorder"
,
strlen
(
"--disorder"
))))
{
||
(
0
==
strncmp
(
argv
[
i
],
"--disorder"
,
strlen
(
"--disorder"
))))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
...
@@ -1692,54 +1827,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1692,54 +1827,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
disorderRatio
,
0
);
arguments
->
disorderRatio
,
0
);
arguments
->
disorderRatio
=
0
;
arguments
->
disorderRatio
=
0
;
}
}
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-R"
,
strlen
(
"-R"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--disorder-range"
,
strlen
(
"--disorder-range"
))))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg
(
argv
[
0
],
"R"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
errorPrintReqArg2
(
argv
[
0
],
"R"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--disorder-range="
,
strlen
(
"--disorder-range="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--disorder-range="
))))
{
arguments
->
disorderRange
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--disorder-rnage="
)));
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-R"
,
strlen
(
"-R"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-R"
))))
{
arguments
->
disorderRange
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-R"
)));
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"-R"
);
exit
(
EXIT_FAILURE
);
}
if
(
arguments
->
disorderRange
<
0
)
{
errorPrint
(
"Invalid disorder range %d, will be set to %d
\n
"
,
arguments
->
disorderRange
,
1000
);
arguments
->
disorderRange
=
1000
;
}
}
else
if
(
strlen
(
"--disorder-range"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
errorPrintReqArg2
(
argv
[
0
],
"--disorder-range"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
}
else
{
errorUnreconized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
}
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-a"
,
strlen
(
"-a"
)))
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-a"
,
strlen
(
"-a"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--replica"
,
||
(
0
==
strncmp
(
argv
[
i
],
"--replica"
,
strlen
(
"--replica"
))))
{
strlen
(
"--replica"
))))
{
...
@@ -1834,7 +1921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1834,7 +1921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
int
columnCount
;
int
columnCount
;
for
(
columnCount
=
0
;
columnCount
<
MAX_NUM_COLUMNS
;
columnCount
++
)
{
for
(
columnCount
=
0
;
columnCount
<
MAX_NUM_COLUMNS
;
columnCount
++
)
{
if
(
g_args
.
data
t
ype
[
columnCount
]
==
NULL
)
{
if
(
g_args
.
data
T
ype
[
columnCount
]
==
NULL
)
{
break
;
break
;
}
}
}
}
...
@@ -1842,7 +1929,56 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1842,7 +1929,56 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
if
(
0
==
columnCount
)
{
if
(
0
==
columnCount
)
{
ERROR_EXIT
(
"data type error!"
);
ERROR_EXIT
(
"data type error!"
);
}
}
g_args
.
num_of_CPR
=
columnCount
;
g_args
.
columnCount
=
columnCount
;
g_args
.
lenOfOneRow
=
20
;
// timestamp
for
(
int
c
=
0
;
c
<
g_args
.
columnCount
;
c
++
)
{
switch
(
g_args
.
data_type
[
c
])
{
case
TSDB_DATA_TYPE_BINARY
:
g_args
.
lenOfOneRow
+=
g_args
.
binwidth
+
3
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
g_args
.
lenOfOneRow
+=
g_args
.
binwidth
+
3
;
break
;
case
TSDB_DATA_TYPE_INT
:
g_args
.
lenOfOneRow
+=
INT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
g_args
.
lenOfOneRow
+=
BIGINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
g_args
.
lenOfOneRow
+=
SMALLINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
g_args
.
lenOfOneRow
+=
TINYINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
g_args
.
lenOfOneRow
+=
BOOL_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
g_args
.
lenOfOneRow
+=
FLOAT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
g_args
.
lenOfOneRow
+=
DOUBLE_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
g_args
.
lenOfOneRow
+=
TIMESTAMP_BUFF_LEN
;
break
;
default:
errorPrint2
(
"get error data type : %s
\n
"
,
g_args
.
dataType
[
c
]);
exit
(
EXIT_FAILURE
);
}
}
if
(((
arguments
->
debug_print
)
&&
(
NULL
!=
arguments
->
metaFile
))
if
(((
arguments
->
debug_print
)
&&
(
NULL
!=
arguments
->
metaFile
))
||
arguments
->
verbose_print
)
{
||
arguments
->
verbose_print
)
{
...
@@ -1855,11 +1991,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1855,11 +1991,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
printf
(
"# Password: %s
\n
"
,
arguments
->
password
);
printf
(
"# Password: %s
\n
"
,
arguments
->
password
);
printf
(
"# Use metric: %s
\n
"
,
printf
(
"# Use metric: %s
\n
"
,
arguments
->
use_metric
?
"true"
:
"false"
);
arguments
->
use_metric
?
"true"
:
"false"
);
if
(
*
(
arguments
->
data
t
ype
))
{
if
(
*
(
arguments
->
data
T
ype
))
{
printf
(
"# Specified data type: "
);
printf
(
"# Specified data type: "
);
for
(
int
c
=
0
;
c
<
MAX_NUM_COLUMNS
;
c
++
)
for
(
int
c
=
0
;
c
<
MAX_NUM_COLUMNS
;
c
++
)
if
(
arguments
->
data
t
ype
[
c
])
if
(
arguments
->
data
T
ype
[
c
])
printf
(
"%s,"
,
arguments
->
data
t
ype
[
c
]);
printf
(
"%s,"
,
arguments
->
data
T
ype
[
c
]);
else
else
break
;
break
;
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -1867,15 +2003,15 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -1867,15 +2003,15 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
printf
(
"# Insertion interval: %"
PRIu64
"
\n
"
,
printf
(
"# Insertion interval: %"
PRIu64
"
\n
"
,
arguments
->
insert_interval
);
arguments
->
insert_interval
);
printf
(
"# Number of records per req: %u
\n
"
,
printf
(
"# Number of records per req: %u
\n
"
,
arguments
->
num_of_RPR
);
arguments
->
reqPerReq
);
printf
(
"# Max SQL length: %"
PRIu64
"
\n
"
,
printf
(
"# Max SQL length: %"
PRIu64
"
\n
"
,
arguments
->
max_sql_len
);
arguments
->
max_sql_len
);
printf
(
"# Length of Binary: %d
\n
"
,
arguments
->
binwidth
);
printf
(
"# Length of Binary: %d
\n
"
,
arguments
->
binwidth
);
printf
(
"# Number of Threads: %d
\n
"
,
arguments
->
n
um_of_
threads
);
printf
(
"# Number of Threads: %d
\n
"
,
arguments
->
nthreads
);
printf
(
"# Number of Tables: %"
PRId64
"
\n
"
,
printf
(
"# Number of Tables: %"
PRId64
"
\n
"
,
arguments
->
n
um_of_
tables
);
arguments
->
ntables
);
printf
(
"# Number of Data per Table: %"
PRId64
"
\n
"
,
printf
(
"# Number of Data per Table: %"
PRId64
"
\n
"
,
arguments
->
num_of_DPT
);
arguments
->
insertRows
);
printf
(
"# Database name: %s
\n
"
,
arguments
->
database
);
printf
(
"# Database name: %s
\n
"
,
arguments
->
database
);
printf
(
"# Table prefix: %s
\n
"
,
arguments
->
tb_prefix
);
printf
(
"# Table prefix: %s
\n
"
,
arguments
->
tb_prefix
);
if
(
arguments
->
disorderRatio
)
{
if
(
arguments
->
disorderRatio
)
{
...
@@ -1901,31 +2037,20 @@ static void tmfclose(FILE *fp) {
...
@@ -1901,31 +2037,20 @@ static void tmfclose(FILE *fp) {
static
void
tmfree
(
char
*
buf
)
{
static
void
tmfree
(
char
*
buf
)
{
if
(
NULL
!=
buf
)
{
if
(
NULL
!=
buf
)
{
free
(
buf
);
free
(
buf
);
buf
=
NULL
;
}
}
}
}
static
int
queryDbExec
(
TAOS
*
taos
,
char
*
command
,
QUERY_TYPE
type
,
bool
quiet
)
{
static
int
queryDbExec
(
TAOS
*
taos
,
char
*
command
,
QUERY_TYPE
type
,
bool
quiet
)
{
int
i
;
TAOS_RES
*
res
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
/* retry */
;
i
++
)
{
verbosePrint
(
"%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
NULL
!=
res
)
{
taos_free_result
(
res
);
res
=
NULL
;
}
res
=
taos_query
(
taos
,
command
);
TAOS_RES
*
res
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
res
);
int32_t
code
=
taos_errno
(
res
);
if
(
0
==
code
)
{
break
;
}
}
verbosePrint
(
"%s() LN%d - command: %s
\n
"
,
__func__
,
__LINE__
,
command
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
if
(
!
quiet
)
{
if
(
!
quiet
)
{
errorPrint2
(
"Failed to execute
%s
, reason: %s
\n
"
,
errorPrint2
(
"Failed to execute
<%s>
, reason: %s
\n
"
,
command
,
taos_errstr
(
res
));
command
,
taos_errstr
(
res
));
}
}
taos_free_result
(
res
);
taos_free_result
(
res
);
...
@@ -2330,7 +2455,7 @@ static int printfInsertMeta() {
...
@@ -2330,7 +2455,7 @@ static int printfInsertMeta() {
printf
(
"top insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"top insert interval:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_args
.
insert_interval
);
g_args
.
insert_interval
);
printf
(
"number of records per req:
\033
[33m%u
\033
[0m
\n
"
,
printf
(
"number of records per req:
\033
[33m%u
\033
[0m
\n
"
,
g_args
.
num_of_RPR
);
g_args
.
reqPerReq
);
printf
(
"max sql length:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"max sql length:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_args
.
max_sql_len
);
g_args
.
max_sql_len
);
...
@@ -2412,7 +2537,7 @@ static int printfInsertMeta() {
...
@@ -2412,7 +2537,7 @@ static int printfInsertMeta() {
printf
(
" super table[
\033
[33m%"
PRIu64
"
\033
[0m]:
\n
"
,
j
);
printf
(
" super table[
\033
[33m%"
PRIu64
"
\033
[0m]:
\n
"
,
j
);
printf
(
" stbName:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
" stbName:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
Tbl
Name
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
tb
Name
);
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
printf
(
" autoCreateTable:
\033
[33m%s
\033
[0m
\n
"
,
"no"
);
...
@@ -2535,7 +2660,7 @@ static void printfInsertMetaToFile(FILE* fp) {
...
@@ -2535,7 +2660,7 @@ static void printfInsertMetaToFile(FILE* fp) {
fprintf
(
fp
,
"resultFile: %s
\n
"
,
g_Dbs
.
resultFile
);
fprintf
(
fp
,
"resultFile: %s
\n
"
,
g_Dbs
.
resultFile
);
fprintf
(
fp
,
"thread num of insert data: %d
\n
"
,
g_Dbs
.
threadCount
);
fprintf
(
fp
,
"thread num of insert data: %d
\n
"
,
g_Dbs
.
threadCount
);
fprintf
(
fp
,
"thread num of create table: %d
\n
"
,
g_Dbs
.
threadCountForCreateTbl
);
fprintf
(
fp
,
"thread num of create table: %d
\n
"
,
g_Dbs
.
threadCountForCreateTbl
);
fprintf
(
fp
,
"number of records per req: %u
\n
"
,
g_args
.
num_of_RPR
);
fprintf
(
fp
,
"number of records per req: %u
\n
"
,
g_args
.
reqPerReq
);
fprintf
(
fp
,
"max sql length: %"
PRIu64
"
\n
"
,
g_args
.
max_sql_len
);
fprintf
(
fp
,
"max sql length: %"
PRIu64
"
\n
"
,
g_args
.
max_sql_len
);
fprintf
(
fp
,
"database count: %d
\n
"
,
g_Dbs
.
dbCount
);
fprintf
(
fp
,
"database count: %d
\n
"
,
g_Dbs
.
dbCount
);
...
@@ -2602,7 +2727,7 @@ static void printfInsertMetaToFile(FILE* fp) {
...
@@ -2602,7 +2727,7 @@ static void printfInsertMetaToFile(FILE* fp) {
fprintf
(
fp
,
" super table[%d]:
\n
"
,
j
);
fprintf
(
fp
,
" super table[%d]:
\n
"
,
j
);
fprintf
(
fp
,
" stbName: %s
\n
"
,
fprintf
(
fp
,
" stbName: %s
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
Tbl
Name
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
tb
Name
);
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
if
(
PRE_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
{
fprintf
(
fp
,
" autoCreateTable: %s
\n
"
,
"no"
);
fprintf
(
fp
,
" autoCreateTable: %s
\n
"
,
"no"
);
...
@@ -2761,7 +2886,7 @@ static void printfQueryMeta() {
...
@@ -2761,7 +2886,7 @@ static void printfQueryMeta() {
printf
(
"childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
printf
(
"childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
childTblCount
);
g_queryInfo
.
superQueryInfo
.
childTblCount
);
printf
(
"stable name:
\033
[33m%s
\033
[0m
\n
"
,
printf
(
"stable name:
\033
[33m%s
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
s
Tbl
Name
);
g_queryInfo
.
superQueryInfo
.
s
tb
Name
);
printf
(
"stb query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
printf
(
"stb query times:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
queryTimes
);
g_queryInfo
.
superQueryInfo
.
queryTimes
);
...
@@ -2832,36 +2957,45 @@ static void xDumpFieldToFile(FILE* fp, const char* val,
...
@@ -2832,36 +2957,45 @@ static void xDumpFieldToFile(FILE* fp, const char* val,
char
buf
[
TSDB_MAX_BYTES_PER_ROW
];
char
buf
[
TSDB_MAX_BYTES_PER_ROW
];
switch
(
field
->
type
)
{
switch
(
field
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
fprintf
(
fp
,
"%d"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
1
:
0
));
fprintf
(
fp
,
"%d"
,
((((
int32_t
)(
*
((
int8_t
*
)
val
)))
==
1
)
?
1
:
0
));
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
fprintf
(
fp
,
"%d"
,
*
((
int8_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int8_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
fprintf
(
fp
,
"%d"
,
*
((
int16_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int16_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
fprintf
(
fp
,
"%d"
,
*
((
int32_t
*
)
val
));
fprintf
(
fp
,
"%d"
,
*
((
int32_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
fprintf
(
fp
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
fprintf
(
fp
,
"%"
PRId64
""
,
*
((
int64_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
fprintf
(
fp
,
"%.5f"
,
GET_FLOAT_VAL
(
val
));
fprintf
(
fp
,
"%.5f"
,
GET_FLOAT_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
fprintf
(
fp
,
"%.9f"
,
GET_DOUBLE_VAL
(
val
));
fprintf
(
fp
,
"%.9f"
,
GET_DOUBLE_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
memcpy
(
buf
,
val
,
length
);
memcpy
(
buf
,
val
,
length
);
buf
[
length
]
=
0
;
buf
[
length
]
=
0
;
fprintf
(
fp
,
"
\'
%s
\'
"
,
buf
);
fprintf
(
fp
,
"
\'
%s
\'
"
,
buf
);
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
formatTimestamp
(
buf
,
*
(
int64_t
*
)
val
,
precision
);
formatTimestamp
(
buf
,
*
(
int64_t
*
)
val
,
precision
);
fprintf
(
fp
,
"'%s'"
,
buf
);
fprintf
(
fp
,
"'%s'"
,
buf
);
break
;
break
;
default:
default:
break
;
break
;
}
}
...
@@ -3348,29 +3482,50 @@ static int calcRowLen(SSuperTable* superTbls) {
...
@@ -3348,29 +3482,50 @@ static int calcRowLen(SSuperTable* superTbls) {
for
(
colIndex
=
0
;
colIndex
<
superTbls
->
columnCount
;
colIndex
++
)
{
for
(
colIndex
=
0
;
colIndex
<
superTbls
->
columnCount
;
colIndex
++
)
{
char
*
dataType
=
superTbls
->
columns
[
colIndex
].
dataType
;
char
*
dataType
=
superTbls
->
columns
[
colIndex
].
dataType
;
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
switch
(
superTbls
->
columns
[
colIndex
].
data_type
)
{
lenOfOneRow
+=
superTbls
->
columns
[
colIndex
].
dataLen
+
3
;
case
TSDB_DATA_TYPE_BINARY
:
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
lenOfOneRow
+=
superTbls
->
columns
[
colIndex
].
dataLen
+
3
;
lenOfOneRow
+=
superTbls
->
columns
[
colIndex
].
dataLen
+
3
;
break
;
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
lenOfOneRow
+=
INT_BUFF_LEN
;
case
TSDB_DATA_TYPE_NCHAR
:
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
lenOfOneRow
+=
superTbls
->
columns
[
colIndex
].
dataLen
+
3
;
lenOfOneRow
+=
BIGINT_BUFF_LEN
;
break
;
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
lenOfOneRow
+=
SMALLINT_BUFF_LEN
;
case
TSDB_DATA_TYPE_INT
:
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
lenOfOneRow
+=
INT_BUFF_LEN
;
lenOfOneRow
+=
TINYINT_BUFF_LEN
;
break
;
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
lenOfOneRow
+=
BOOL_BUFF_LEN
;
case
TSDB_DATA_TYPE_BIGINT
:
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
lenOfOneRow
+=
BIGINT_BUFF_LEN
;
lenOfOneRow
+=
FLOAT_BUFF_LEN
;
break
;
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
lenOfOneRow
+=
DOUBLE_BUFF_LEN
;
case
TSDB_DATA_TYPE_SMALLINT
:
}
else
if
(
strcasecmp
(
dataType
,
"TIMESTAMP"
)
==
0
)
{
lenOfOneRow
+=
SMALLINT_BUFF_LEN
;
lenOfOneRow
+=
TIMESTAMP_BUFF_LEN
;
break
;
}
else
{
errorPrint2
(
"get error data type : %s
\n
"
,
dataType
);
case
TSDB_DATA_TYPE_TINYINT
:
exit
(
EXIT_FAILURE
);
lenOfOneRow
+=
TINYINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
lenOfOneRow
+=
BOOL_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
lenOfOneRow
+=
FLOAT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
lenOfOneRow
+=
DOUBLE_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
lenOfOneRow
+=
TIMESTAMP_BUFF_LEN
;
break
;
default:
errorPrint2
(
"get error data type : %s
\n
"
,
dataType
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -3410,9 +3565,8 @@ static int calcRowLen(SSuperTable* superTbls) {
...
@@ -3410,9 +3565,8 @@ static int calcRowLen(SSuperTable* superTbls) {
return
0
;
return
0
;
}
}
static
int
getChildNameOfSuperTableWithLimitAndOffset
(
TAOS
*
taos
,
static
int
getChildNameOfSuperTableWithLimitAndOffset
(
TAOS
*
taos
,
char
*
dbName
,
char
*
s
Tbl
Name
,
char
**
childTblNameOfSuperTbl
,
char
*
dbName
,
char
*
s
tb
Name
,
char
**
childTblNameOfSuperTbl
,
int64_t
*
childTblCountOfSuperTbl
,
int64_t
limit
,
uint64_t
offset
)
{
int64_t
*
childTblCountOfSuperTbl
,
int64_t
limit
,
uint64_t
offset
)
{
char
command
[
1024
]
=
"
\0
"
;
char
command
[
1024
]
=
"
\0
"
;
...
@@ -3430,7 +3584,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3430,7 +3584,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
//get all child table name use cmd: select tbname from superTblName;
//get all child table name use cmd: select tbname from superTblName;
snprintf
(
command
,
1024
,
"select tbname from %s.%s %s"
,
snprintf
(
command
,
1024
,
"select tbname from %s.%s %s"
,
dbName
,
s
Tbl
Name
,
limitBuf
);
dbName
,
s
tb
Name
,
limitBuf
);
res
=
taos_query
(
taos
,
command
);
res
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
res
);
int32_t
code
=
taos_errno
(
res
);
...
@@ -3481,7 +3635,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3481,7 +3635,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
taos_free_result
(
res
);
taos_free_result
(
res
);
taos_close
(
taos
);
taos_close
(
taos
);
errorPrint2
(
"%s() LN%d, realloc fail for save child table name of %s.%s
\n
"
,
errorPrint2
(
"%s() LN%d, realloc fail for save child table name of %s.%s
\n
"
,
__func__
,
__LINE__
,
dbName
,
s
Tbl
Name
);
__func__
,
__LINE__
,
dbName
,
s
tb
Name
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -3496,10 +3650,10 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
...
@@ -3496,10 +3650,10 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
}
}
static
int
getAllChildNameOfSuperTable
(
TAOS
*
taos
,
char
*
dbName
,
static
int
getAllChildNameOfSuperTable
(
TAOS
*
taos
,
char
*
dbName
,
char
*
s
Tbl
Name
,
char
**
childTblNameOfSuperTbl
,
char
*
s
tb
Name
,
char
**
childTblNameOfSuperTbl
,
int64_t
*
childTblCountOfSuperTbl
)
{
int64_t
*
childTblCountOfSuperTbl
)
{
return
getChildNameOfSuperTableWithLimitAndOffset
(
taos
,
dbName
,
s
Tbl
Name
,
return
getChildNameOfSuperTableWithLimitAndOffset
(
taos
,
dbName
,
s
tb
Name
,
childTblNameOfSuperTbl
,
childTblCountOfSuperTbl
,
childTblNameOfSuperTbl
,
childTblCountOfSuperTbl
,
-
1
,
0
);
-
1
,
0
);
}
}
...
@@ -3513,7 +3667,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
...
@@ -3513,7 +3667,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
int
count
=
0
;
int
count
=
0
;
//get schema use cmd: describe superTblName;
//get schema use cmd: describe superTblName;
snprintf
(
command
,
1024
,
"describe %s.%s"
,
dbName
,
superTbls
->
s
Tbl
Name
);
snprintf
(
command
,
1024
,
"describe %s.%s"
,
dbName
,
superTbls
->
s
tb
Name
);
res
=
taos_query
(
taos
,
command
);
res
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
res
);
int32_t
code
=
taos_errno
(
res
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -3539,6 +3693,39 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
...
@@ -3539,6 +3693,39 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
min
(
DATATYPE_BUFF_LEN
,
min
(
DATATYPE_BUFF_LEN
,
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
)
+
1
);
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
)
+
1
);
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"INT"
,
strlen
(
"INT"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
tagIndex
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
superTbls
->
tags
[
tagIndex
].
data_type
=
TSDB_DATA_TYPE_NULL
;
}
superTbls
->
tags
[
tagIndex
].
dataLen
=
superTbls
->
tags
[
tagIndex
].
dataLen
=
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
tstrncpy
(
superTbls
->
tags
[
tagIndex
].
note
,
tstrncpy
(
superTbls
->
tags
[
tagIndex
].
note
,
...
@@ -3550,16 +3737,51 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
...
@@ -3550,16 +3737,51 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
field
,
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
field
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
fields
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
].
bytes
);
fields
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
].
bytes
);
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
dataType
,
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
dataType
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
],
min
(
DATATYPE_BUFF_LEN
,
min
(
DATATYPE_BUFF_LEN
,
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
)
+
1
);
fields
[
TSDB_DESCRIBE_METRIC_TYPE_INDEX
].
bytes
)
+
1
);
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"INT"
,
strlen
(
"INT"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
columnIndex
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
superTbls
->
columns
[
columnIndex
].
data_type
=
TSDB_DATA_TYPE_NULL
;
}
superTbls
->
columns
[
columnIndex
].
dataLen
=
superTbls
->
columns
[
columnIndex
].
dataLen
=
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
*
((
int
*
)
row
[
TSDB_DESCRIBE_METRIC_LENGTH_INDEX
]);
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
note
,
tstrncpy
(
superTbls
->
columns
[
columnIndex
].
note
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
],
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
],
min
(
NOTE_BUFF_LEN
,
min
(
NOTE_BUFF_LEN
,
fields
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
].
bytes
)
+
1
);
fields
[
TSDB_DESCRIBE_METRIC_NOTE_INDEX
].
bytes
)
+
1
);
columnIndex
++
;
columnIndex
++
;
}
}
count
++
;
count
++
;
...
@@ -3581,7 +3803,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
...
@@ -3581,7 +3803,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
return -1;
return -1;
}
}
getAllChildNameOfSuperTable(taos, dbName,
getAllChildNameOfSuperTable(taos, dbName,
superTbls->s
Tbl
Name,
superTbls->s
tb
Name,
&superTbls->childTblName,
&superTbls->childTblName,
&superTbls->childTblCount);
&superTbls->childTblCount);
}
}
...
@@ -3597,7 +3819,6 @@ static int createSuperTable(
...
@@ -3597,7 +3819,6 @@ static int createSuperTable(
assert
(
command
);
assert
(
command
);
char
cols
[
COL_BUFFER_LEN
]
=
"
\0
"
;
char
cols
[
COL_BUFFER_LEN
]
=
"
\0
"
;
int
colIndex
;
int
len
=
0
;
int
len
=
0
;
int
lenOfOneRow
=
0
;
int
lenOfOneRow
=
0
;
...
@@ -3609,81 +3830,101 @@ static int createSuperTable(
...
@@ -3609,81 +3830,101 @@ static int createSuperTable(
return
-
1
;
return
-
1
;
}
}
for
(
colIndex
=
0
;
colIndex
<
superTbl
->
columnCount
;
colIndex
++
)
{
for
(
int
colIndex
=
0
;
colIndex
<
superTbl
->
columnCount
;
colIndex
++
)
{
char
*
dataType
=
superTbl
->
columns
[
colIndex
].
dataType
;
if
(
strcasecmp
(
dataType
,
"BINARY"
)
==
0
)
{
switch
(
superTbl
->
columns
[
colIndex
].
data_type
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
case
TSDB_DATA_TYPE_BINARY
:
",C%d %s(%d)"
,
colIndex
,
"BINARY"
,
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
if
(
strcasecmp
(
dataType
,
"NCHAR"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s(%d)"
,
colIndex
,
"NCHAR"
,
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
if
(
strcasecmp
(
dataType
,
"INT"
)
==
0
)
{
if
((
g_args
.
demo_mode
)
&&
(
colIndex
==
1
))
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", VOLTAGE INT"
);
",C%d %s(%d)"
,
colIndex
,
"BINARY"
,
}
else
{
superTbl
->
columns
[
colIndex
].
dataLen
);
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"INT"
);
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
break
;
lenOfOneRow
+=
INT_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"BIGINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"BIGINT"
);
lenOfOneRow
+=
BIGINT_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"SMALLINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"SMALLINT"
);
lenOfOneRow
+=
SMALLINT_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"TINYINT"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"TINYINT"
);
lenOfOneRow
+=
TINYINT_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"BOOL"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"BOOL"
);
lenOfOneRow
+=
BOOL_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"FLOAT"
)
==
0
)
{
if
(
g_args
.
demo_mode
)
{
if
(
colIndex
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", CURRENT FLOAT"
);
}
else
if
(
colIndex
==
2
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", PHASE FLOAT"
);
}
}
else
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"FLOAT"
);
}
lenOfOneRow
+=
FLOAT_BUFF_LEN
;
case
TSDB_DATA_TYPE_NCHAR
:
}
else
if
(
strcasecmp
(
dataType
,
"DOUBLE"
)
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
",C%d %s(%d)"
,
colIndex
,
"NCHAR"
,
colIndex
,
"DOUBLE"
);
superTbl
->
columns
[
colIndex
].
dataLen
);
lenOfOneRow
+=
DOUBLE_BUFF_LEN
;
lenOfOneRow
+=
superTbl
->
columns
[
colIndex
].
dataLen
+
3
;
}
else
if
(
strcasecmp
(
dataType
,
"TIMESTAMP"
)
==
0
)
{
break
;
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"TIMESTAMP"
);
lenOfOneRow
+=
TIMESTAMP_BUFF_LEN
;
}
else
{
taos_close
(
taos
);
free
(
command
);
errorPrint2
(
"%s() LN%d, config error data type : %s
\n
"
,
__func__
,
__LINE__
,
dataType
);
exit
(
EXIT_FAILURE
);
}
}
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
case
TSDB_DATA_TYPE_INT
:
if
((
g_args
.
demo_mode
)
&&
(
colIndex
==
1
))
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", VOLTAGE INT"
);
}
else
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"INT"
);
}
lenOfOneRow
+=
INT_BUFF_LEN
;
break
;
// save for creating child table
case
TSDB_DATA_TYPE_BIGINT
:
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
20
,
1
);
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
colIndex
,
"BIGINT"
);
taos_close
(
taos
);
lenOfOneRow
+=
BIGINT_BUFF_LEN
;
free
(
command
);
break
;
errorPrint2
(
"%s() LN%d, Failed when calloc, size:%d"
,
__func__
,
__LINE__
,
len
+
1
);
case
TSDB_DATA_TYPE_SMALLINT
:
exit
(
EXIT_FAILURE
);
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
}
colIndex
,
"SMALLINT"
);
lenOfOneRow
+=
SMALLINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"TINYINT"
);
lenOfOneRow
+=
TINYINT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"BOOL"
);
lenOfOneRow
+=
BOOL_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
if
(
g_args
.
demo_mode
)
{
if
(
colIndex
==
0
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", CURRENT FLOAT"
);
}
else
if
(
colIndex
==
2
)
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
", PHASE FLOAT"
);
}
}
else
{
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"FLOAT"
);
}
lenOfOneRow
+=
FLOAT_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"DOUBLE"
);
lenOfOneRow
+=
DOUBLE_BUFF_LEN
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
len
+=
snprintf
(
cols
+
len
,
COL_BUFFER_LEN
-
len
,
",C%d %s"
,
colIndex
,
"TIMESTAMP"
);
lenOfOneRow
+=
TIMESTAMP_BUFF_LEN
;
break
;
default:
taos_close
(
taos
);
free
(
command
);
errorPrint2
(
"%s() LN%d, config error data type : %s
\n
"
,
__func__
,
__LINE__
,
superTbl
->
columns
[
colIndex
].
dataType
);
exit
(
EXIT_FAILURE
);
}
}
superTbl
->
lenOfOneRow
=
lenOfOneRow
+
20
;
// timestamp
// save for creating child table
superTbl
->
colsOfCreateChildTable
=
(
char
*
)
calloc
(
len
+
20
,
1
);
if
(
NULL
==
superTbl
->
colsOfCreateChildTable
)
{
taos_close
(
taos
);
free
(
command
);
errorPrint2
(
"%s() LN%d, Failed when calloc, size:%d"
,
__func__
,
__LINE__
,
len
+
1
);
exit
(
EXIT_FAILURE
);
}
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
snprintf
(
superTbl
->
colsOfCreateChildTable
,
len
+
20
,
"(ts timestamp%s)"
,
cols
);
verbosePrint
(
"%s() LN%d: %s
\n
"
,
verbosePrint
(
"%s() LN%d: %s
\n
"
,
...
@@ -3769,16 +4010,16 @@ static int createSuperTable(
...
@@ -3769,16 +4010,16 @@ static int createSuperTable(
superTbl
->
lenOfTagOfOneRow
=
lenOfTagOfOneRow
;
superTbl
->
lenOfTagOfOneRow
=
lenOfTagOfOneRow
;
snprintf
(
command
,
BUFFER_SIZE
,
snprintf
(
command
,
BUFFER_SIZE
,
"
create table if not exists %s.%s (ts timestamp%s) tags
%s"
,
"
CREATE TABLE IF NOT EXISTS %s.%s (ts TIMESTAMP%s) TAGS
%s"
,
dbName
,
superTbl
->
s
Tbl
Name
,
cols
,
tags
);
dbName
,
superTbl
->
s
tb
Name
,
cols
,
tags
);
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
errorPrint2
(
"create supertable %s failed!
\n\n
"
,
errorPrint2
(
"create supertable %s failed!
\n\n
"
,
superTbl
->
s
Tbl
Name
);
superTbl
->
s
tb
Name
);
free
(
command
);
free
(
command
);
return
-
1
;
return
-
1
;
}
}
debugPrint
(
"create supertable %s success!
\n\n
"
,
superTbl
->
s
Tbl
Name
);
debugPrint
(
"create supertable %s success!
\n\n
"
,
superTbl
->
s
tb
Name
);
free
(
command
);
free
(
command
);
return
0
;
return
0
;
}
}
...
@@ -3802,42 +4043,42 @@ int createDatabasesAndStables(char *command) {
...
@@ -3802,42 +4043,42 @@ int createDatabasesAndStables(char *command) {
int
dataLen
=
0
;
int
dataLen
=
0
;
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
create database if not exists
%s"
,
BUFFER_SIZE
-
dataLen
,
"
CREATE DATABASE IF NOT EXISTS
%s"
,
g_Dbs
.
db
[
i
].
dbName
);
g_Dbs
.
db
[
i
].
dbName
);
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
blocks
%d"
,
BUFFER_SIZE
-
dataLen
,
"
BLOCKS
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cache
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
cache
%d"
,
BUFFER_SIZE
-
dataLen
,
"
CACHE
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
days
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
days
%d"
,
BUFFER_SIZE
-
dataLen
,
"
DAYS
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
keep
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
keep
%d"
,
BUFFER_SIZE
-
dataLen
,
"
KEEP
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
1
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
>
1
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
quorum
%d"
,
BUFFER_SIZE
-
dataLen
,
"
QUORUM
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
replica
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
replica
%d"
,
BUFFER_SIZE
-
dataLen
,
"
REPLICA
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
update
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
update
%d"
,
BUFFER_SIZE
-
dataLen
,
"
UPDATE
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
}
//if (g_Dbs.db[i].dbCfg.maxtablesPerVnode > 0) {
//if (g_Dbs.db[i].dbCfg.maxtablesPerVnode > 0) {
...
@@ -3846,17 +4087,17 @@ int createDatabasesAndStables(char *command) {
...
@@ -3846,17 +4087,17 @@ int createDatabasesAndStables(char *command) {
//}
//}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
minrows
%d"
,
BUFFER_SIZE
-
dataLen
,
"
MINROWS
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
maxrows
%d"
,
BUFFER_SIZE
-
dataLen
,
"
MAXROWS
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
comp
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
comp
%d"
,
BUFFER_SIZE
-
dataLen
,
"
COMP
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
...
@@ -3866,12 +4107,12 @@ int createDatabasesAndStables(char *command) {
...
@@ -3866,12 +4107,12 @@ int createDatabasesAndStables(char *command) {
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cacheLast
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
cacheLast
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
cachelast
%d"
,
BUFFER_SIZE
-
dataLen
,
"
CACHELAST
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cacheLast
);
g_Dbs
.
db
[
i
].
dbCfg
.
cacheLast
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
"
fsync
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
"
FSYNC
%d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
fsync
);
}
}
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
...
@@ -3898,7 +4139,7 @@ int createDatabasesAndStables(char *command) {
...
@@ -3898,7 +4139,7 @@ int createDatabasesAndStables(char *command) {
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
sprintf
(
command
,
"describe %s.%s;"
,
g_Dbs
.
db
[
i
].
dbName
,
sprintf
(
command
,
"describe %s.%s;"
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
Tbl
Name
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
tb
Name
);
ret
=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
true
);
ret
=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
true
);
if
((
ret
!=
0
)
||
(
g_Dbs
.
db
[
i
].
drop
))
{
if
((
ret
!=
0
)
||
(
g_Dbs
.
db
[
i
].
drop
))
{
...
@@ -3915,7 +4156,7 @@ int createDatabasesAndStables(char *command) {
...
@@ -3915,7 +4156,7 @@ int createDatabasesAndStables(char *command) {
&
g_Dbs
.
db
[
i
].
superTbls
[
j
]);
&
g_Dbs
.
db
[
i
].
superTbls
[
j
]);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
errorPrint2
(
"
\n
get super table %s.%s info failed!
\n\n
"
,
errorPrint2
(
"
\n
get super table %s.%s info failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
Tbl
Name
);
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
tb
Name
);
continue
;
continue
;
}
}
...
@@ -3957,7 +4198,7 @@ static void* createTable(void *sarg)
...
@@ -3957,7 +4198,7 @@ static void* createTable(void *sarg)
i
<=
pThreadInfo
->
end_table_to
;
i
++
)
{
i
<=
pThreadInfo
->
end_table_to
;
i
++
)
{
if
(
0
==
g_Dbs
.
use_metric
)
{
if
(
0
==
g_Dbs
.
use_metric
)
{
snprintf
(
pThreadInfo
->
buffer
,
buff_len
,
snprintf
(
pThreadInfo
->
buffer
,
buff_len
,
"
create table if not exists
%s.%s%"
PRIu64
" %s;"
,
"
CREATE TABLE IF NOT EXISTS
%s.%s%"
PRIu64
" %s;"
,
pThreadInfo
->
db_name
,
pThreadInfo
->
db_name
,
g_args
.
tb_prefix
,
i
,
g_args
.
tb_prefix
,
i
,
pThreadInfo
->
cols
);
pThreadInfo
->
cols
);
...
@@ -3973,7 +4214,7 @@ static void* createTable(void *sarg)
...
@@ -3973,7 +4214,7 @@ static void* createTable(void *sarg)
batchNum
=
0
;
batchNum
=
0
;
memset
(
pThreadInfo
->
buffer
,
0
,
buff_len
);
memset
(
pThreadInfo
->
buffer
,
0
,
buff_len
);
len
+=
snprintf
(
pThreadInfo
->
buffer
+
len
,
len
+=
snprintf
(
pThreadInfo
->
buffer
+
len
,
buff_len
-
len
,
"
create table
"
);
buff_len
-
len
,
"
CREATE TABLE
"
);
}
}
char
*
tagsValBuf
=
NULL
;
char
*
tagsValBuf
=
NULL
;
...
@@ -3998,7 +4239,7 @@ static void* createTable(void *sarg)
...
@@ -3998,7 +4239,7 @@ static void* createTable(void *sarg)
"if not exists %s.%s%"
PRIu64
" using %s.%s tags %s "
,
"if not exists %s.%s%"
PRIu64
" using %s.%s tags %s "
,
pThreadInfo
->
db_name
,
stbInfo
->
childTblPrefix
,
pThreadInfo
->
db_name
,
stbInfo
->
childTblPrefix
,
i
,
pThreadInfo
->
db_name
,
i
,
pThreadInfo
->
db_name
,
stbInfo
->
s
Tbl
Name
,
tagsValBuf
);
stbInfo
->
s
tb
Name
,
tagsValBuf
);
free
(
tagsValBuf
);
free
(
tagsValBuf
);
batchNum
++
;
batchNum
++
;
if
((
batchNum
<
stbInfo
->
batchCreateTableNum
)
if
((
batchNum
<
stbInfo
->
batchCreateTableNum
)
...
@@ -4010,6 +4251,7 @@ static void* createTable(void *sarg)
...
@@ -4010,6 +4251,7 @@ static void* createTable(void *sarg)
}
}
len
=
0
;
len
=
0
;
if
(
0
!=
queryDbExec
(
pThreadInfo
->
taos
,
pThreadInfo
->
buffer
,
if
(
0
!=
queryDbExec
(
pThreadInfo
->
taos
,
pThreadInfo
->
buffer
,
NO_INSERT_TYPE
,
false
))
{
NO_INSERT_TYPE
,
false
))
{
errorPrint2
(
"queryDbExec() failed. buffer:
\n
%s
\n
"
,
pThreadInfo
->
buffer
);
errorPrint2
(
"queryDbExec() failed. buffer:
\n
%s
\n
"
,
pThreadInfo
->
buffer
);
...
@@ -4142,15 +4384,15 @@ static void createChildTables() {
...
@@ -4142,15 +4384,15 @@ static void createChildTables() {
}
else
{
}
else
{
// normal table
// normal table
len
=
snprintf
(
tblColsBuf
,
TSDB_MAX_BYTES_PER_ROW
,
"(TS TIMESTAMP"
);
len
=
snprintf
(
tblColsBuf
,
TSDB_MAX_BYTES_PER_ROW
,
"(TS TIMESTAMP"
);
for
(
int
j
=
0
;
j
<
g_args
.
num_of_CPR
;
j
++
)
{
for
(
int
j
=
0
;
j
<
g_args
.
columnCount
;
j
++
)
{
if
((
strncasecmp
(
g_args
.
data
t
ype
[
j
],
"BINARY"
,
strlen
(
"BINARY"
))
==
0
)
if
((
strncasecmp
(
g_args
.
data
T
ype
[
j
],
"BINARY"
,
strlen
(
"BINARY"
))
==
0
)
||
(
strncasecmp
(
g_args
.
data
t
ype
[
j
],
||
(
strncasecmp
(
g_args
.
data
T
ype
[
j
],
"NCHAR"
,
strlen
(
"NCHAR"
))
==
0
))
{
"NCHAR"
,
strlen
(
"NCHAR"
))
==
0
))
{
snprintf
(
tblColsBuf
+
len
,
TSDB_MAX_BYTES_PER_ROW
-
len
,
snprintf
(
tblColsBuf
+
len
,
TSDB_MAX_BYTES_PER_ROW
-
len
,
",C%d %s(%d)"
,
j
,
g_args
.
data
t
ype
[
j
],
g_args
.
binwidth
);
",C%d %s(%d)"
,
j
,
g_args
.
data
T
ype
[
j
],
g_args
.
binwidth
);
}
else
{
}
else
{
snprintf
(
tblColsBuf
+
len
,
TSDB_MAX_BYTES_PER_ROW
-
len
,
snprintf
(
tblColsBuf
+
len
,
TSDB_MAX_BYTES_PER_ROW
-
len
,
",C%d %s"
,
j
,
g_args
.
data
t
ype
[
j
]);
",C%d %s"
,
j
,
g_args
.
data
T
ype
[
j
]);
}
}
len
=
strlen
(
tblColsBuf
);
len
=
strlen
(
tblColsBuf
);
}
}
...
@@ -4159,12 +4401,12 @@ static void createChildTables() {
...
@@ -4159,12 +4401,12 @@ static void createChildTables() {
verbosePrint
(
"%s() LN%d: dbName: %s num of tb: %"
PRId64
" schema: %s
\n
"
,
verbosePrint
(
"%s() LN%d: dbName: %s num of tb: %"
PRId64
" schema: %s
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
g_Dbs
.
db
[
i
].
dbName
,
g_args
.
n
um_of_
tables
,
tblColsBuf
);
g_Dbs
.
db
[
i
].
dbName
,
g_args
.
ntables
,
tblColsBuf
);
startMultiThreadCreateChildTable
(
startMultiThreadCreateChildTable
(
tblColsBuf
,
tblColsBuf
,
g_Dbs
.
threadCountForCreateTbl
,
g_Dbs
.
threadCountForCreateTbl
,
0
,
0
,
g_args
.
n
um_of_
tables
,
g_args
.
ntables
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
dbName
,
NULL
);
NULL
);
}
}
...
@@ -4242,7 +4484,7 @@ static int readTagFromCsvFileToMem(SSuperTable * stbInfo) {
...
@@ -4242,7 +4484,7 @@ static int readTagFromCsvFileToMem(SSuperTable * stbInfo) {
/*
/*
Read 10000 lines at most. If more than 10000 lines, continue to read after using
Read 10000 lines at most. If more than 10000 lines, continue to read after using
*/
*/
static
int
readSampleFromCsvFileToMem
(
static
int
generateSampleFromCsvForStb
(
SSuperTable
*
stbInfo
)
{
SSuperTable
*
stbInfo
)
{
size_t
n
=
0
;
size_t
n
=
0
;
ssize_t
readLen
=
0
;
ssize_t
readLen
=
0
;
...
@@ -4368,6 +4610,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
...
@@ -4368,6 +4610,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
tstrncpy
(
superTbls
->
columns
[
index
].
dataType
,
tstrncpy
(
superTbls
->
columns
[
index
].
dataType
,
columnCase
.
dataType
,
columnCase
.
dataType
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
columnCase
.
dataType
)
+
1
));
min
(
DATATYPE_BUFF_LEN
,
strlen
(
columnCase
.
dataType
)
+
1
));
superTbls
->
columns
[
index
].
dataLen
=
columnCase
.
dataLen
;
superTbls
->
columns
[
index
].
dataLen
=
columnCase
.
dataLen
;
index
++
;
index
++
;
}
}
...
@@ -4381,6 +4624,42 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
...
@@ -4381,6 +4624,42 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
superTbls
->
columnCount
=
index
;
superTbls
->
columnCount
=
index
;
for
(
int
c
=
0
;
c
<
superTbls
->
columnCount
;
c
++
)
{
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"INT"
,
strlen
(
"INT"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
columns
[
c
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
superTbls
->
columns
[
c
].
data_type
=
TSDB_DATA_TYPE_NULL
;
}
}
count
=
1
;
count
=
1
;
index
=
0
;
index
=
0
;
// tags
// tags
...
@@ -4450,6 +4729,42 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
...
@@ -4450,6 +4729,42 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
superTbls
->
tagCount
=
index
;
superTbls
->
tagCount
=
index
;
for
(
int
t
=
0
;
t
<
superTbls
->
tagCount
;
t
++
)
{
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"INT"
,
strlen
(
"INT"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_INT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_SMALLINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_BOOL
;
}
else
if
(
0
==
strncasecmp
(
superTbls
->
tags
[
t
].
dataType
,
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
}
else
{
superTbls
->
tags
[
t
].
data_type
=
TSDB_DATA_TYPE_NULL
;
}
}
if
((
superTbls
->
columnCount
+
superTbls
->
tagCount
+
1
/* ts */
)
>
TSDB_MAX_COLUMNS
)
{
if
((
superTbls
->
columnCount
+
superTbls
->
tagCount
+
1
/* ts */
)
>
TSDB_MAX_COLUMNS
)
{
errorPrint
(
"columns + tags is more than allowed max columns count: %d
\n
"
,
errorPrint
(
"columns + tags is more than allowed max columns count: %d
\n
"
,
TSDB_MAX_COLUMNS
);
TSDB_MAX_COLUMNS
);
...
@@ -4586,9 +4901,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -4586,9 +4901,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
prompt
();
prompt
();
numRecPerReq
->
valueint
=
MAX_RECORDS_PER_REQ
;
numRecPerReq
->
valueint
=
MAX_RECORDS_PER_REQ
;
}
}
g_args
.
num_of_RPR
=
numRecPerReq
->
valueint
;
g_args
.
reqPerReq
=
numRecPerReq
->
valueint
;
}
else
if
(
!
numRecPerReq
)
{
}
else
if
(
!
numRecPerReq
)
{
g_args
.
num_of_RPR
=
MAX_RECORDS_PER_REQ
;
g_args
.
reqPerReq
=
MAX_RECORDS_PER_REQ
;
}
else
{
}
else
{
errorPrint
(
"%s() LN%d, failed to read json, num_of_records_per_req not found
\n
"
,
errorPrint
(
"%s() LN%d, failed to read json, num_of_records_per_req not found
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
...
@@ -4614,13 +4929,13 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -4614,13 +4929,13 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
}
}
// rows per table need be less than insert batch
// rows per table need be less than insert batch
if
(
g_args
.
interlace_rows
>
g_args
.
num_of_RPR
)
{
if
(
g_args
.
interlace_rows
>
g_args
.
reqPerReq
)
{
printf
(
"NOTICE: interlace rows value %u > num_of_records_per_req %u
\n\n
"
,
printf
(
"NOTICE: interlace rows value %u > num_of_records_per_req %u
\n\n
"
,
g_args
.
interlace_rows
,
g_args
.
num_of_RPR
);
g_args
.
interlace_rows
,
g_args
.
reqPerReq
);
printf
(
" interlace rows value will be set to num_of_records_per_req %u
\n\n
"
,
printf
(
" interlace rows value will be set to num_of_records_per_req %u
\n\n
"
,
g_args
.
num_of_RPR
);
g_args
.
reqPerReq
);
prompt
();
prompt
();
g_args
.
interlace_rows
=
g_args
.
num_of_RPR
;
g_args
.
interlace_rows
=
g_args
.
reqPerReq
;
}
}
cJSON
*
dbs
=
cJSON_GetObjectItem
(
root
,
"databases"
);
cJSON
*
dbs
=
cJSON_GetObjectItem
(
root
,
"databases"
);
...
@@ -4849,7 +5164,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -4849,7 +5164,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
errorPrint
(
"%s"
,
"failed to read json, stb name not found
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, stb name not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
}
}
tstrncpy
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
Tbl
Name
,
stbName
->
valuestring
,
tstrncpy
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
s
tb
Name
,
stbName
->
valuestring
,
TSDB_TABLE_NAME_LEN
);
TSDB_TABLE_NAME_LEN
);
cJSON
*
prefix
=
cJSON_GetObjectItem
(
stbInfo
,
"childtable_prefix"
);
cJSON
*
prefix
=
cJSON_GetObjectItem
(
stbInfo
,
"childtable_prefix"
);
...
@@ -5503,7 +5818,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -5503,7 +5818,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
cJSON
*
stblname
=
cJSON_GetObjectItem
(
superQuery
,
"stblname"
);
cJSON
*
stblname
=
cJSON_GetObjectItem
(
superQuery
,
"stblname"
);
if
(
stblname
&&
stblname
->
type
==
cJSON_String
if
(
stblname
&&
stblname
->
type
==
cJSON_String
&&
stblname
->
valuestring
!=
NULL
)
{
&&
stblname
->
valuestring
!=
NULL
)
{
tstrncpy
(
g_queryInfo
.
superQueryInfo
.
s
Tbl
Name
,
stblname
->
valuestring
,
tstrncpy
(
g_queryInfo
.
superQueryInfo
.
s
tb
Name
,
stblname
->
valuestring
,
TSDB_TABLE_NAME_LEN
);
TSDB_TABLE_NAME_LEN
);
}
else
{
}
else
{
errorPrint
(
"%s"
,
"failed to read json, super table name input error
\n
"
);
errorPrint
(
"%s"
,
"failed to read json, super table name input error
\n
"
);
...
@@ -5725,23 +6040,37 @@ static int prepareSampleData() {
...
@@ -5725,23 +6040,37 @@ static int prepareSampleData() {
static
void
postFreeResource
()
{
static
void
postFreeResource
()
{
tmfclose
(
g_fpOfInsertResult
);
tmfclose
(
g_fpOfInsertResult
);
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
)
{
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
tm
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreateChildTable
=
NULL
;
}
}
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
)
{
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
);
tm
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
=
NULL
;
}
}
#if STMT_BIND_PARAM_BATCH == 1
for
(
int
c
=
0
;
c
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
c
++
)
{
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindBatchArray
)
{
tmfree
((
char
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)));
}
}
tmfree
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindBatchArray
);
#endif
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
)
{
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
);
tm
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
=
NULL
;
}
}
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
)
{
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
);
tm
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
=
NULL
;
}
}
}
}
...
@@ -5757,6 +6086,19 @@ static void postFreeResource() {
...
@@ -5757,6 +6086,19 @@ static void postFreeResource() {
tmfree
(
g_rand_current_buff
);
tmfree
(
g_rand_current_buff
);
tmfree
(
g_rand_phase_buff
);
tmfree
(
g_rand_phase_buff
);
tmfree
(
g_sampleDataBuf
);
#if STMT_BIND_PARAM_BATCH == 1
for
(
int
l
=
0
;
l
<
g_args
.
columnCount
;
l
++
)
{
if
(
g_sampleBindBatchArray
)
{
tmfree
((
char
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
l
)));
}
}
tmfree
(
g_sampleBindBatchArray
);
#endif
}
}
static
int
getRowDataFromSample
(
static
int
getRowDataFromSample
(
...
@@ -5794,13 +6136,14 @@ static int64_t generateStbRowData(
...
@@ -5794,13 +6136,14 @@ static int64_t generateStbRowData(
int
tmpLen
;
int
tmpLen
;
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"(%"
PRId64
"
,
"
,
timestamp
);
"(%"
PRId64
""
,
timestamp
);
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
;
i
++
)
{
if
((
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
tstrncpy
(
pstr
+
dataLen
,
","
,
2
);
"BINARY"
,
6
))
dataLen
+=
1
;
||
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"NCHAR"
,
5
)))
{
if
((
stbInfo
->
columns
[
i
].
data_type
==
TSDB_DATA_TYPE_BINARY
)
||
(
stbInfo
->
columns
[
i
].
data_type
==
TSDB_DATA_TYPE_NCHAR
))
{
if
(
stbInfo
->
columns
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
if
(
stbInfo
->
columns
[
i
].
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"binary or nchar length overflow, max size:%u
\n
"
,
errorPrint2
(
"binary or nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
...
@@ -5818,80 +6161,91 @@ static int64_t generateStbRowData(
...
@@ -5818,80 +6161,91 @@ static int64_t generateStbRowData(
return
-
1
;
return
-
1
;
}
}
rand_string
(
buf
,
stbInfo
->
columns
[
i
].
dataLen
);
rand_string
(
buf
,
stbInfo
->
columns
[
i
].
dataLen
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"
\'
%s
\'
,
"
,
buf
);
dataLen
+=
snprintf
(
pstr
+
dataLen
,
maxLen
-
dataLen
,
"
\'
%s
\'
"
,
buf
);
tmfree
(
buf
);
tmfree
(
buf
);
}
else
{
}
else
{
char
*
tmp
;
char
*
tmp
=
NULL
;
switch
(
stbInfo
->
columns
[
i
].
data_type
)
{
case
TSDB_DATA_TYPE_INT
:
if
((
g_args
.
demo_mode
)
&&
(
i
==
1
))
{
tmp
=
demo_voltage_int_str
();
}
else
{
tmp
=
rand_int_str
();
}
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
INT_BUFF_LEN
));
break
;
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
case
TSDB_DATA_TYPE_BIGINT
:
"INT"
,
3
))
{
tmp
=
rand_bigint_str
();
if
((
g_args
.
demo_mode
)
&&
(
i
==
1
))
{
tstrncpy
(
pstr
+
dataLen
,
tmp
,
BIGINT_BUFF_LEN
);
tmp
=
demo_voltage_int_str
();
break
;
}
else
{
tmp
=
rand_int_str
();
case
TSDB_DATA_TYPE_FLOAT
:
}
if
(
g_args
.
demo_mode
)
{
tmpLen
=
strlen
(
tmp
);
if
(
i
==
0
)
{
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
INT_BUFF_LEN
));
tmp
=
demo_current_float_str
();
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
}
else
{
"BIGINT"
,
6
))
{
tmp
=
demo_phase_float_str
();
tmp
=
rand_bigint_str
();
}
tstrncpy
(
pstr
+
dataLen
,
tmp
,
BIGINT_BUFF_LEN
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"FLOAT"
,
5
))
{
if
(
g_args
.
demo_mode
)
{
if
(
i
==
0
)
{
tmp
=
demo_current_float_str
();
}
else
{
}
else
{
tmp
=
demo_phase
_float_str
();
tmp
=
rand
_float_str
();
}
}
}
else
{
tmpLen
=
strlen
(
tmp
);
tmp
=
rand_float_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
FLOAT_BUFF_LEN
));
}
break
;
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
FLOAT_BUFF_LEN
));
case
TSDB_DATA_TYPE_DOUBLE
:
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
tmp
=
rand_double_str
();
"DOUBLE"
,
6
))
{
tmpLen
=
strlen
(
tmp
);
tmp
=
rand_double_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
DOUBLE_BUFF_LEN
));
tmpLen
=
strlen
(
tmp
);
break
;
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
DOUBLE_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
case
TSDB_DATA_TYPE_SMALLINT
:
"SMALLINT"
,
8
))
{
tmp
=
rand_smallint_str
();
tmp
=
rand_smallint_str
();
tmpLen
=
strlen
(
tmp
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
SMALLINT_BUFF_LEN
));
min
(
tmpLen
+
1
,
SMALLINT_BUFF_LEN
));
break
;
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
"TINYINT"
,
7
))
{
case
TSDB_DATA_TYPE_TINYINT
:
tmp
=
rand_tinyint_str
();
tmp
=
rand_tinyint_str
();
tmpLen
=
strlen
(
tmp
);
tmpLen
=
strlen
(
tmp
);
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
TINYINT_BUFF_LEN
));
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
TINYINT_BUFF_LEN
));
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
break
;
"BOOL"
,
4
))
{
tmp
=
rand_bool_str
();
case
TSDB_DATA_TYPE_BOOL
:
tmpLen
=
strlen
(
tmp
);
tmp
=
rand_bool_str
();
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
BOOL_BUFF_LEN
));
tmpLen
=
strlen
(
tmp
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
i
].
dataType
,
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
BOOL_BUFF_LEN
));
"TIMESTAMP"
,
9
))
{
break
;
tmp
=
rand_bigint_str
();
tmpLen
=
strlen
(
tmp
);
case
TSDB_DATA_TYPE_TIMESTAMP
:
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
BIGINT_BUFF_LEN
));
tmp
=
rand_bigint_str
();
}
else
{
tmpLen
=
strlen
(
tmp
);
errorPrint2
(
"Not support data type: %s
\n
"
,
tstrncpy
(
pstr
+
dataLen
,
tmp
,
min
(
tmpLen
+
1
,
BIGINT_BUFF_LEN
));
stbInfo
->
columns
[
i
].
dataType
);
break
;
return
-
1
;
case
TSDB_DATA_TYPE_NULL
:
break
;
default:
errorPrint2
(
"Not support data type: %s
\n
"
,
stbInfo
->
columns
[
i
].
dataType
);
exit
(
EXIT_FAILURE
);
}
}
dataLen
+=
strlen
(
tmp
);
if
(
tmp
)
{
tstrncpy
(
pstr
+
dataLen
,
","
,
2
);
dataLen
+=
strlen
(
tmp
);
dataLen
+=
1
;
}
}
}
if
(
dataLen
>
(
remainderBufLen
-
(
128
)))
if
(
dataLen
>
(
remainderBufLen
-
(
128
)))
return
0
;
return
0
;
}
}
tstrncpy
(
pstr
+
dataLen
-
1
,
")"
,
2
);
tstrncpy
(
pstr
+
dataLen
,
")"
,
2
);
verbosePrint
(
"%s() LN%d, dataLen:%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
dataLen
);
verbosePrint
(
"%s() LN%d, dataLen:%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
dataLen
);
verbosePrint
(
"%s() LN%d, recBuf:
\n\t
%s
\n
"
,
__func__
,
__LINE__
,
recBuf
);
verbosePrint
(
"%s() LN%d, recBuf:
\n\t
%s
\n
"
,
__func__
,
__LINE__
,
recBuf
);
...
@@ -5899,53 +6253,83 @@ static int64_t generateStbRowData(
...
@@ -5899,53 +6253,83 @@ static int64_t generateStbRowData(
return
strlen
(
recBuf
);
return
strlen
(
recBuf
);
}
}
static
int64_t
generateData
(
char
*
recBuf
,
char
*
*
data_type
,
static
int64_t
generateData
(
char
*
recBuf
,
char
*
data_type
,
int64_t
timestamp
,
int
lenOfBinary
)
{
int64_t
timestamp
,
int
lenOfBinary
)
{
memset
(
recBuf
,
0
,
MAX_DATA_SIZE
);
memset
(
recBuf
,
0
,
MAX_DATA_SIZE
);
char
*
pstr
=
recBuf
;
char
*
pstr
=
recBuf
;
pstr
+=
sprintf
(
pstr
,
"(%"
PRId64
,
timestamp
);
pstr
+=
sprintf
(
pstr
,
"(%"
PRId64
""
,
timestamp
);
int
columnCount
=
g_args
.
num_of_CPR
;
int
columnCount
=
g_args
.
columnCount
;
bool
b
;
char
*
s
;
for
(
int
i
=
0
;
i
<
columnCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++
)
{
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"TINYINT"
)
==
0
)
{
switch
(
data_type
[
i
])
{
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_tinyint
()
);
case
TSDB_DATA_TYPE_TINYINT
:
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"SMALLINT"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_tinyint
()
);
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_smallint
());
break
;
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"INT"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_int
());
case
TSDB_DATA_TYPE_SMALLINT
:
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"BIGINT"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_smallint
());
pstr
+=
sprintf
(
pstr
,
",%"
PRId64
,
rand_bigint
());
break
;
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"TIMESTAMP"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%"
PRId64
,
rand_bigint
());
case
TSDB_DATA_TYPE_INT
:
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"FLOAT"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%d"
,
rand_int
());
pstr
+=
sprintf
(
pstr
,
",%10.4f"
,
rand_float
());
break
;
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"DOUBLE"
)
==
0
)
{
double
t
=
rand_double
();
case
TSDB_DATA_TYPE_BIGINT
:
pstr
+=
sprintf
(
pstr
,
",%20.8f"
,
t
);
pstr
+=
sprintf
(
pstr
,
",%"
PRId64
""
,
rand_bigint
());
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"BOOL"
)
==
0
)
{
break
;
bool
b
=
rand_bool
()
&
1
;
pstr
+=
sprintf
(
pstr
,
",%s"
,
b
?
"true"
:
"false"
);
case
TSDB_DATA_TYPE_TIMESTAMP
:
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"BINARY"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
",%"
PRId64
""
,
rand_bigint
());
char
*
s
=
malloc
(
lenOfBinary
+
1
);
break
;
if
(
s
==
NULL
)
{
errorPrint2
(
"%s() LN%d, memory allocation %d bytes failed
\n
"
,
case
TSDB_DATA_TYPE_FLOAT
:
__func__
,
__LINE__
,
lenOfBinary
+
1
);
pstr
+=
sprintf
(
pstr
,
",%10.4f"
,
rand_float
());
exit
(
EXIT_FAILURE
);
break
;
}
rand_string
(
s
,
lenOfBinary
);
case
TSDB_DATA_TYPE_DOUBLE
:
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
pstr
+=
sprintf
(
pstr
,
",%20.8f"
,
rand_double
());
free
(
s
);
break
;
}
else
if
(
strcasecmp
(
data_type
[
i
%
columnCount
],
"NCHAR"
)
==
0
)
{
char
*
s
=
malloc
(
lenOfBinary
+
1
);
case
TSDB_DATA_TYPE_BOOL
:
if
(
s
==
NULL
)
{
b
=
rand_bool
()
&
1
;
errorPrint2
(
"%s() LN%d, memory allocation %d bytes failed
\n
"
,
pstr
+=
sprintf
(
pstr
,
",%s"
,
b
?
"true"
:
"false"
);
__func__
,
__LINE__
,
lenOfBinary
+
1
);
break
;
case
TSDB_DATA_TYPE_BINARY
:
s
=
malloc
(
lenOfBinary
+
1
);
if
(
s
==
NULL
)
{
errorPrint2
(
"%s() LN%d, memory allocation %d bytes failed
\n
"
,
__func__
,
__LINE__
,
lenOfBinary
+
1
);
exit
(
EXIT_FAILURE
);
}
rand_string
(
s
,
lenOfBinary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
free
(
s
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
s
=
malloc
(
lenOfBinary
+
1
);
if
(
s
==
NULL
)
{
errorPrint2
(
"%s() LN%d, memory allocation %d bytes failed
\n
"
,
__func__
,
__LINE__
,
lenOfBinary
+
1
);
exit
(
EXIT_FAILURE
);
}
rand_string
(
s
,
lenOfBinary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
free
(
s
);
break
;
case
TSDB_DATA_TYPE_NULL
:
break
;
default:
errorPrint2
(
"%s() LN%d, Unknown data type %d
\n
"
,
__func__
,
__LINE__
,
data_type
[
i
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
rand_string
(
s
,
lenOfBinary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
free
(
s
);
}
}
if
(
strlen
(
recBuf
)
>
MAX_DATA_SIZE
)
{
if
(
strlen
(
recBuf
)
>
MAX_DATA_SIZE
)
{
...
@@ -5960,81 +6344,143 @@ static int64_t generateData(char *recBuf, char **data_type,
...
@@ -5960,81 +6344,143 @@ static int64_t generateData(char *recBuf, char **data_type,
return
(
int32_t
)
strlen
(
recBuf
);
return
(
int32_t
)
strlen
(
recBuf
);
}
}
static
int
generateSampleMemoryFromRand
(
SSuperTable
*
stbInfo
)
static
int
generateSampleFromRand
(
char
*
sampleDataBuf
,
uint64_t
lenOfOneRow
,
int
columnCount
,
StrColumn
*
columns
)
{
{
char
data
[
MAX_DATA_SIZE
];
char
data
[
MAX_DATA_SIZE
];
memset
(
data
,
0
,
MAX_DATA_SIZE
);
memset
(
data
,
0
,
MAX_DATA_SIZE
);
char
*
buff
=
malloc
(
stbInfo
->
lenOfOneRow
);
char
*
buff
=
malloc
(
lenOfOneRow
);
if
(
NULL
==
buff
)
{
if
(
NULL
==
buff
)
{
errorPrint2
(
"%s() LN%d, memory allocation %"
PRI
d
64
" bytes failed
\n
"
,
errorPrint2
(
"%s() LN%d, memory allocation %"
PRI
u
64
" bytes failed
\n
"
,
__func__
,
__LINE__
,
stbInfo
->
lenOfOneRow
);
__func__
,
__LINE__
,
lenOfOneRow
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
for
(
int
i
=
0
;
i
<
MAX_SAMPLES_ONCE_FROM_FILE
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SAMPLES_ONCE_FROM_FILE
;
i
++
)
{
uint64_t
pos
=
0
;
uint64_t
pos
=
0
;
memset
(
buff
,
0
,
stbInfo
->
lenOfOneRow
);
memset
(
buff
,
0
,
lenOfOneRow
);
for
(
int
c
=
0
;
c
<
stbInfo
->
columnCount
;
c
++
)
{
for
(
int
c
=
0
;
c
<
columnCount
;
c
++
)
{
char
*
tmp
;
char
*
tmp
=
NULL
;
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
"BINARY"
,
strlen
(
"BINARY"
)))
{
uint32_t
dataLen
;
rand_string
(
data
,
stbInfo
->
columns
[
c
].
dataLen
);
char
data_type
=
(
columns
)
?
(
columns
[
c
].
data_type
)
:
g_args
.
data_type
[
c
];
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
data
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
switch
(
data_type
)
{
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
case
TSDB_DATA_TYPE_BINARY
:
rand_string
(
data
,
stbInfo
->
columns
[
c
].
dataLen
);
dataLen
=
(
columns
)
?
columns
[
c
].
dataLen
:
g_args
.
binwidth
;
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
data
);
rand_string
(
data
,
dataLen
);
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
data
);
"INT"
,
strlen
(
"INT"
)))
{
break
;
if
((
g_args
.
demo_mode
)
&&
(
c
==
1
))
{
tmp
=
demo_voltage_int_str
();
case
TSDB_DATA_TYPE_NCHAR
:
}
else
{
dataLen
=
(
columns
)
?
columns
[
c
].
dataLen
:
g_args
.
binwidth
;
tmp
=
rand_int_str
();
rand_string
(
data
,
dataLen
);
}
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
data
);
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
tmp
);
break
;
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
case
TSDB_DATA_TYPE_INT
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bigint_str
());
if
((
g_args
.
demo_mode
)
&&
(
c
==
1
))
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
tmp
=
demo_voltage_int_str
();
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
if
(
g_args
.
demo_mode
)
{
if
(
c
==
0
)
{
tmp
=
demo_current_float_str
();
}
else
{
}
else
{
tmp
=
demo_phase_floa
t_str
();
tmp
=
rand_in
t_str
();
}
}
}
else
{
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
tmp
);
tmp
=
rand_float_str
();
break
;
}
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
tmp
);
case
TSDB_DATA_TYPE_BIGINT
:
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bigint_str
());
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
break
;
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_double_str
());
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
case
TSDB_DATA_TYPE_FLOAT
:
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
if
(
g_args
.
demo_mode
)
{
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_smallint_str
());
if
(
c
==
0
)
{
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
tmp
=
demo_current_float_str
();
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
}
else
{
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_tinyint_str
());
tmp
=
demo_phase_float_str
();
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
}
"BOOL"
,
strlen
(
"BOOL"
)))
{
}
else
{
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bool_str
());
tmp
=
rand_float_str
();
}
else
if
(
0
==
strncasecmp
(
stbInfo
->
columns
[
c
].
dataType
,
}
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
tmp
);
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bigint_str
());
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_double_str
());
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_smallint_str
());
break
;
case
TSDB_DATA_TYPE_TINYINT
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_tinyint_str
());
break
;
case
TSDB_DATA_TYPE_BOOL
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bool_str
());
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
pos
+=
sprintf
(
buff
+
pos
,
"%s,"
,
rand_bigint_str
());
break
;
case
TSDB_DATA_TYPE_NULL
:
break
;
default:
errorPrint2
(
"%s() LN%d, Unknown data type %s
\n
"
,
__func__
,
__LINE__
,
(
columns
)
?
(
columns
[
c
].
dataType
)
:
g_args
.
dataType
[
c
]);
exit
(
EXIT_FAILURE
);
}
}
}
}
*
(
buff
+
pos
-
1
)
=
0
;
*
(
buff
+
pos
-
1
)
=
0
;
memcpy
(
s
tbInfo
->
sampleDataBuf
+
i
*
stbInfo
->
lenOfOneRow
,
buff
,
pos
);
memcpy
(
s
ampleDataBuf
+
i
*
lenOfOneRow
,
buff
,
pos
);
}
}
free
(
buff
);
free
(
buff
);
return
0
;
return
0
;
}
}
static
int
prepareSampleDataForSTable
(
SSuperTable
*
stbInfo
)
{
static
int
generateSampleFromRandForNtb
()
{
return
generateSampleFromRand
(
g_sampleDataBuf
,
g_args
.
lenOfOneRow
,
g_args
.
columnCount
,
NULL
);
}
static
int
generateSampleFromRandForStb
(
SSuperTable
*
stbInfo
)
{
return
generateSampleFromRand
(
stbInfo
->
sampleDataBuf
,
stbInfo
->
lenOfOneRow
,
stbInfo
->
columnCount
,
stbInfo
->
columns
);
}
static
int
prepareSampleForNtb
()
{
g_sampleDataBuf
=
calloc
(
g_args
.
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
1
);
if
(
NULL
==
g_sampleDataBuf
)
{
errorPrint2
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
__func__
,
__LINE__
,
g_args
.
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
strerror
(
errno
));
return
-
1
;
}
return
generateSampleFromRandForNtb
();
}
static
int
prepareSampleForStb
(
SSuperTable
*
stbInfo
)
{
stbInfo
->
sampleDataBuf
=
calloc
(
stbInfo
->
sampleDataBuf
=
calloc
(
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
1
);
stbInfo
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
1
);
...
@@ -6047,10 +6493,11 @@ static int prepareSampleDataForSTable(SSuperTable *stbInfo) {
...
@@ -6047,10 +6493,11 @@ static int prepareSampleDataForSTable(SSuperTable *stbInfo) {
}
}
int
ret
;
int
ret
;
if
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
)))
if
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
)))
{
ret
=
readSampleFromCsvFileToMem
(
stbInfo
);
ret
=
generateSampleFromCsvForStb
(
stbInfo
);
else
}
else
{
ret
=
generateSampleMemoryFromRand
(
stbInfo
);
ret
=
generateSampleFromRandForStb
(
stbInfo
);
}
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, read sample from csv file failed.
\n
"
,
errorPrint2
(
"%s() LN%d, read sample from csv file failed.
\n
"
,
...
@@ -6175,7 +6622,7 @@ static int32_t generateDataTailWithoutStb(
...
@@ -6175,7 +6622,7 @@ static int32_t generateDataTailWithoutStb(
int64_t
retLen
=
0
;
int64_t
retLen
=
0
;
char
*
*
data_type
=
g_args
.
data
type
;
char
*
data_type
=
g_args
.
data_
type
;
int
lenOfBinary
=
g_args
.
binwidth
;
int
lenOfBinary
=
g_args
.
binwidth
;
if
(
g_args
.
disorderRatio
)
{
if
(
g_args
.
disorderRatio
)
{
...
@@ -6361,7 +6808,7 @@ static int generateStbSQLHead(
...
@@ -6361,7 +6808,7 @@ static int generateStbSQLHead(
dbName
,
dbName
,
tableName
,
tableName
,
dbName
,
dbName
,
stbInfo
->
s
Tbl
Name
,
stbInfo
->
s
tb
Name
,
tagsValBuf
);
tagsValBuf
);
tmfree
(
tagsValBuf
);
tmfree
(
tagsValBuf
);
}
else
if
(
TBL_ALREADY_EXISTS
==
stbInfo
->
childTblExists
)
{
}
else
if
(
TBL_ALREADY_EXISTS
==
stbInfo
->
childTblExists
)
{
...
@@ -6493,202 +6940,224 @@ static int64_t generateInterlaceDataWithoutStb(
...
@@ -6493,202 +6940,224 @@ static int64_t generateInterlaceDataWithoutStb(
static
int32_t
prepareStmtBindArrayByType
(
static
int32_t
prepareStmtBindArrayByType
(
TAOS_BIND
*
bind
,
TAOS_BIND
*
bind
,
char
*
dataT
ype
,
int32_t
dataLen
,
char
data_t
ype
,
int32_t
dataLen
,
int32_t
timePrec
,
int32_t
timePrec
,
char
*
value
)
char
*
value
)
{
{
if
(
0
==
strncasecmp
(
dataType
,
int32_t
*
bind_int
;
"BINARY"
,
strlen
(
"BINARY"
)))
{
int64_t
*
bind_bigint
;
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
float
*
bind_float
;
errorPrint2
(
"binary length overflow, max size:%u
\n
"
,
double
*
bind_double
;
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
int8_t
*
bind_bool
;
return
-
1
;
int64_t
*
bind_ts2
;
}
int16_t
*
bind_smallint
;
char
*
bind_binary
;
int8_t
*
bind_tinyint
;
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_BINARY
:
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"binary length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
}
char
*
bind_binary
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
if
(
value
)
{
if
(
value
)
{
bind_binary
=
calloc
(
1
,
strlen
(
value
)
+
1
);
bind_binary
=
calloc
(
1
,
strlen
(
value
)
+
1
);
strncpy
(
bind_binary
,
value
,
strlen
(
value
));
strncpy
(
bind_binary
,
value
,
strlen
(
value
));
bind
->
buffer_length
=
strlen
(
bind_binary
);
bind
->
buffer_length
=
strlen
(
bind_binary
);
}
else
{
}
else
{
bind_binary
=
calloc
(
1
,
dataLen
+
1
);
bind_binary
=
calloc
(
1
,
dataLen
+
1
);
rand_string
(
bind_binary
,
dataLen
);
rand_string
(
bind_binary
,
dataLen
);
bind
->
buffer_length
=
dataLen
;
bind
->
buffer_length
=
dataLen
;
}
}
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer
=
bind_binary
;
bind
->
buffer
=
bind_binary
;
bind
->
is_null
=
NULL
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"nchar length overflow, max size:%u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
}
char
*
bind_nchar
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
case
TSDB_DATA_TYPE_NCHAR
:
if
(
value
)
{
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
bind_nchar
=
calloc
(
1
,
strlen
(
value
)
+
1
);
errorPrint2
(
"nchar length overflow, max size:%u
\n
"
,
strncpy
(
bind_nchar
,
value
,
strlen
(
value
));
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
}
else
{
return
-
1
;
bind_nchar
=
calloc
(
1
,
dataLen
+
1
);
}
rand_string
(
bind_nchar
,
dataLen
);
char
*
bind_nchar
;
}
bind
->
buffer_length
=
strlen
(
bind_nchar
)
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
bind
->
buffer
=
bind_nchar
;
if
(
value
)
{
bind
->
length
=
&
bind
->
buffer_length
;
bind_nchar
=
calloc
(
1
,
strlen
(
value
)
+
1
)
;
bind
->
is_null
=
NULL
;
strncpy
(
bind_nchar
,
value
,
strlen
(
value
))
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
}
else
{
"INT"
,
strlen
(
"INT"
)))
{
bind_nchar
=
calloc
(
1
,
dataLen
+
1
);
int32_t
*
bind_int
=
malloc
(
sizeof
(
int32_t
)
);
rand_string
(
bind_nchar
,
dataLen
);
assert
(
bind_int
);
}
if
(
value
)
{
bind
->
buffer_length
=
strlen
(
bind_nchar
);
*
bind_int
=
atoi
(
value
);
bind
->
buffer
=
bind_nchar
;
}
else
{
bind
->
length
=
&
bind
->
buffer_length
;
*
bind_int
=
rand_int
();
bind
->
is_null
=
NULL
;
}
break
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_INT
;
bind
->
buffer_length
=
sizeof
(
int32_t
);
bind
->
buffer
=
bind_int
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
int64_t
*
bind_bigint
=
malloc
(
sizeof
(
int64_t
));
assert
(
bind_bigint
);
if
(
value
)
{
case
TSDB_DATA_TYPE_INT
:
*
bind_bigint
=
atoll
(
value
);
bind_int
=
malloc
(
sizeof
(
int32_t
));
}
else
{
assert
(
bind_int
);
*
bind_bigint
=
rand_bigint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_bigint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
float
*
bind_float
=
malloc
(
sizeof
(
float
));
assert
(
bind_float
);
if
(
value
)
{
if
(
value
)
{
*
bind_float
=
(
float
)
atof
(
value
);
*
bind_int
=
atoi
(
value
);
}
else
{
}
else
{
*
bind_float
=
rand_float
();
*
bind_int
=
rand_int
();
}
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_INT
;
bind
->
buffer_length
=
sizeof
(
float
);
bind
->
buffer_length
=
sizeof
(
int32_t
);
bind
->
buffer
=
bind_float
;
bind
->
buffer
=
bind_int
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
double
*
bind_double
=
malloc
(
sizeof
(
double
));
assert
(
bind_double
);
if
(
value
)
{
case
TSDB_DATA_TYPE_BIGINT
:
*
bind_double
=
atof
(
value
);
bind_bigint
=
malloc
(
sizeof
(
int64_t
));
}
else
{
assert
(
bind_bigint
);
*
bind_double
=
rand_double
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
bind
->
buffer_length
=
sizeof
(
double
);
bind
->
buffer
=
bind_double
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
int16_t
*
bind_smallint
=
malloc
(
sizeof
(
int16_t
));
assert
(
bind_smallint
);
if
(
value
)
{
if
(
value
)
{
*
bind_smallint
=
(
int16_t
)
atoi
(
value
);
*
bind_bigint
=
atoll
(
value
);
}
else
{
}
else
{
*
bind_smallint
=
rand_smallint
();
*
bind_bigint
=
rand_bigint
();
}
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
bind
->
buffer_length
=
sizeof
(
int16_t
);
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_smallint
;
bind
->
buffer
=
bind_bigint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
int8_t
*
bind_tinyint
=
malloc
(
sizeof
(
int8_t
));
assert
(
bind_tinyint
);
if
(
value
)
{
case
TSDB_DATA_TYPE_FLOAT
:
*
bind_tinyint
=
(
int8_t
)
atoi
(
value
);
bind_float
=
malloc
(
sizeof
(
float
));
}
else
{
assert
(
bind_float
);
*
bind_tinyint
=
rand_tinyint
();
}
if
(
value
)
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
*
bind_float
=
(
float
)
atof
(
value
);
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
buffer
=
bind_tinyint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
"BOOL"
,
strlen
(
"BOOL"
)))
{
int8_t
*
bind_bool
=
malloc
(
sizeof
(
int8_t
));
assert
(
bind_bool
);
if
(
value
)
{
if
(
strncasecmp
(
value
,
"true"
,
4
))
{
*
bind_bool
=
true
;
}
else
{
}
else
{
*
bind_
bool
=
false
;
*
bind_
float
=
rand_float
()
;
}
}
}
else
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
*
bind_bool
=
rand_bool
();
bind
->
buffer_length
=
sizeof
(
float
);
}
bind
->
buffer
=
bind_float
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
is_null
=
NULL
;
bind
->
buffer
=
bind_bool
;
break
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
case
TSDB_DATA_TYPE_DOUBLE
:
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
bind_double
=
malloc
(
sizeof
(
double
));
int64_t
*
bind_ts2
=
malloc
(
sizeof
(
int64_t
));
assert
(
bind_double
);
assert
(
bind_ts2
);
if
(
value
)
{
if
(
value
)
{
*
bind_double
=
atof
(
value
);
if
(
strchr
(
value
,
':'
)
&&
strchr
(
value
,
'-'
))
{
int
i
=
0
;
while
(
value
[
i
]
!=
'\0'
)
{
if
(
value
[
i
]
==
'\"'
||
value
[
i
]
==
'\''
)
{
value
[
i
]
=
' '
;
}
i
++
;
}
int64_t
tmpEpoch
;
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
value
,
&
tmpEpoch
,
strlen
(
value
),
timePrec
,
0
))
{
free
(
bind_ts2
);
errorPrint2
(
"Input %s, time format error!
\n
"
,
value
);
return
-
1
;
}
*
bind_ts2
=
tmpEpoch
;
}
else
{
}
else
{
*
bind_
ts2
=
atoll
(
value
);
*
bind_
double
=
rand_double
(
);
}
}
}
else
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
*
bind_ts2
=
rand_bigint
();
bind
->
buffer_length
=
sizeof
(
double
);
}
bind
->
buffer
=
bind_double
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
is_null
=
NULL
;
bind
->
buffer
=
bind_ts2
;
break
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
case
TSDB_DATA_TYPE_SMALLINT
:
}
else
{
bind_smallint
=
malloc
(
sizeof
(
int16_t
));
errorPrint2
(
"Not support data type: %s
\n
"
,
dataType
);
assert
(
bind_smallint
);
return
-
1
;
if
(
value
)
{
*
bind_smallint
=
(
int16_t
)
atoi
(
value
);
}
else
{
*
bind_smallint
=
rand_smallint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
bind
->
buffer_length
=
sizeof
(
int16_t
);
bind
->
buffer
=
bind_smallint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
bind_tinyint
=
malloc
(
sizeof
(
int8_t
));
assert
(
bind_tinyint
);
if
(
value
)
{
*
bind_tinyint
=
(
int8_t
)
atoi
(
value
);
}
else
{
*
bind_tinyint
=
rand_tinyint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
buffer
=
bind_tinyint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
bind_bool
=
malloc
(
sizeof
(
int8_t
));
assert
(
bind_bool
);
if
(
value
)
{
if
(
strncasecmp
(
value
,
"true"
,
4
))
{
*
bind_bool
=
true
;
}
else
{
*
bind_bool
=
false
;
}
}
else
{
*
bind_bool
=
rand_bool
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
buffer
=
bind_bool
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
bind_ts2
=
malloc
(
sizeof
(
int64_t
));
assert
(
bind_ts2
);
if
(
value
)
{
if
(
strchr
(
value
,
':'
)
&&
strchr
(
value
,
'-'
))
{
int
i
=
0
;
while
(
value
[
i
]
!=
'\0'
)
{
if
(
value
[
i
]
==
'\"'
||
value
[
i
]
==
'\''
)
{
value
[
i
]
=
' '
;
}
i
++
;
}
int64_t
tmpEpoch
;
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
value
,
&
tmpEpoch
,
strlen
(
value
),
timePrec
,
0
))
{
free
(
bind_ts2
);
errorPrint2
(
"Input %s, time format error!
\n
"
,
value
);
return
-
1
;
}
*
bind_ts2
=
tmpEpoch
;
}
else
{
*
bind_ts2
=
atoll
(
value
);
}
}
else
{
*
bind_ts2
=
rand_bigint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_ts2
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
break
;
case
TSDB_DATA_TYPE_NULL
:
break
;
default:
errorPrint2
(
"Not support data type: %d
\n
"
,
data_type
);
exit
(
EXIT_FAILURE
);
}
}
return
0
;
return
0
;
...
@@ -6696,209 +7165,230 @@ static int32_t prepareStmtBindArrayByType(
...
@@ -6696,209 +7165,230 @@ static int32_t prepareStmtBindArrayByType(
static
int32_t
prepareStmtBindArrayByTypeForRand
(
static
int32_t
prepareStmtBindArrayByTypeForRand
(
TAOS_BIND
*
bind
,
TAOS_BIND
*
bind
,
char
*
dataT
ype
,
int32_t
dataLen
,
char
data_t
ype
,
int32_t
dataLen
,
int32_t
timePrec
,
int32_t
timePrec
,
char
**
ptr
,
char
**
ptr
,
char
*
value
)
char
*
value
)
{
{
if
(
0
==
strncasecmp
(
dataType
,
int32_t
*
bind_int
;
"BINARY"
,
strlen
(
"BINARY"
)))
{
int64_t
*
bind_bigint
;
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
float
*
bind_float
;
errorPrint2
(
"binary length overflow, max size:%u
\n
"
,
double
*
bind_double
;
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
int16_t
*
bind_smallint
;
return
-
1
;
int8_t
*
bind_tinyint
;
}
int8_t
*
bind_bool
;
char
*
bind_binary
=
(
char
*
)
*
ptr
;
int64_t
*
bind_ts2
;
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_BINARY
:
bind
->
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
if
(
value
)
{
errorPrint2
(
"binary length overflow, max size:%u
\n
"
,
strncpy
(
bind_binary
,
value
,
strlen
(
value
));
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
bind
->
buffer_length
=
strlen
(
bind_binary
);
return
-
1
;
}
else
{
}
rand_string
(
bind_binary
,
dataLen
);
char
*
bind_binary
=
(
char
*
)
*
ptr
;
bind
->
buffer_length
=
dataLen
;
}
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
bind
->
buffer
=
bind_binary
;
if
(
value
)
{
bind
->
is_null
=
NULL
;
strncpy
(
bind_binary
,
value
,
strlen
(
value
));
bind
->
buffer_length
=
strlen
(
bind_binary
);
}
else
{
rand_string
(
bind_binary
,
dataLen
);
bind
->
buffer_length
=
dataLen
;
}
*
ptr
+=
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
bind
->
buffer
=
bind_binary
;
"NCHAR"
,
strlen
(
"NCHAR"
)))
{
bind
->
is_null
=
NULL
;
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
errorPrint2
(
"nchar length overflow, max size: %u
\n
"
,
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
}
char
*
bind_nchar
=
(
char
*
)
*
ptr
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
*
ptr
+=
bind
->
buffer_length
;
if
(
value
)
{
break
;
strncpy
(
bind_nchar
,
value
,
strlen
(
value
));
}
else
{
rand_string
(
bind_nchar
,
dataLen
);
}
bind
->
buffer_length
=
strlen
(
bind_nchar
);
case
TSDB_DATA_TYPE_NCHAR
:
bind
->
buffer
=
bind_nchar
;
if
(
dataLen
>
TSDB_MAX_BINARY_LEN
)
{
bind
->
length
=
&
bind
->
buffer_length
;
errorPrint2
(
"nchar length overflow, max size: %u
\n
"
,
bind
->
is_null
=
NULL
;
(
uint32_t
)
TSDB_MAX_BINARY_LEN
);
return
-
1
;
}
char
*
bind_nchar
=
(
char
*
)
*
ptr
;
*
ptr
+=
bind
->
buffer_length
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
if
(
value
)
{
"INT"
,
strlen
(
"INT"
)))
{
strncpy
(
bind_nchar
,
value
,
strlen
(
value
));
int32_t
*
bind_int
=
(
int32_t
*
)
*
ptr
;
}
else
{
rand_string
(
bind_nchar
,
dataLen
);
}
if
(
value
)
{
bind
->
buffer_length
=
strlen
(
bind_nchar
);
*
bind_int
=
atoi
(
value
);
bind
->
buffer
=
bind_nchar
;
}
else
{
bind
->
length
=
&
bind
->
buffer_length
;
*
bind_int
=
rand_int
();
bind
->
is_null
=
NULL
;
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_INT
;
bind
->
buffer_length
=
sizeof
(
int32_t
);
bind
->
buffer
=
bind_int
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
*
ptr
+=
bind
->
buffer_length
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"BIGINT"
,
strlen
(
"BIGINT"
)))
{
int64_t
*
bind_bigint
=
(
int64_t
*
)
*
ptr
;
if
(
value
)
{
case
TSDB_DATA_TYPE_INT
:
*
bind_bigint
=
atoll
(
value
);
bind_int
=
(
int32_t
*
)
*
ptr
;
}
else
{
*
bind_bigint
=
rand_bigint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_bigint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
if
(
value
)
{
}
else
if
(
0
==
strncasecmp
(
dataType
,
*
bind_int
=
atoi
(
value
);
"FLOAT"
,
strlen
(
"FLOAT"
)))
{
}
else
{
float
*
bind_float
=
(
float
*
)
*
ptr
;
*
bind_int
=
rand_int
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_INT
;
bind
->
buffer_length
=
sizeof
(
int32_t
);
bind
->
buffer
=
bind_int
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
if
(
value
)
{
*
ptr
+=
bind
->
buffer_length
;
*
bind_float
=
(
float
)
atof
(
value
);
break
;
}
else
{
*
bind_float
=
rand_float
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
bind
->
buffer_length
=
sizeof
(
float
);
bind
->
buffer
=
bind_float
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
case
TSDB_DATA_TYPE_BIGINT
:
}
else
if
(
0
==
strncasecmp
(
dataType
,
bind_bigint
=
(
int64_t
*
)
*
ptr
;
"DOUBLE"
,
strlen
(
"DOUBLE"
)))
{
double
*
bind_double
=
(
double
*
)
*
ptr
;
if
(
value
)
{
if
(
value
)
{
*
bind_double
=
atof
(
value
);
*
bind_bigint
=
atoll
(
value
);
}
else
{
}
else
{
*
bind_double
=
rand_double
();
*
bind_bigint
=
rand_bigint
();
}
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
bind
->
buffer_length
=
sizeof
(
double
);
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_double
;
bind
->
buffer
=
bind_bigint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
*
ptr
+=
bind
->
buffer_length
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"SMALLINT"
,
strlen
(
"SMALLINT"
)))
{
int16_t
*
bind_smallint
=
(
int16_t
*
)
*
ptr
;
if
(
value
)
{
case
TSDB_DATA_TYPE_FLOAT
:
*
bind_smallint
=
(
int16_t
)
atoi
(
value
);
bind_float
=
(
float
*
)
*
ptr
;
}
else
{
*
bind_smallint
=
rand_smallint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
bind
->
buffer_length
=
sizeof
(
int16_t
);
bind
->
buffer
=
bind_smallint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
if
(
value
)
{
}
else
if
(
0
==
strncasecmp
(
dataType
,
*
bind_float
=
(
float
)
atof
(
value
);
"TINYINT"
,
strlen
(
"TINYINT"
)))
{
}
else
{
int8_t
*
bind_tinyint
=
(
int8_t
*
)
*
ptr
;
*
bind_float
=
rand_float
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
bind
->
buffer_length
=
sizeof
(
float
);
bind
->
buffer
=
bind_float
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
if
(
value
)
{
*
ptr
+=
bind
->
buffer_length
;
*
bind_tinyint
=
(
int8_t
)
atoi
(
value
);
break
;
}
else
{
*
bind_tinyint
=
rand_tinyint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
buffer
=
bind_tinyint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
case
TSDB_DATA_TYPE_DOUBLE
:
}
else
if
(
0
==
strncasecmp
(
dataType
,
bind_double
=
(
double
*
)
*
ptr
;
"BOOL"
,
strlen
(
"BOOL"
)))
{
int8_t
*
bind_bool
=
(
int8_t
*
)
*
ptr
;
if
(
value
)
{
if
(
value
)
{
if
(
strncasecmp
(
value
,
"true"
,
4
))
{
*
bind_double
=
atof
(
value
);
*
bind_bool
=
true
;
}
else
{
}
else
{
*
bind_
bool
=
false
;
*
bind_
double
=
rand_double
()
;
}
}
}
else
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
*
bind_bool
=
rand_bool
();
bind
->
buffer_length
=
sizeof
(
double
);
}
bind
->
buffer
=
bind_double
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
is_null
=
NULL
;
bind
->
buffer
=
bind_bool
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
*
ptr
+=
bind
->
buffer_length
;
}
else
if
(
0
==
strncasecmp
(
dataType
,
break
;
"TIMESTAMP"
,
strlen
(
"TIMESTAMP"
)))
{
int64_t
*
bind_ts2
=
(
int64_t
*
)
*
ptr
;
case
TSDB_DATA_TYPE_SMALLINT
:
bind_smallint
=
(
int16_t
*
)
*
ptr
;
if
(
value
)
{
if
(
strchr
(
value
,
':'
)
&&
strchr
(
value
,
'-'
))
{
if
(
value
)
{
int
i
=
0
;
*
bind_smallint
=
(
int16_t
)
atoi
(
value
);
while
(
value
[
i
]
!=
'\0'
)
{
}
else
{
if
(
value
[
i
]
==
'\"'
||
value
[
i
]
==
'\''
)
{
*
bind_smallint
=
rand_smallint
();
value
[
i
]
=
' '
;
}
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
i
++
;
bind
->
buffer_length
=
sizeof
(
int16_t
);
bind
->
buffer
=
bind_smallint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
bind_tinyint
=
(
int8_t
*
)
*
ptr
;
if
(
value
)
{
*
bind_tinyint
=
(
int8_t
)
atoi
(
value
);
}
else
{
*
bind_tinyint
=
rand_tinyint
();
}
bind
->
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
bind
->
buffer_length
=
sizeof
(
int8_t
);
bind
->
buffer
=
bind_tinyint
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
bind_bool
=
(
int8_t
*
)
*
ptr
;
if
(
value
)
{
if
(
strncasecmp
(
value
,
"true"
,
4
))
{
*
bind_bool
=
true
;
}
else
{
*
bind_bool
=
false
;
}
}
int64_t
tmpEpoch
;
}
else
{
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
*
bind_bool
=
rand_bool
();
value
,
&
tmpEpoch
,
strlen
(
value
),
}
timePrec
,
0
))
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
errorPrint2
(
"Input %s, time format error!
\n
"
,
value
);
bind
->
buffer_length
=
sizeof
(
int8_t
);
return
-
1
;
bind
->
buffer
=
bind_bool
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
bind_ts2
=
(
int64_t
*
)
*
ptr
;
if
(
value
)
{
if
(
strchr
(
value
,
':'
)
&&
strchr
(
value
,
'-'
))
{
int
i
=
0
;
while
(
value
[
i
]
!=
'\0'
)
{
if
(
value
[
i
]
==
'\"'
||
value
[
i
]
==
'\''
)
{
value
[
i
]
=
' '
;
}
i
++
;
}
int64_t
tmpEpoch
;
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
value
,
&
tmpEpoch
,
strlen
(
value
),
timePrec
,
0
))
{
errorPrint2
(
"Input %s, time format error!
\n
"
,
value
);
return
-
1
;
}
*
bind_ts2
=
tmpEpoch
;
}
else
{
*
bind_ts2
=
atoll
(
value
);
}
}
*
bind_ts2
=
tmpEpoch
;
}
else
{
}
else
{
*
bind_ts2
=
atoll
(
value
);
*
bind_ts2
=
rand_bigint
(
);
}
}
}
else
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
*
bind_ts2
=
rand_bigint
();
bind
->
buffer_length
=
sizeof
(
int64_t
);
}
bind
->
buffer
=
bind_ts2
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
is_null
=
NULL
;
bind
->
buffer
=
bind_ts2
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
*
ptr
+=
bind
->
buffer_length
;
*
ptr
+=
bind
->
buffer_length
;
}
else
{
break
;
errorPrint2
(
"No support data type: %s
\n
"
,
dataType
);
return
-
1
;
default:
errorPrint2
(
"No support data type: %d
\n
"
,
data_type
);
return
-
1
;
}
}
return
0
;
return
0
;
...
@@ -6920,12 +7410,12 @@ static int32_t prepareStmtWithoutStb(
...
@@ -6920,12 +7410,12 @@ static int32_t prepareStmtWithoutStb(
return
ret
;
return
ret
;
}
}
char
*
*
data_type
=
g_args
.
data
type
;
char
*
data_type
=
g_args
.
data_
type
;
char
*
bindArray
=
malloc
(
sizeof
(
TAOS_BIND
)
*
(
g_args
.
num_of_CPR
+
1
));
char
*
bindArray
=
malloc
(
sizeof
(
TAOS_BIND
)
*
(
g_args
.
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
if
(
bindArray
==
NULL
)
{
errorPrint2
(
"Failed to allocate %d bind params
\n
"
,
errorPrint2
(
"Failed to allocate %d bind params
\n
"
,
(
g_args
.
num_of_CPR
+
1
));
(
g_args
.
columnCount
+
1
));
return
-
1
;
return
-
1
;
}
}
...
@@ -6952,7 +7442,7 @@ static int32_t prepareStmtWithoutStb(
...
@@ -6952,7 +7442,7 @@ static int32_t prepareStmtWithoutStb(
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
bind
->
is_null
=
NULL
;
for
(
int
i
=
0
;
i
<
g_args
.
num_of_CPR
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_args
.
columnCount
;
i
++
)
{
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
(
i
+
1
)));
+
(
sizeof
(
TAOS_BIND
)
*
(
i
+
1
)));
if
(
-
1
==
prepareStmtBindArrayByType
(
if
(
-
1
==
prepareStmtBindArrayByType
(
...
@@ -6992,29 +7482,20 @@ static int32_t prepareStbStmtBindTag(
...
@@ -6992,29 +7482,20 @@ static int32_t prepareStbStmtBindTag(
char
*
tagsVal
,
char
*
tagsVal
,
int32_t
timePrec
)
int32_t
timePrec
)
{
{
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.binwidth);
if
(
bindBuffer
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
DOUBLE_BUFF_LEN
);
return
-
1
;
}
TAOS_BIND
*
tag
;
TAOS_BIND
*
tag
;
for
(
int
t
=
0
;
t
<
stbInfo
->
tagCount
;
t
++
)
{
for
(
int
t
=
0
;
t
<
stbInfo
->
tagCount
;
t
++
)
{
tag
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
t
));
tag
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
t
));
if
(
-
1
==
prepareStmtBindArrayByType
(
if
(
-
1
==
prepareStmtBindArrayByType
(
tag
,
tag
,
stbInfo
->
tags
[
t
].
data
T
ype
,
stbInfo
->
tags
[
t
].
data
_t
ype
,
stbInfo
->
tags
[
t
].
dataLen
,
stbInfo
->
tags
[
t
].
dataLen
,
timePrec
,
timePrec
,
NULL
))
{
NULL
))
{
free
(
bindBuffer
);
return
-
1
;
return
-
1
;
}
}
}
}
free
(
bindBuffer
);
return
0
;
return
0
;
}
}
...
@@ -7024,13 +7505,6 @@ static int32_t prepareStbStmtBindRand(
...
@@ -7024,13 +7505,6 @@ static int32_t prepareStbStmtBindRand(
int64_t
startTime
,
int32_t
recSeq
,
int64_t
startTime
,
int32_t
recSeq
,
int32_t
timePrec
)
int32_t
timePrec
)
{
{
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.binwidth);
if
(
bindBuffer
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
DOUBLE_BUFF_LEN
);
return
-
1
;
}
char
data
[
MAX_DATA_SIZE
];
char
data
[
MAX_DATA_SIZE
];
memset
(
data
,
0
,
MAX_DATA_SIZE
);
memset
(
data
,
0
,
MAX_DATA_SIZE
);
char
*
ptr
=
data
;
char
*
ptr
=
data
;
...
@@ -7060,26 +7534,681 @@ static int32_t prepareStbStmtBindRand(
...
@@ -7060,26 +7534,681 @@ static int32_t prepareStbStmtBindRand(
ptr
+=
bind
->
buffer_length
;
ptr
+=
bind
->
buffer_length
;
}
else
if
(
-
1
==
prepareStmtBindArrayByTypeForRand
(
}
else
if
(
-
1
==
prepareStmtBindArrayByTypeForRand
(
bind
,
bind
,
stbInfo
->
columns
[
i
-
1
].
data
T
ype
,
stbInfo
->
columns
[
i
-
1
].
data
_t
ype
,
stbInfo
->
columns
[
i
-
1
].
dataLen
,
stbInfo
->
columns
[
i
-
1
].
dataLen
,
timePrec
,
timePrec
,
&
ptr
,
&
ptr
,
NULL
))
{
NULL
))
{
tmfree
(
bindBuffer
);
return
-
1
;
return
-
1
;
}
}
}
}
tmfree
(
bindBuffer
);
return
0
;
return
0
;
}
UNUSED_FUNC
static
int32_t
prepareStbStmtRand
(
threadInfo
*
pThreadInfo
,
char
*
tableName
,
int64_t
tableSeq
,
uint32_t
batch
,
uint64_t
insertRows
,
uint64_t
recordFrom
,
int64_t
startTime
)
{
int
ret
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
char
*
tagsValBuf
=
NULL
;
if
(
0
==
stbInfo
->
tagSource
)
{
tagsValBuf
=
generateTagValuesForStb
(
stbInfo
,
tableSeq
);
}
else
{
tagsValBuf
=
getTagValueFromTagSample
(
stbInfo
,
tableSeq
%
stbInfo
->
tagSampleCount
);
}
if
(
NULL
==
tagsValBuf
)
{
errorPrint2
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
-
1
;
}
char
*
tagsArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
stbInfo
->
tagCount
);
if
(
NULL
==
tagsArray
)
{
tmfree
(
tagsValBuf
);
errorPrint2
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
-
1
;
}
if
(
-
1
==
prepareStbStmtBindTag
(
tagsArray
,
stbInfo
,
tagsValBuf
,
pThreadInfo
->
time_precision
/* is tag */
))
{
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
return
-
1
;
}
ret
=
taos_stmt_set_tbname_tags
(
stmt
,
tableName
,
(
TAOS_BIND
*
)
tagsArray
);
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_set_tbname_tags() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
}
else
{
ret
=
taos_stmt_set_tbname
(
stmt
,
tableName
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_set_tbname() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
}
char
*
bindArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
stbInfo
->
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind params
\n
"
,
__func__
,
__LINE__
,
(
stbInfo
->
columnCount
+
1
));
return
-
1
;
}
uint32_t
k
;
for
(
k
=
0
;
k
<
batch
;)
{
/* columnCount + 1 (ts) */
if
(
-
1
==
prepareStbStmtBindRand
(
pThreadInfo
->
bind_ts
,
bindArray
,
stbInfo
,
startTime
,
k
,
pThreadInfo
->
time_precision
/* is column */
))
{
free
(
bindArray
);
return
-
1
;
}
ret
=
taos_stmt_bind_param
(
stmt
,
(
TAOS_BIND
*
)
bindArray
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_bind_param() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
free
(
bindArray
);
return
-
1
;
}
// if msg > 3MB, break
ret
=
taos_stmt_add_batch
(
stmt
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
free
(
bindArray
);
return
-
1
;
}
k
++
;
recordFrom
++
;
if
(
recordFrom
>=
insertRows
)
{
break
;
}
}
free
(
bindArray
);
return
k
;
}
#if STMT_BIND_PARAM_BATCH == 1
static
int
execBindParamBatch
(
threadInfo
*
pThreadInfo
,
char
*
tableName
,
int64_t
tableSeq
,
uint32_t
batch
,
uint64_t
insertRows
,
uint64_t
recordFrom
,
int64_t
startTime
,
int64_t
*
pSamplePos
)
{
int
ret
;
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
uint32_t
columnCount
=
(
stbInfo
)
?
pThreadInfo
->
stbInfo
->
columnCount
:
g_args
.
columnCount
;
uint32_t
thisBatch
=
MAX_SAMPLES_ONCE_FROM_FILE
-
(
*
pSamplePos
);
if
(
thisBatch
>
batch
)
{
thisBatch
=
batch
;
}
verbosePrint
(
"%s() LN%d, batch=%d pos=%"
PRId64
" thisBatch=%d
\n
"
,
__func__
,
__LINE__
,
batch
,
*
pSamplePos
,
thisBatch
);
memset
(
pThreadInfo
->
bindParams
,
0
,
(
sizeof
(
TAOS_MULTI_BIND
)
*
(
columnCount
+
1
)));
memset
(
pThreadInfo
->
is_null
,
0
,
thisBatch
);
for
(
int
c
=
0
;
c
<
columnCount
+
1
;
c
++
)
{
TAOS_MULTI_BIND
*
param
=
(
TAOS_MULTI_BIND
*
)(
pThreadInfo
->
bindParams
+
sizeof
(
TAOS_MULTI_BIND
)
*
c
);
char
data_type
;
if
(
c
==
0
)
{
data_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
param
->
buffer_length
=
sizeof
(
int64_t
);
param
->
buffer
=
pThreadInfo
->
bind_ts_array
;
}
else
{
data_type
=
(
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
data_type
:
g_args
.
data_type
[
c
-
1
];
char
*
tmpP
;
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
param
->
buffer_length
=
((
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
dataLen
:
g_args
.
binwidth
);
tmpP
=
(
char
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
)));
verbosePrint
(
"%s() LN%d, tmpP=%p pos=%"
PRId64
" width=%d position=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
tmpP
,
*
pSamplePos
,
(((
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
dataLen
:
g_args
.
binwidth
)),
(
*
pSamplePos
)
*
(((
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
dataLen
:
g_args
.
binwidth
)));
param
->
buffer
=
(
void
*
)(
tmpP
+
*
pSamplePos
*
(((
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
dataLen
:
g_args
.
binwidth
))
);
break
;
case
TSDB_DATA_TYPE_INT
:
param
->
buffer_length
=
sizeof
(
int32_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int32_t
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_TINYINT
:
param
->
buffer_length
=
sizeof
(
int8_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int8_t
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
param
->
buffer_length
=
sizeof
(
int16_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int16_t
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
param
->
buffer_length
=
sizeof
(
int64_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int64_t
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_BOOL
:
param
->
buffer_length
=
sizeof
(
int8_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int8_t
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
param
->
buffer_length
=
sizeof
(
float
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
float
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
param
->
buffer_length
=
sizeof
(
double
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
double
)
*
(
*
pSamplePos
));
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
param
->
buffer_length
=
sizeof
(
int64_t
);
param
->
buffer
=
(
stbInfo
)
?
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
stbInfo
->
sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
stbInfo
->
columns
[
c
-
1
].
dataLen
*
(
*
pSamplePos
))
:
(
void
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
g_sampleBindBatchArray
+
sizeof
(
char
*
)
*
(
c
-
1
))
+
sizeof
(
int64_t
)
*
(
*
pSamplePos
));
break
;
default:
errorPrint
(
"%s() LN%d, wrong data type: %d
\n
"
,
__func__
,
__LINE__
,
data_type
);
exit
(
EXIT_FAILURE
);
}
}
param
->
buffer_type
=
data_type
;
param
->
length
=
malloc
(
sizeof
(
int32_t
)
*
thisBatch
);
assert
(
param
->
length
);
for
(
int
b
=
0
;
b
<
thisBatch
;
b
++
)
{
if
(
param
->
buffer_type
==
TSDB_DATA_TYPE_NCHAR
)
{
param
->
length
[
b
]
=
strlen
(
(
char
*
)
param
->
buffer
+
b
*
((
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataLen
:
g_args
.
binwidth
)
);
}
else
{
param
->
length
[
b
]
=
param
->
buffer_length
;
}
}
param
->
is_null
=
pThreadInfo
->
is_null
;
param
->
num
=
thisBatch
;
}
uint32_t
k
;
for
(
k
=
0
;
k
<
thisBatch
;)
{
/* columnCount + 1 (ts) */
if
(
stbInfo
->
disorderRatio
)
{
*
(
pThreadInfo
->
bind_ts_array
+
k
)
=
startTime
+
getTSRandTail
(
stbInfo
->
timeStampStep
,
k
,
stbInfo
->
disorderRatio
,
stbInfo
->
disorderRange
);
}
else
{
*
(
pThreadInfo
->
bind_ts_array
+
k
)
=
startTime
+
stbInfo
->
timeStampStep
*
k
;
}
debugPrint
(
"%s() LN%d, k=%d ts=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
k
,
*
(
pThreadInfo
->
bind_ts_array
+
k
));
k
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
pSamplePos
=
0
;
}
if
(
recordFrom
>=
insertRows
)
{
break
;
}
}
ret
=
taos_stmt_bind_param_batch
(
stmt
,
(
TAOS_MULTI_BIND
*
)
pThreadInfo
->
bindParams
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_bind_param() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
for
(
int
c
=
0
;
c
<
stbInfo
->
columnCount
+
1
;
c
++
)
{
TAOS_MULTI_BIND
*
param
=
(
TAOS_MULTI_BIND
*
)(
pThreadInfo
->
bindParams
+
sizeof
(
TAOS_MULTI_BIND
)
*
c
);
free
(
param
->
length
);
}
// if msg > 3MB, break
ret
=
taos_stmt_add_batch
(
stmt
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
return
k
;
}
static
int
parseSamplefileToStmtBatch
(
SSuperTable
*
stbInfo
)
{
// char *sampleDataBuf = (stbInfo)?
// stbInfo->sampleDataBuf:g_sampleDataBuf;
int32_t
columnCount
=
(
stbInfo
)
?
stbInfo
->
columnCount
:
g_args
.
columnCount
;
char
*
sampleBindBatchArray
=
NULL
;
if
(
stbInfo
)
{
stbInfo
->
sampleBindBatchArray
=
calloc
(
1
,
sizeof
(
uintptr_t
*
)
*
columnCount
);
sampleBindBatchArray
=
stbInfo
->
sampleBindBatchArray
;
}
else
{
g_sampleBindBatchArray
=
calloc
(
1
,
sizeof
(
uintptr_t
*
)
*
columnCount
);
sampleBindBatchArray
=
g_sampleBindBatchArray
;
}
assert
(
sampleBindBatchArray
);
for
(
int
c
=
0
;
c
<
columnCount
;
c
++
)
{
char
data_type
=
(
stbInfo
)
?
stbInfo
->
columns
[
c
].
data_type
:
g_args
.
data_type
[
c
];
char
*
tmpP
=
NULL
;
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_INT
:
tmpP
=
calloc
(
1
,
sizeof
(
int
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int16_t
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
tmpP
=
calloc
(
1
,
sizeof
(
int8_t
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
tmpP
=
calloc
(
1
,
sizeof
(
float
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
tmpP
=
calloc
(
1
,
sizeof
(
double
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
tmpP
=
calloc
(
1
,
MAX_SAMPLES_ONCE_FROM_FILE
*
(((
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataLen
:
g_args
.
binwidth
)));
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
tmpP
=
calloc
(
1
,
sizeof
(
int64_t
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
tmpP
);
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
uintptr_t
*
)
*
c
)
=
(
uintptr_t
)
tmpP
;
break
;
default:
errorPrint
(
"Unknown data type: %s
\n
"
,
(
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataType
:
g_args
.
dataType
[
c
]);
exit
(
EXIT_FAILURE
);
}
}
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
for
(
int
i
=
0
;
i
<
MAX_SAMPLES_ONCE_FROM_FILE
;
i
++
)
{
int
cursor
=
0
;
for
(
int
c
=
0
;
c
<
columnCount
;
c
++
)
{
char
data_type
=
(
stbInfo
)
?
stbInfo
->
columns
[
c
].
data_type
:
g_args
.
data_type
[
c
];
char
*
restStr
=
sampleDataBuf
+
lenOfOneRow
*
i
+
cursor
;
int
lengthOfRest
=
strlen
(
restStr
);
int
index
=
0
;
for
(
index
=
0
;
index
<
lengthOfRest
;
index
++
)
{
if
(
restStr
[
index
]
==
','
)
{
break
;
}
}
char
*
tmpStr
=
calloc
(
1
,
index
+
1
);
if
(
NULL
==
tmpStr
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
index
+
1
);
return
-
1
;
}
strncpy
(
tmpStr
,
restStr
,
index
);
cursor
+=
index
+
1
;
// skip ',' too
char
*
tmpP
;
switch
(
data_type
)
{
case
TSDB_DATA_TYPE_INT
:
*
((
int32_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int32_t
)
*
i
))
=
atoi
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
*
(
float
*
)(((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
float
)
*
i
))
=
(
float
)
atof
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
*
(
double
*
)(((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
double
)
*
i
))
=
atof
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
*
((
int8_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int8_t
)
*
i
))
=
(
int8_t
)
atoi
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
*
((
int16_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int16_t
)
*
i
))
=
(
int16_t
)
atoi
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
*
((
int64_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int64_t
)
*
i
))
=
(
int64_t
)
atol
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
*
((
int8_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int8_t
)
*
i
))
=
(
int8_t
)
atoi
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
((
int64_t
*
)((
uintptr_t
)
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
)
+
sizeof
(
int64_t
)
*
i
))
=
(
int64_t
)
atol
(
tmpStr
);
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
tmpP
=
(
char
*
)(
*
(
uintptr_t
*
)(
sampleBindBatchArray
+
sizeof
(
char
*
)
*
c
));
strcpy
(
tmpP
+
i
*
(((
stbInfo
)
?
stbInfo
->
columns
[
c
].
dataLen
:
g_args
.
binwidth
))
,
tmpStr
);
break
;
default:
break
;
}
free
(
tmpStr
);
}
}
return
0
;
}
static
int
parseSampleToStmtBatchForThread
(
threadInfo
*
pThreadInfo
,
SSuperTable
*
stbInfo
,
uint32_t
timePrec
,
uint32_t
batch
)
{
uint32_t
columnCount
=
(
stbInfo
)
?
stbInfo
->
columnCount
:
g_args
.
columnCount
;
pThreadInfo
->
bind_ts_array
=
malloc
(
sizeof
(
int64_t
)
*
batch
);
assert
(
pThreadInfo
->
bind_ts_array
);
pThreadInfo
->
bindParams
=
malloc
(
sizeof
(
TAOS_MULTI_BIND
)
*
(
columnCount
+
1
));
assert
(
pThreadInfo
->
bindParams
);
pThreadInfo
->
is_null
=
malloc
(
batch
);
assert
(
pThreadInfo
->
is_null
);
return
0
;
}
static
int
parseStbSampleToStmtBatchForThread
(
threadInfo
*
pThreadInfo
,
SSuperTable
*
stbInfo
,
uint32_t
timePrec
,
uint32_t
batch
)
{
return
parseSampleToStmtBatchForThread
(
pThreadInfo
,
stbInfo
,
timePrec
,
batch
);
}
static
int
parseNtbSampleToStmtBatchForThread
(
threadInfo
*
pThreadInfo
,
uint32_t
timePrec
,
uint32_t
batch
)
{
return
parseSampleToStmtBatchForThread
(
pThreadInfo
,
NULL
,
timePrec
,
batch
);
}
#else
static
int
parseSampleToStmt
(
threadInfo
*
pThreadInfo
,
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
{
pThreadInfo
->
sampleBindArray
=
calloc
(
1
,
sizeof
(
char
*
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
if
(
pThreadInfo
->
sampleBindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %"
PRIu64
" bind array buffer
\n
"
,
__func__
,
__LINE__
,
(
uint64_t
)
sizeof
(
char
*
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
return
-
1
;
}
int32_t
columnCount
=
(
stbInfo
)
?
stbInfo
->
columnCount
:
g_args
.
columnCount
;
char
*
sampleDataBuf
=
(
stbInfo
)
?
stbInfo
->
sampleDataBuf
:
g_sampleDataBuf
;
int64_t
lenOfOneRow
=
(
stbInfo
)
?
stbInfo
->
lenOfOneRow
:
g_args
.
lenOfOneRow
;
for
(
int
i
=
0
;
i
<
MAX_SAMPLES_ONCE_FROM_FILE
;
i
++
)
{
char
*
bindArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind params
\n
"
,
__func__
,
__LINE__
,
(
columnCount
+
1
));
return
-
1
;
}
TAOS_BIND
*
bind
;
int
cursor
=
0
;
for
(
int
c
=
0
;
c
<
columnCount
+
1
;
c
++
)
{
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
c
));
if
(
c
==
0
)
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
NULL
;
//bind_ts;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
{
char
data_type
=
(
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
data_type
:
g_args
.
data_type
[
c
-
1
];
int32_t
dataLen
=
(
stbInfo
)
?
stbInfo
->
columns
[
c
-
1
].
dataLen
:
g_args
.
binwidth
;
char
*
restStr
=
sampleDataBuf
+
lenOfOneRow
*
i
+
cursor
;
int
lengthOfRest
=
strlen
(
restStr
);
int
index
=
0
;
for
(
index
=
0
;
index
<
lengthOfRest
;
index
++
)
{
if
(
restStr
[
index
]
==
','
)
{
break
;
}
}
char
*
bindBuffer
=
calloc
(
1
,
index
+
1
);
if
(
bindBuffer
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
index
+
1
);
return
-
1
;
}
strncpy
(
bindBuffer
,
restStr
,
index
);
cursor
+=
index
+
1
;
// skip ',' too
if
(
-
1
==
prepareStmtBindArrayByType
(
bind
,
data_type
,
dataLen
,
timePrec
,
bindBuffer
))
{
free
(
bindBuffer
);
return
-
1
;
}
free
(
bindBuffer
);
}
}
*
((
uintptr_t
*
)(
pThreadInfo
->
sampleBindArray
+
(
sizeof
(
char
*
))
*
i
))
=
(
uintptr_t
)
bindArray
;
}
return
0
;
}
static
int
parseStbSampleToStmt
(
threadInfo
*
pThreadInfo
,
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
{
return
parseSampleToStmt
(
pThreadInfo
,
stbInfo
,
timePrec
);
}
static
int
parseNtbSampleToStmt
(
threadInfo
*
pThreadInfo
,
uint32_t
timePrec
)
{
return
parseSampleToStmt
(
pThreadInfo
,
NULL
,
timePrec
);
}
}
static
int32_t
prepareStbStmtBindStartTime
(
static
int32_t
prepareStbStmtBindStartTime
(
char
*
tableName
,
char
*
tableName
,
int64_t
*
ts
,
int64_t
*
ts
,
char
*
bindArray
,
SSuperTable
*
stbInfo
,
char
*
bindArray
,
SSuperTable
*
stbInfo
,
int64_t
startTime
,
int32_t
recSeq
,
int64_t
startTime
,
int32_t
recSeq
)
int32_t
timePrec
)
{
{
TAOS_BIND
*
bind
;
TAOS_BIND
*
bind
;
...
@@ -7108,95 +8237,37 @@ static int32_t prepareStbStmtBindStartTime(
...
@@ -7108,95 +8237,37 @@ static int32_t prepareStbStmtBindStartTime(
return
0
;
return
0
;
}
}
UNUSED_FUNC
static
int32_t
prepareStbStmtRand
(
static
uint32_t
execBindParam
(
threadInfo
*
pThreadInfo
,
threadInfo
*
pThreadInfo
,
char
*
tableName
,
char
*
tableName
,
int64_t
tableSeq
,
int64_t
tableSeq
,
uint32_t
batch
,
uint32_t
batch
,
uint64_t
insertRows
,
uint64_t
insertRows
,
uint64_t
recordFrom
,
uint64_t
recordFrom
,
int64_t
startTime
)
int64_t
startTime
,
int64_t
*
pSamplePos
)
{
{
int
ret
;
int
ret
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
char
*
tagsValBuf
=
NULL
;
if
(
0
==
stbInfo
->
tagSource
)
{
tagsValBuf
=
generateTagValuesForStb
(
stbInfo
,
tableSeq
);
}
else
{
tagsValBuf
=
getTagValueFromTagSample
(
stbInfo
,
tableSeq
%
stbInfo
->
tagSampleCount
);
}
if
(
NULL
==
tagsValBuf
)
{
errorPrint2
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
-
1
;
}
char
*
tagsArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
stbInfo
->
tagCount
);
if
(
NULL
==
tagsArray
)
{
tmfree
(
tagsValBuf
);
errorPrint2
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
__func__
,
__LINE__
);
return
-
1
;
}
if
(
-
1
==
prepareStbStmtBindTag
(
tagsArray
,
stbInfo
,
tagsValBuf
,
pThreadInfo
->
time_precision
/* is tag */
))
{
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
return
-
1
;
}
ret
=
taos_stmt_set_tbname_tags
(
stmt
,
tableName
,
(
TAOS_BIND
*
)
tagsArray
);
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_set_tbname_tags() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
}
else
{
ret
=
taos_stmt_set_tbname
(
stmt
,
tableName
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_set_tbname() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
}
char
*
bindArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
stbInfo
->
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind params
\n
"
,
__func__
,
__LINE__
,
(
stbInfo
->
columnCount
+
1
));
return
-
1
;
}
uint32_t
k
;
uint32_t
k
;
for
(
k
=
0
;
k
<
batch
;)
{
for
(
k
=
0
;
k
<
batch
;)
{
char
*
bindArray
=
(
char
*
)(
*
((
uintptr_t
*
)
(
pThreadInfo
->
sampleBindArray
+
(
sizeof
(
char
*
))
*
(
*
pSamplePos
))));
/* columnCount + 1 (ts) */
/* columnCount + 1 (ts) */
if
(
-
1
==
prepareStbStmtBindRand
(
if
(
-
1
==
prepareStbStmtBindStartTime
(
tableName
,
pThreadInfo
->
bind_ts
,
pThreadInfo
->
bind_ts
,
bindArray
,
stbInfo
,
bindArray
,
stbInfo
,
startTime
,
k
,
startTime
,
k
pThreadInfo
->
time_precision
/* is column */
))
{
/* is column */
))
{
free
(
bindArray
);
return
-
1
;
return
-
1
;
}
}
ret
=
taos_stmt_bind_param
(
stmt
,
(
TAOS_BIND
*
)
bindArray
);
ret
=
taos_stmt_bind_param
(
stmt
,
(
TAOS_BIND
*
)
bindArray
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_bind_param() failed! reason: %s
\n
"
,
errorPrint2
(
"%s() LN%d, stmt_bind_param() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
free
(
bindArray
);
return
-
1
;
return
-
1
;
}
}
// if msg > 3MB, break
// if msg > 3MB, break
...
@@ -7204,21 +8275,25 @@ UNUSED_FUNC static int32_t prepareStbStmtRand(
...
@@ -7204,21 +8275,25 @@ UNUSED_FUNC static int32_t prepareStbStmtRand(
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
errorPrint2
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
free
(
bindArray
);
return
-
1
;
return
-
1
;
}
}
k
++
;
k
++
;
recordFrom
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
pSamplePos
=
0
;
}
if
(
recordFrom
>=
insertRows
)
{
if
(
recordFrom
>=
insertRows
)
{
break
;
break
;
}
}
}
}
free
(
bindArray
);
return
k
;
return
k
;
}
}
#endif
static
int32_t
prepareStbStmtWithSample
(
static
int32_t
prepareStbStmtWithSample
(
threadInfo
*
pThreadInfo
,
threadInfo
*
pThreadInfo
,
...
@@ -7286,48 +8361,27 @@ static int32_t prepareStbStmtWithSample(
...
@@ -7286,48 +8361,27 @@ static int32_t prepareStbStmtWithSample(
}
}
}
}
uint32_t
k
;
#if STMT_BIND_PARAM_BATCH == 1
for
(
k
=
0
;
k
<
batch
;)
{
return
execBindParamBatch
(
char
*
bindArray
=
(
char
*
)(
*
((
uintptr_t
*
)
pThreadInfo
,
(
pThreadInfo
->
sampleBindArray
+
(
sizeof
(
char
*
))
*
(
*
pSamplePos
))));
tableName
,
/* columnCount + 1 (ts) */
tableSeq
,
if
(
-
1
==
prepareStbStmtBindStartTime
(
batch
,
tableName
,
insertRows
,
pThreadInfo
->
bind_ts
,
recordFrom
,
bindArray
,
stbInfo
,
startTime
,
startTime
,
k
,
pSamplePos
);
pThreadInfo
->
time_precision
#else
/* is column */
))
{
return
execBindParam
(
return
-
1
;
pThreadInfo
,
}
tableName
,
ret
=
taos_stmt_bind_param
(
stmt
,
(
TAOS_BIND
*
)
bindArray
);
tableSeq
,
if
(
0
!=
ret
)
{
batch
,
errorPrint2
(
"%s() LN%d, stmt_bind_param() failed! reason: %s
\n
"
,
insertRows
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
recordFrom
,
return
-
1
;
startTime
,
}
pSamplePos
);
// if msg > 3MB, break
#endif
ret
=
taos_stmt_add_batch
(
stmt
);
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
}
k
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
pSamplePos
=
0
;
}
if
(
recordFrom
>=
insertRows
)
{
break
;
}
}
return
k
;
}
}
static
int32_t
generateStbProgressiveData
(
static
int32_t
generateStbProgressiveData
(
...
@@ -7358,7 +8412,7 @@ static int32_t generateStbProgressiveData(
...
@@ -7358,7 +8412,7 @@ static int32_t generateStbProgressiveData(
int64_t
dataLen
;
int64_t
dataLen
;
return
generateStbDataTail
(
stbInfo
,
return
generateStbDataTail
(
stbInfo
,
g_args
.
num_of_RPR
,
pstr
,
*
pRemainderBufLen
,
g_args
.
reqPerReq
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
recordFrom
,
insertRows
,
recordFrom
,
startTime
,
startTime
,
pSamplePos
,
&
dataLen
);
pSamplePos
,
&
dataLen
);
...
@@ -7390,20 +8444,22 @@ static int32_t generateProgressiveDataWithoutStb(
...
@@ -7390,20 +8444,22 @@ static int32_t generateProgressiveDataWithoutStb(
int64_t
dataLen
;
int64_t
dataLen
;
return
generateDataTailWithoutStb
(
return
generateDataTailWithoutStb
(
g_args
.
num_of_RPR
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
recordFrom
,
g_args
.
reqPerReq
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
recordFrom
,
startTime
,
startTime
,
/*pSamplePos, */
&
dataLen
);
/*pSamplePos, */
&
dataLen
);
}
}
static
void
printStatPerThread
(
threadInfo
*
pThreadInfo
)
static
void
printStatPerThread
(
threadInfo
*
pThreadInfo
)
{
{
if
(
0
==
pThreadInfo
->
totalDelay
)
pThreadInfo
->
totalDelay
=
1
;
fprintf
(
stderr
,
"====thread[%d] completed total inserted rows: %"
PRIu64
", total affected rows: %"
PRIu64
". %.2f records/second====
\n
"
,
fprintf
(
stderr
,
"====thread[%d] completed total inserted rows: %"
PRIu64
", total affected rows: %"
PRIu64
". %.2f records/second====
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
threadID
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
totalAffectedRows
,
pThreadInfo
->
totalAffectedRows
,
(
pThreadInfo
->
totalDelay
)
?
(
double
)(
pThreadInfo
->
totalAffectedRows
/
((
double
)
pThreadInfo
->
totalDelay
/
1000000
.
0
))
(
double
)(
pThreadInfo
->
totalAffectedRows
/
((
double
)
pThreadInfo
->
totalDelay
/
1000000
.
0
))
:
);
FLT_MAX
);
}
}
// sync write interlace data
// sync write interlace data
...
@@ -7432,7 +8488,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7432,7 +8488,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
nTimeStampStep
=
stbInfo
->
timeStampStep
;
nTimeStampStep
=
stbInfo
->
timeStampStep
;
insert_interval
=
stbInfo
->
insertInterval
;
insert_interval
=
stbInfo
->
insertInterval
;
}
else
{
}
else
{
insertRows
=
g_args
.
num_of_DPT
;
insertRows
=
g_args
.
insertRows
;
interlaceRows
=
g_args
.
interlace_rows
;
interlaceRows
=
g_args
.
interlace_rows
;
maxSqlLen
=
g_args
.
max_sql_len
;
maxSqlLen
=
g_args
.
max_sql_len
;
nTimeStampStep
=
g_args
.
timestamp_step
;
nTimeStampStep
=
g_args
.
timestamp_step
;
...
@@ -7447,15 +8503,15 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7447,15 +8503,15 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
if
(
interlaceRows
>
insertRows
)
if
(
interlaceRows
>
insertRows
)
interlaceRows
=
insertRows
;
interlaceRows
=
insertRows
;
if
(
interlaceRows
>
g_args
.
num_of_RPR
)
if
(
interlaceRows
>
g_args
.
reqPerReq
)
interlaceRows
=
g_args
.
num_of_RPR
;
interlaceRows
=
g_args
.
reqPerReq
;
uint32_t
batchPerTbl
=
interlaceRows
;
uint32_t
batchPerTbl
=
interlaceRows
;
uint32_t
batchPerTblTimes
;
uint32_t
batchPerTblTimes
;
if
((
interlaceRows
>
0
)
&&
(
pThreadInfo
->
ntables
>
1
))
{
if
((
interlaceRows
>
0
)
&&
(
pThreadInfo
->
ntables
>
1
))
{
batchPerTblTimes
=
batchPerTblTimes
=
g_args
.
num_of_RPR
/
interlaceRows
;
g_args
.
reqPerReq
/
interlaceRows
;
}
else
{
}
else
{
batchPerTblTimes
=
1
;
batchPerTblTimes
=
1
;
}
}
...
@@ -7505,6 +8561,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7505,6 +8561,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
uint32_t
recOfBatch
=
0
;
uint32_t
recOfBatch
=
0
;
int32_t
generated
;
for
(
uint64_t
i
=
0
;
i
<
batchPerTblTimes
;
i
++
)
{
for
(
uint64_t
i
=
0
;
i
<
batchPerTblTimes
;
i
++
)
{
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
...
@@ -7518,7 +8575,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7518,7 +8575,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
uint64_t
oldRemainderLen
=
remainderBufLen
;
uint64_t
oldRemainderLen
=
remainderBufLen
;
int32_t
generated
;
if
(
stbInfo
)
{
if
(
stbInfo
)
{
if
(
stbInfo
->
iface
==
STMT_IFACE
)
{
if
(
stbInfo
->
iface
==
STMT_IFACE
)
{
generated
=
prepareStbStmtWithSample
(
generated
=
prepareStbStmtWithSample
(
...
@@ -7599,7 +8655,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7599,7 +8655,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
if
((
remainRows
>
0
)
&&
(
batchPerTbl
>
remainRows
))
if
((
remainRows
>
0
)
&&
(
batchPerTbl
>
remainRows
))
batchPerTbl
=
remainRows
;
batchPerTbl
=
remainRows
;
if
(
pThreadInfo
->
ntables
*
batchPerTbl
<
g_args
.
num_of_RPR
)
if
(
pThreadInfo
->
ntables
*
batchPerTbl
<
g_args
.
reqPerReq
)
break
;
break
;
}
}
...
@@ -7607,7 +8663,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -7607,7 +8663,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
generatedRecPerTbl
,
insertRows
);
generatedRecPerTbl
,
insertRows
);
if
((
g_args
.
num_of_RPR
-
recOfBatch
)
<
batchPerTbl
)
if
((
g_args
.
reqPerReq
-
recOfBatch
)
<
batchPerTbl
)
break
;
break
;
}
}
...
@@ -7699,7 +8755,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -7699,7 +8755,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
int64_t
timeStampStep
=
int64_t
timeStampStep
=
stbInfo
?
stbInfo
->
timeStampStep
:
g_args
.
timestamp_step
;
stbInfo
?
stbInfo
->
timeStampStep
:
g_args
.
timestamp_step
;
int64_t
insertRows
=
int64_t
insertRows
=
(
stbInfo
)
?
stbInfo
->
insertRows
:
g_args
.
num_of_DPT
;
(
stbInfo
)
?
stbInfo
->
insertRows
:
g_args
.
insertRows
;
verbosePrint
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
verbosePrint
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
insertRows
);
__func__
,
__LINE__
,
insertRows
);
...
@@ -7760,7 +8816,9 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -7760,7 +8816,9 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
pThreadInfo
,
pThreadInfo
,
tableName
,
tableName
,
tableSeq
,
tableSeq
,
g_args
.
num_of_RPR
,
(
g_args
.
reqPerReq
>
stbInfo
->
insertRows
)
?
stbInfo
->
insertRows
:
g_args
.
reqPerReq
,
insertRows
,
i
,
start_time
,
insertRows
,
i
,
start_time
,
&
(
pThreadInfo
->
samplePos
));
&
(
pThreadInfo
->
samplePos
));
}
else
{
}
else
{
...
@@ -7777,7 +8835,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -7777,7 +8835,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
generated
=
prepareStmtWithoutStb
(
generated
=
prepareStmtWithoutStb
(
pThreadInfo
,
pThreadInfo
,
tableName
,
tableName
,
g_args
.
num_of_RPR
,
g_args
.
reqPerReq
,
insertRows
,
i
,
insertRows
,
i
,
start_time
);
start_time
);
}
else
{
}
else
{
...
@@ -7845,7 +8903,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -7845,7 +8903,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
if
(
i
>=
insertRows
)
if
(
i
>=
insertRows
)
break
;
break
;
}
//
num_of_DPT
}
//
insertRows
if
((
g_args
.
verbose_print
)
&&
if
((
g_args
.
verbose_print
)
&&
(
tableSeq
==
pThreadInfo
->
ntables
-
1
)
&&
(
stbInfo
)
(
tableSeq
==
pThreadInfo
->
ntables
-
1
)
&&
(
stbInfo
)
...
@@ -7856,8 +8914,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -7856,8 +8914,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
__func__
,
__LINE__
,
pThreadInfo
->
samplePos
);
__func__
,
__LINE__
,
pThreadInfo
->
samplePos
);
}
}
}
// tableSeq
}
// tableSeq
if
(
percentComplete
<
100
)
if
(
percentComplete
<
100
)
{
printf
(
"[%d]:%d%%
\n
"
,
pThreadInfo
->
threadID
,
percentComplete
);
printf
(
"[%d]:%d%%
\n
"
,
pThreadInfo
->
threadID
,
percentComplete
);
}
free_of_progressive:
free_of_progressive:
tmfree
(
pThreadInfo
->
buffer
);
tmfree
(
pThreadInfo
->
buffer
);
...
@@ -7910,11 +8970,11 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -7910,11 +8970,11 @@ static void callBack(void *param, TAOS_RES *res, int code) {
char
*
buffer
=
calloc
(
1
,
pThreadInfo
->
stbInfo
->
maxSqlLen
);
char
*
buffer
=
calloc
(
1
,
pThreadInfo
->
stbInfo
->
maxSqlLen
);
char
data
[
MAX_DATA_SIZE
];
char
data
[
MAX_DATA_SIZE
];
char
*
pstr
=
buffer
;
char
*
pstr
=
buffer
;
pstr
+=
sprintf
(
pstr
,
"
insert into %s.%s%"
PRId64
" values
"
,
pstr
+=
sprintf
(
pstr
,
"
INSERT INTO %s.%s%"
PRId64
" VALUES
"
,
pThreadInfo
->
db_name
,
pThreadInfo
->
tb_prefix
,
pThreadInfo
->
db_name
,
pThreadInfo
->
tb_prefix
,
pThreadInfo
->
start_table_from
);
pThreadInfo
->
start_table_from
);
// if (pThreadInfo->counter >= pThreadInfo->stbInfo->insertRows) {
// if (pThreadInfo->counter >= pThreadInfo->stbInfo->insertRows) {
if
(
pThreadInfo
->
counter
>=
g_args
.
num_of_RPR
)
{
if
(
pThreadInfo
->
counter
>=
g_args
.
reqPerReq
)
{
pThreadInfo
->
start_table_from
++
;
pThreadInfo
->
start_table_from
++
;
pThreadInfo
->
counter
=
0
;
pThreadInfo
->
counter
=
0
;
}
}
...
@@ -7925,7 +8985,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -7925,7 +8985,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
return
;
return
;
}
}
for
(
int
i
=
0
;
i
<
g_args
.
num_of_RPR
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_args
.
reqPerReq
;
i
++
)
{
int
rand_num
=
taosRandom
()
%
100
;
int
rand_num
=
taosRandom
()
%
100
;
if
(
0
!=
pThreadInfo
->
stbInfo
->
disorderRatio
if
(
0
!=
pThreadInfo
->
stbInfo
->
disorderRatio
&&
rand_num
<
pThreadInfo
->
stbInfo
->
disorderRatio
)
{
&&
rand_num
<
pThreadInfo
->
stbInfo
->
disorderRatio
)
{
...
@@ -8005,81 +9065,6 @@ static int convertHostToServAddr(char *host, uint16_t port, struct sockaddr_in *
...
@@ -8005,81 +9065,6 @@ static int convertHostToServAddr(char *host, uint16_t port, struct sockaddr_in *
return
0
;
return
0
;
}
}
static
int
parseSampleFileToStmt
(
threadInfo
*
pThreadInfo
,
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
{
pThreadInfo
->
sampleBindArray
=
calloc
(
1
,
sizeof
(
char
*
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
if
(
pThreadInfo
->
sampleBindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %"
PRIu64
" bind array buffer
\n
"
,
__func__
,
__LINE__
,
(
uint64_t
)
sizeof
(
char
*
)
*
MAX_SAMPLES_ONCE_FROM_FILE
);
return
-
1
;
}
for
(
int
i
=
0
;
i
<
MAX_SAMPLES_ONCE_FROM_FILE
;
i
++
)
{
char
*
bindArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
(
stbInfo
->
columnCount
+
1
));
if
(
bindArray
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind params
\n
"
,
__func__
,
__LINE__
,
(
stbInfo
->
columnCount
+
1
));
return
-
1
;
}
TAOS_BIND
*
bind
;
int
cursor
=
0
;
for
(
int
c
=
0
;
c
<
stbInfo
->
columnCount
+
1
;
c
++
)
{
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
c
));
if
(
c
==
0
)
{
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
NULL
;
//bind_ts;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
}
else
{
char
*
restStr
=
stbInfo
->
sampleDataBuf
+
stbInfo
->
lenOfOneRow
*
i
+
cursor
;
int
lengthOfRest
=
strlen
(
restStr
);
int
index
=
0
;
for
(
index
=
0
;
index
<
lengthOfRest
;
index
++
)
{
if
(
restStr
[
index
]
==
','
)
{
break
;
}
}
char
*
bindBuffer
=
calloc
(
1
,
index
+
1
);
if
(
bindBuffer
==
NULL
)
{
errorPrint2
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
DOUBLE_BUFF_LEN
);
return
-
1
;
}
strncpy
(
bindBuffer
,
restStr
,
index
);
cursor
+=
index
+
1
;
// skip ',' too
if
(
-
1
==
prepareStmtBindArrayByType
(
bind
,
stbInfo
->
columns
[
c
-
1
].
dataType
,
stbInfo
->
columns
[
c
-
1
].
dataLen
,
timePrec
,
bindBuffer
))
{
free
(
bindBuffer
);
return
-
1
;
}
free
(
bindBuffer
);
}
}
*
((
uintptr_t
*
)(
pThreadInfo
->
sampleBindArray
+
(
sizeof
(
char
*
))
*
i
))
=
(
uintptr_t
)
bindArray
;
}
return
0
;
}
static
void
startMultiThreadInsertData
(
int
threads
,
char
*
db_name
,
static
void
startMultiThreadInsertData
(
int
threads
,
char
*
db_name
,
char
*
precision
,
SSuperTable
*
stbInfo
)
{
char
*
precision
,
SSuperTable
*
stbInfo
)
{
...
@@ -8117,12 +9102,17 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8117,12 +9102,17 @@ static void startMultiThreadInsertData(int threads, char* db_name,
__func__
,
__LINE__
,
start_time
);
__func__
,
__LINE__
,
start_time
);
// read sample data from file first
// read sample data from file first
int
ret
;
if
(
stbInfo
)
{
if
(
stbInfo
)
{
if
(
0
!=
prepareSampleDataForSTable
(
stbInfo
))
{
ret
=
prepareSampleForStb
(
stbInfo
);
errorPrint2
(
"%s() LN%d, prepare sample data for stable failed!
\n
"
,
}
else
{
__func__
,
__LINE__
);
ret
=
prepareSampleForNtb
();
exit
(
EXIT_FAILURE
);
}
}
if
(
0
!=
ret
)
{
errorPrint2
(
"%s() LN%d, prepare sample data for stable failed!
\n
"
,
__func__
,
__LINE__
);
exit
(
EXIT_FAILURE
);
}
}
TAOS
*
taos0
=
taos_connect
(
TAOS
*
taos0
=
taos_connect
(
...
@@ -8153,6 +9143,12 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8153,6 +9143,12 @@ static void startMultiThreadInsertData(int threads, char* db_name,
||
((
stbInfo
->
childTblOffset
||
((
stbInfo
->
childTblOffset
+
stbInfo
->
childTblLimit
)
+
stbInfo
->
childTblLimit
)
>
(
stbInfo
->
childTblCount
)))
{
>
(
stbInfo
->
childTblCount
)))
{
if
(
stbInfo
->
childTblCount
<
stbInfo
->
childTblOffset
)
{
printf
(
"WARNING: offset will not be used since the child tables count is less then offset!
\n
"
);
stbInfo
->
childTblOffset
=
0
;
}
stbInfo
->
childTblLimit
=
stbInfo
->
childTblLimit
=
stbInfo
->
childTblCount
-
stbInfo
->
childTblOffset
;
stbInfo
->
childTblCount
-
stbInfo
->
childTblOffset
;
}
}
...
@@ -8191,12 +9187,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8191,12 +9187,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t
childTblCount
;
int64_t
childTblCount
;
getChildNameOfSuperTableWithLimitAndOffset
(
getChildNameOfSuperTableWithLimitAndOffset
(
taos0
,
taos0
,
db_name
,
stbInfo
->
s
Tbl
Name
,
db_name
,
stbInfo
->
s
tb
Name
,
&
stbInfo
->
childTblName
,
&
childTblCount
,
&
stbInfo
->
childTblName
,
&
childTblCount
,
limit
,
limit
,
offset
);
offset
);
ntables
=
childTblCount
;
// CBD
}
else
{
}
else
{
ntables
=
g_args
.
n
um_of_
tables
;
ntables
=
g_args
.
ntables
;
tableFrom
=
0
;
tableFrom
=
0
;
}
}
...
@@ -8232,6 +9229,35 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8232,6 +9229,35 @@ static void startMultiThreadInsertData(int threads, char* db_name,
char
*
stmtBuffer
=
calloc
(
1
,
BUFFER_SIZE
);
char
*
stmtBuffer
=
calloc
(
1
,
BUFFER_SIZE
);
assert
(
stmtBuffer
);
assert
(
stmtBuffer
);
#if STMT_BIND_PARAM_BATCH == 1
uint32_t
interlaceRows
;
uint32_t
batch
;
if
(
stbInfo
)
{
if
((
stbInfo
->
interlaceRows
==
0
)
&&
(
g_args
.
interlace_rows
>
0
))
{
interlaceRows
=
g_args
.
interlace_rows
;
if
(
interlaceRows
>
stbInfo
->
insertRows
)
{
interlaceRows
=
stbInfo
->
insertRows
;
}
}
else
{
interlaceRows
=
stbInfo
->
interlaceRows
;
}
}
else
{
interlaceRows
=
g_args
.
interlace_rows
;
}
if
(
interlaceRows
>
0
)
{
batch
=
interlaceRows
;
}
else
{
batch
=
(
g_args
.
reqPerReq
>
g_args
.
insertRows
)
?
g_args
.
insertRows
:
g_args
.
reqPerReq
;
}
#endif
if
((
g_args
.
iface
==
STMT_IFACE
)
if
((
g_args
.
iface
==
STMT_IFACE
)
||
((
stbInfo
)
||
((
stbInfo
)
&&
(
stbInfo
->
iface
==
STMT_IFACE
)))
{
&&
(
stbInfo
->
iface
==
STMT_IFACE
)))
{
...
@@ -8241,7 +9267,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8241,7 +9267,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&&
(
AUTO_CREATE_SUBTBL
&&
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
))
{
==
stbInfo
->
autoCreateTable
))
{
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? USING %s TAGS(?"
,
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? USING %s TAGS(?"
,
stbInfo
->
s
Tbl
Name
);
stbInfo
->
s
tb
Name
);
for
(
int
tag
=
0
;
tag
<
(
stbInfo
->
tagCount
-
1
);
for
(
int
tag
=
0
;
tag
<
(
stbInfo
->
tagCount
-
1
);
tag
++
)
{
tag
++
)
{
pstr
+=
sprintf
(
pstr
,
",?"
);
pstr
+=
sprintf
(
pstr
,
",?"
);
...
@@ -8251,12 +9277,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8251,12 +9277,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? VALUES(?"
);
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? VALUES(?"
);
}
}
int
columnCount
;
int
columnCount
=
(
stbInfo
)
?
if
(
stbInfo
)
{
stbInfo
->
columnCount
:
columnCount
=
stbInfo
->
columnCount
;
g_args
.
columnCount
;
}
else
{
columnCount
=
g_args
.
num_of_CPR
;
}
for
(
int
col
=
0
;
col
<
columnCount
;
col
++
)
{
for
(
int
col
=
0
;
col
<
columnCount
;
col
++
)
{
pstr
+=
sprintf
(
pstr
,
",?"
);
pstr
+=
sprintf
(
pstr
,
",?"
);
...
@@ -8264,6 +9287,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8264,6 +9287,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
pstr
+=
sprintf
(
pstr
,
")"
);
pstr
+=
sprintf
(
pstr
,
")"
);
debugPrint
(
"%s() LN%d, stmtBuffer: %s"
,
__func__
,
__LINE__
,
stmtBuffer
);
debugPrint
(
"%s() LN%d, stmtBuffer: %s"
,
__func__
,
__LINE__
,
stmtBuffer
);
#if STMT_BIND_PARAM_BATCH == 1
parseSamplefileToStmtBatch
(
stbInfo
);
#endif
}
}
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
...
@@ -8307,8 +9333,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8307,8 +9333,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int
ret
=
taos_stmt_prepare
(
pThreadInfo
->
stmt
,
stmtBuffer
,
0
);
if
(
0
!=
taos_stmt_prepare
(
pThreadInfo
->
stmt
,
stmtBuffer
,
0
))
{
if
(
ret
!=
0
)
{
free
(
pids
);
free
(
pids
);
free
(
infos
);
free
(
infos
);
free
(
stmtBuffer
);
free
(
stmtBuffer
);
...
@@ -8319,7 +9344,19 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8319,7 +9344,19 @@ static void startMultiThreadInsertData(int threads, char* db_name,
pThreadInfo
->
bind_ts
=
malloc
(
sizeof
(
int64_t
));
pThreadInfo
->
bind_ts
=
malloc
(
sizeof
(
int64_t
));
if
(
stbInfo
)
{
if
(
stbInfo
)
{
parseSampleFileToStmt
(
pThreadInfo
,
stbInfo
,
timePrec
);
#if STMT_BIND_PARAM_BATCH == 1
parseStbSampleToStmtBatchForThread
(
pThreadInfo
,
stbInfo
,
timePrec
,
batch
);
#else
parseStbSampleToStmt
(
pThreadInfo
,
stbInfo
,
timePrec
);
#endif
}
else
{
#if STMT_BIND_PARAM_BATCH == 1
parseNtbSampleToStmtBatchForThread
(
pThreadInfo
,
timePrec
,
batch
);
#else
parseNtbSampleToStmt
(
pThreadInfo
,
timePrec
);
#endif
}
}
}
}
}
else
{
}
else
{
...
@@ -8364,19 +9401,29 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8364,19 +9401,29 @@ static void startMultiThreadInsertData(int threads, char* db_name,
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
threadInfo
*
pThreadInfo
=
infos
+
i
;
threadInfo
*
pThreadInfo
=
infos
+
i
;
tsem_destroy
(
&
(
pThreadInfo
->
lock_sem
));
taos_close
(
pThreadInfo
->
taos
);
if
(
pThreadInfo
->
stmt
)
{
if
(
pThreadInfo
->
stmt
)
{
taos_stmt_close
(
pThreadInfo
->
stmt
);
taos_stmt_close
(
pThreadInfo
->
stmt
);
tmfree
((
char
*
)
pThreadInfo
->
bind_ts
);
}
}
tsem_destroy
(
&
(
pThreadInfo
->
lock_sem
));
taos_close
(
pThreadInfo
->
taos
);
#if STMT_BIND_PARAM_BATCH == 1
tmfree
((
char
*
)
pThreadInfo
->
bind_ts
);
tmfree
((
char
*
)
pThreadInfo
->
bind_ts_array
);
tmfree
(
pThreadInfo
->
bindParams
);
tmfree
(
pThreadInfo
->
is_null
);
#else
tmfree
((
char
*
)
pThreadInfo
->
bind_ts
);
if
(
pThreadInfo
->
sampleBindArray
)
{
if
(
pThreadInfo
->
sampleBindArray
)
{
for
(
int
k
=
0
;
k
<
MAX_SAMPLES_ONCE_FROM_FILE
;
k
++
)
{
for
(
int
k
=
0
;
k
<
MAX_SAMPLES_ONCE_FROM_FILE
;
k
++
)
{
uintptr_t
*
tmp
=
(
uintptr_t
*
)(
*
(
uintptr_t
*
)(
uintptr_t
*
tmp
=
(
uintptr_t
*
)(
*
(
uintptr_t
*
)(
pThreadInfo
->
sampleBindArray
pThreadInfo
->
sampleBindArray
+
sizeof
(
uintptr_t
*
)
*
k
));
+
sizeof
(
uintptr_t
*
)
*
k
));
for
(
int
c
=
1
;
c
<
pThreadInfo
->
stbInfo
->
columnCount
+
1
;
c
++
)
{
int
columnCount
=
(
pThreadInfo
->
stbInfo
)
?
pThreadInfo
->
stbInfo
->
columnCount
:
g_args
.
columnCount
;
for
(
int
c
=
1
;
c
<
columnCount
+
1
;
c
++
)
{
TAOS_BIND
*
bind
=
(
TAOS_BIND
*
)((
char
*
)
tmp
+
(
sizeof
(
TAOS_BIND
)
*
c
));
TAOS_BIND
*
bind
=
(
TAOS_BIND
*
)((
char
*
)
tmp
+
(
sizeof
(
TAOS_BIND
)
*
c
));
if
(
bind
)
if
(
bind
)
tmfree
(
bind
->
buffer
);
tmfree
(
bind
->
buffer
);
...
@@ -8385,6 +9432,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8385,6 +9432,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
}
tmfree
(
pThreadInfo
->
sampleBindArray
);
tmfree
(
pThreadInfo
->
sampleBindArray
);
}
}
#endif
debugPrint
(
"%s() LN%d, [%d] totalInsert=%"
PRIu64
" totalAffected=%"
PRIu64
"
\n
"
,
debugPrint
(
"%s() LN%d, [%d] totalInsert=%"
PRIu64
" totalAffected=%"
PRIu64
"
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
...
@@ -8403,7 +9451,6 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8403,7 +9451,6 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if
(
pThreadInfo
->
maxDelay
>
maxDelay
)
maxDelay
=
pThreadInfo
->
maxDelay
;
if
(
pThreadInfo
->
maxDelay
>
maxDelay
)
maxDelay
=
pThreadInfo
->
maxDelay
;
if
(
pThreadInfo
->
minDelay
<
minDelay
)
minDelay
=
pThreadInfo
->
minDelay
;
if
(
pThreadInfo
->
minDelay
<
minDelay
)
minDelay
=
pThreadInfo
->
minDelay
;
}
}
cntDelay
-=
1
;
if
(
cntDelay
==
0
)
cntDelay
=
1
;
if
(
cntDelay
==
0
)
cntDelay
=
1
;
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
...
@@ -8418,7 +9465,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8418,7 +9465,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
fprintf
(
stderr
,
"Spent %.4f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
fprintf
(
stderr
,
"Spent %.4f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
tInMs
,
stbInfo
->
totalInsertRows
,
tInMs
,
stbInfo
->
totalInsertRows
,
stbInfo
->
totalAffectedRows
,
stbInfo
->
totalAffectedRows
,
threads
,
db_name
,
stbInfo
->
s
Tbl
Name
,
threads
,
db_name
,
stbInfo
->
s
tb
Name
,
(
double
)(
stbInfo
->
totalInsertRows
/
tInMs
));
(
double
)(
stbInfo
->
totalInsertRows
/
tInMs
));
if
(
g_fpOfInsertResult
)
{
if
(
g_fpOfInsertResult
)
{
...
@@ -8426,7 +9473,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -8426,7 +9473,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
"Spent %.4f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
"Spent %.4f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
tInMs
,
stbInfo
->
totalInsertRows
,
tInMs
,
stbInfo
->
totalInsertRows
,
stbInfo
->
totalAffectedRows
,
stbInfo
->
totalAffectedRows
,
threads
,
db_name
,
stbInfo
->
s
Tbl
Name
,
threads
,
db_name
,
stbInfo
->
s
tb
Name
,
(
double
)(
stbInfo
->
totalInsertRows
/
tInMs
));
(
double
)(
stbInfo
->
totalInsertRows
/
tInMs
));
}
}
}
else
{
}
else
{
...
@@ -8479,16 +9526,16 @@ static void *readTable(void *sarg) {
...
@@ -8479,16 +9526,16 @@ static void *readTable(void *sarg) {
return
NULL
;
return
NULL
;
}
}
int64_t
num_of_DPT
;
int64_t
insertRows
;
/* if (pThreadInfo->stbInfo) {
/* if (pThreadInfo->stbInfo) {
num_of_DPT
= pThreadInfo->stbInfo->insertRows; // nrecords_per_table;
insertRows
= pThreadInfo->stbInfo->insertRows; // nrecords_per_table;
} else {
} else {
*/
*/
num_of_DPT
=
g_args
.
num_of_DPT
;
insertRows
=
g_args
.
insertRows
;
// }
// }
int64_t
n
um_of_
tables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
ntables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
totalData
=
num_of_DPT
*
num_of_
tables
;
int64_t
totalData
=
insertRows
*
n
tables
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
int
n
=
do_aggreFunc
?
(
sizeof
(
g_aggreFunc
)
/
sizeof
(
g_aggreFunc
[
0
]))
:
2
;
int
n
=
do_aggreFunc
?
(
sizeof
(
g_aggreFunc
)
/
sizeof
(
g_aggreFunc
[
0
]))
:
2
;
...
@@ -8501,8 +9548,8 @@ static void *readTable(void *sarg) {
...
@@ -8501,8 +9548,8 @@ static void *readTable(void *sarg) {
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
double
totalT
=
0
;
double
totalT
=
0
;
uint64_t
count
=
0
;
uint64_t
count
=
0
;
for
(
int64_t
i
=
0
;
i
<
n
um_of_
tables
;
i
++
)
{
for
(
int64_t
i
=
0
;
i
<
ntables
;
i
++
)
{
sprintf
(
command
,
"
select %s from %s%"
PRId64
" where
ts>= %"
PRIu64
,
sprintf
(
command
,
"
SELECT %s FROM %s%"
PRId64
" WHERE
ts>= %"
PRIu64
,
g_aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
g_aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
double
t
=
taosGetTimestampMs
();
double
t
=
taosGetTimestampMs
();
...
@@ -8530,7 +9577,7 @@ static void *readTable(void *sarg) {
...
@@ -8530,7 +9577,7 @@ static void *readTable(void *sarg) {
fprintf
(
fp
,
"|%10s | %"
PRId64
" | %12.2f | %10.2f |
\n
"
,
fprintf
(
fp
,
"|%10s | %"
PRId64
" | %12.2f | %10.2f |
\n
"
,
g_aggreFunc
[
j
][
0
]
==
'*'
?
" * "
:
g_aggreFunc
[
j
],
totalData
,
g_aggreFunc
[
j
][
0
]
==
'*'
?
" * "
:
g_aggreFunc
[
j
],
totalData
,
(
double
)(
n
um_of_tables
*
num_of_DPT
)
/
totalT
,
totalT
*
1000
);
(
double
)(
n
tables
*
insertRows
)
/
totalT
,
totalT
*
1000
);
printf
(
"select %10s took %.6f second(s)
\n
"
,
g_aggreFunc
[
j
],
totalT
*
1000
);
printf
(
"select %10s took %.6f second(s)
\n
"
,
g_aggreFunc
[
j
],
totalT
*
1000
);
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
...
@@ -8555,9 +9602,9 @@ static void *readMetric(void *sarg) {
...
@@ -8555,9 +9602,9 @@ static void *readMetric(void *sarg) {
return
NULL
;
return
NULL
;
}
}
int64_t
num_of_DPT
=
pThreadInfo
->
stbInfo
->
insertRows
;
int64_t
insertRows
=
pThreadInfo
->
stbInfo
->
insertRows
;
int64_t
n
um_of_
tables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
ntables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
totalData
=
num_of_DPT
*
num_of_
tables
;
int64_t
totalData
=
insertRows
*
n
tables
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
int
n
=
do_aggreFunc
?
(
sizeof
(
g_aggreFunc
)
/
sizeof
(
g_aggreFunc
[
0
]))
:
2
;
int
n
=
do_aggreFunc
?
(
sizeof
(
g_aggreFunc
)
/
sizeof
(
g_aggreFunc
[
0
]))
:
2
;
...
@@ -8571,7 +9618,7 @@ static void *readMetric(void *sarg) {
...
@@ -8571,7 +9618,7 @@ static void *readMetric(void *sarg) {
char
condition
[
COND_BUF_LEN
]
=
"
\0
"
;
char
condition
[
COND_BUF_LEN
]
=
"
\0
"
;
char
tempS
[
64
]
=
"
\0
"
;
char
tempS
[
64
]
=
"
\0
"
;
int64_t
m
=
10
<
n
um_of_tables
?
10
:
num_of_
tables
;
int64_t
m
=
10
<
n
tables
?
10
:
n
tables
;
for
(
int64_t
i
=
1
;
i
<=
m
;
i
++
)
{
for
(
int64_t
i
=
1
;
i
<=
m
;
i
++
)
{
if
(
i
==
1
)
{
if
(
i
==
1
)
{
...
@@ -8581,7 +9628,7 @@ static void *readMetric(void *sarg) {
...
@@ -8581,7 +9628,7 @@ static void *readMetric(void *sarg) {
}
}
strncat
(
condition
,
tempS
,
COND_BUF_LEN
-
1
);
strncat
(
condition
,
tempS
,
COND_BUF_LEN
-
1
);
sprintf
(
command
,
"
select %s from meters where
%s"
,
g_aggreFunc
[
j
],
condition
);
sprintf
(
command
,
"
SELECT %s FROM meters WHERE
%s"
,
g_aggreFunc
[
j
],
condition
);
printf
(
"Where condition: %s
\n
"
,
condition
);
printf
(
"Where condition: %s
\n
"
,
condition
);
fprintf
(
fp
,
"%s
\n
"
,
command
);
fprintf
(
fp
,
"%s
\n
"
,
command
);
...
@@ -8606,7 +9653,7 @@ static void *readMetric(void *sarg) {
...
@@ -8606,7 +9653,7 @@ static void *readMetric(void *sarg) {
t
=
taosGetTimestampMs
()
-
t
;
t
=
taosGetTimestampMs
()
-
t
;
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
n
um_of_tables
*
num_of_DPT
/
(
t
*
1000
.
0
),
t
);
n
tables
*
insertRows
/
(
t
*
1000
.
0
),
t
);
printf
(
"select %10s took %.6f second(s)
\n\n
"
,
g_aggreFunc
[
j
],
t
*
1000
.
0
);
printf
(
"select %10s took %.6f second(s)
\n\n
"
,
g_aggreFunc
[
j
],
t
*
1000
.
0
);
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
...
@@ -8806,7 +9853,7 @@ static void *specifiedTableQuery(void *sarg) {
...
@@ -8806,7 +9853,7 @@ static void *specifiedTableQuery(void *sarg) {
uint64_t
currentPrintTime
=
taosGetTimestampMs
();
uint64_t
currentPrintTime
=
taosGetTimestampMs
();
uint64_t
endTs
=
taosGetTimestampMs
();
uint64_t
endTs
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
debugPrint
(
"%s() LN%d, endTs=%"
PRIu64
"
ms, startTs=%"
PRIu64
"
ms
\n
"
,
debugPrint
(
"%s() LN%d, endTs=%"
PRIu64
"
ms, startTs=%"
PRIu64
"
ms
\n
"
,
__func__
,
__LINE__
,
endTs
,
startTs
);
__func__
,
__LINE__
,
endTs
,
startTs
);
printf
(
"thread[%d] has currently completed queries: %"
PRIu64
", QPS: %10.6f
\n
"
,
printf
(
"thread[%d] has currently completed queries: %"
PRIu64
", QPS: %10.6f
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
threadID
,
...
@@ -8939,7 +9986,7 @@ static int queryTestProcess() {
...
@@ -8939,7 +9986,7 @@ static int queryTestProcess() {
if
(
0
!=
g_queryInfo
.
superQueryInfo
.
sqlCount
)
{
if
(
0
!=
g_queryInfo
.
superQueryInfo
.
sqlCount
)
{
getAllChildNameOfSuperTable
(
taos
,
getAllChildNameOfSuperTable
(
taos
,
g_queryInfo
.
dbName
,
g_queryInfo
.
dbName
,
g_queryInfo
.
superQueryInfo
.
s
Tbl
Name
,
g_queryInfo
.
superQueryInfo
.
s
tb
Name
,
&
g_queryInfo
.
superQueryInfo
.
childTblName
,
&
g_queryInfo
.
superQueryInfo
.
childTblName
,
&
g_queryInfo
.
superQueryInfo
.
childTblCount
);
&
g_queryInfo
.
superQueryInfo
.
childTblCount
);
}
}
...
@@ -8995,7 +10042,7 @@ static int queryTestProcess() {
...
@@ -8995,7 +10042,7 @@ static int queryTestProcess() {
}
}
}
}
pThreadInfo
->
taos
=
NULL
;
//
TODO:
workaround to use separate taos connection;
pThreadInfo
->
taos
=
NULL
;
// workaround to use separate taos connection;
pthread_create
(
pids
+
seq
,
NULL
,
specifiedTableQuery
,
pthread_create
(
pids
+
seq
,
NULL
,
specifiedTableQuery
,
pThreadInfo
);
pThreadInfo
);
...
@@ -9045,7 +10092,7 @@ static int queryTestProcess() {
...
@@ -9045,7 +10092,7 @@ static int queryTestProcess() {
pThreadInfo
->
ntables
=
i
<
b
?
a
+
1
:
a
;
pThreadInfo
->
ntables
=
i
<
b
?
a
+
1
:
a
;
pThreadInfo
->
end_table_to
=
i
<
b
?
tableFrom
+
a
:
tableFrom
+
a
-
1
;
pThreadInfo
->
end_table_to
=
i
<
b
?
tableFrom
+
a
:
tableFrom
+
a
-
1
;
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
pThreadInfo
->
taos
=
NULL
;
//
TODO:
workaround to use separate taos connection;
pThreadInfo
->
taos
=
NULL
;
// workaround to use separate taos connection;
pthread_create
(
pidsOfSub
+
i
,
NULL
,
superTableQuery
,
pThreadInfo
);
pthread_create
(
pidsOfSub
+
i
,
NULL
,
superTableQuery
,
pThreadInfo
);
}
}
...
@@ -9072,7 +10119,7 @@ static int queryTestProcess() {
...
@@ -9072,7 +10119,7 @@ static int queryTestProcess() {
tmfree
((
char
*
)
pidsOfSub
);
tmfree
((
char
*
)
pidsOfSub
);
tmfree
((
char
*
)
infosOfSub
);
tmfree
((
char
*
)
infosOfSub
);
// taos_close(taos);//
TODO:
workaround to use separate taos connection;
// taos_close(taos);// workaround to use separate taos connection;
uint64_t
endTs
=
taosGetTimestampMs
();
uint64_t
endTs
=
taosGetTimestampMs
();
uint64_t
totalQueried
=
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
+
uint64_t
totalQueried
=
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
+
...
@@ -9432,12 +10479,12 @@ static int subscribeTestProcess() {
...
@@ -9432,12 +10479,12 @@ static int subscribeTestProcess() {
if
(
0
!=
g_queryInfo
.
superQueryInfo
.
sqlCount
)
{
if
(
0
!=
g_queryInfo
.
superQueryInfo
.
sqlCount
)
{
getAllChildNameOfSuperTable
(
taos
,
getAllChildNameOfSuperTable
(
taos
,
g_queryInfo
.
dbName
,
g_queryInfo
.
dbName
,
g_queryInfo
.
superQueryInfo
.
s
Tbl
Name
,
g_queryInfo
.
superQueryInfo
.
s
tb
Name
,
&
g_queryInfo
.
superQueryInfo
.
childTblName
,
&
g_queryInfo
.
superQueryInfo
.
childTblName
,
&
g_queryInfo
.
superQueryInfo
.
childTblCount
);
&
g_queryInfo
.
superQueryInfo
.
childTblCount
);
}
}
taos_close
(
taos
);
//
TODO:
workaround to use separate taos connection;
taos_close
(
taos
);
// workaround to use separate taos connection;
pthread_t
*
pids
=
NULL
;
pthread_t
*
pids
=
NULL
;
threadInfo
*
infos
=
NULL
;
threadInfo
*
infos
=
NULL
;
...
@@ -9479,7 +10526,7 @@ static int subscribeTestProcess() {
...
@@ -9479,7 +10526,7 @@ static int subscribeTestProcess() {
threadInfo
*
pThreadInfo
=
infos
+
seq
;
threadInfo
*
pThreadInfo
=
infos
+
seq
;
pThreadInfo
->
threadID
=
seq
;
pThreadInfo
->
threadID
=
seq
;
pThreadInfo
->
querySeq
=
i
;
pThreadInfo
->
querySeq
=
i
;
pThreadInfo
->
taos
=
NULL
;
//
TODO:
workaround to use separate taos connection;
pThreadInfo
->
taos
=
NULL
;
// workaround to use separate taos connection;
pthread_create
(
pids
+
seq
,
NULL
,
specifiedSubscribe
,
pThreadInfo
);
pthread_create
(
pids
+
seq
,
NULL
,
specifiedSubscribe
,
pThreadInfo
);
}
}
}
}
...
@@ -9536,7 +10583,7 @@ static int subscribeTestProcess() {
...
@@ -9536,7 +10583,7 @@ static int subscribeTestProcess() {
pThreadInfo
->
ntables
=
j
<
b
?
a
+
1
:
a
;
pThreadInfo
->
ntables
=
j
<
b
?
a
+
1
:
a
;
pThreadInfo
->
end_table_to
=
j
<
b
?
tableFrom
+
a
:
tableFrom
+
a
-
1
;
pThreadInfo
->
end_table_to
=
j
<
b
?
tableFrom
+
a
:
tableFrom
+
a
-
1
;
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
pThreadInfo
->
taos
=
NULL
;
//
TODO:
workaround to use separate taos connection;
pThreadInfo
->
taos
=
NULL
;
// workaround to use separate taos connection;
pthread_create
(
pidsOfStable
+
seq
,
pthread_create
(
pidsOfStable
+
seq
,
NULL
,
superSubscribe
,
pThreadInfo
);
NULL
,
superSubscribe
,
pThreadInfo
);
}
}
...
@@ -9609,8 +10656,8 @@ static void setParaFromArg() {
...
@@ -9609,8 +10656,8 @@ static void setParaFromArg() {
g_Dbs
.
port
=
g_args
.
port
;
g_Dbs
.
port
=
g_args
.
port
;
}
}
g_Dbs
.
threadCount
=
g_args
.
n
um_of_
threads
;
g_Dbs
.
threadCount
=
g_args
.
nthreads
;
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
n
um_of_
threads
;
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
nthreads
;
g_Dbs
.
dbCount
=
1
;
g_Dbs
.
dbCount
=
1
;
g_Dbs
.
db
[
0
].
drop
=
true
;
g_Dbs
.
db
[
0
].
drop
=
true
;
...
@@ -9627,22 +10674,23 @@ static void setParaFromArg() {
...
@@ -9627,22 +10674,23 @@ static void setParaFromArg() {
g_Dbs
.
do_aggreFunc
=
true
;
g_Dbs
.
do_aggreFunc
=
true
;
char
dataString
[
TSDB_MAX_BYTES_PER_ROW
];
char
dataString
[
TSDB_MAX_BYTES_PER_ROW
];
char
**
data_type
=
g_args
.
datatype
;
char
*
data_type
=
g_args
.
data_type
;
char
**
dataType
=
g_args
.
dataType
;
memset
(
dataString
,
0
,
TSDB_MAX_BYTES_PER_ROW
);
memset
(
dataString
,
0
,
TSDB_MAX_BYTES_PER_ROW
);
if
(
strcasecmp
(
data_type
[
0
],
"BINARY"
)
==
0
if
(
(
data_type
[
0
]
==
TSDB_DATA_TYPE_BINARY
)
||
strcasecmp
(
data_type
[
0
],
"BOOL"
)
==
0
||
(
data_type
[
0
]
==
TSDB_DATA_TYPE_BOOL
)
||
strcasecmp
(
data_type
[
0
],
"NCHAR"
)
==
0
)
{
||
(
data_type
[
0
]
==
TSDB_DATA_TYPE_NCHAR
)
)
{
g_Dbs
.
do_aggreFunc
=
false
;
g_Dbs
.
do_aggreFunc
=
false
;
}
}
if
(
g_args
.
use_metric
)
{
if
(
g_args
.
use_metric
)
{
g_Dbs
.
db
[
0
].
superTblCount
=
1
;
g_Dbs
.
db
[
0
].
superTblCount
=
1
;
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
s
Tbl
Name
,
"meters"
,
TSDB_TABLE_NAME_LEN
);
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
s
tb
Name
,
"meters"
,
TSDB_TABLE_NAME_LEN
);
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
=
g_args
.
n
um_of_
tables
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
=
g_args
.
ntables
;
g_Dbs
.
threadCount
=
g_args
.
n
um_of_
threads
;
g_Dbs
.
threadCount
=
g_args
.
nthreads
;
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
n
um_of_
threads
;
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
nthreads
;
g_Dbs
.
asyncMode
=
g_args
.
async_mode
;
g_Dbs
.
asyncMode
=
g_args
.
async_mode
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
autoCreateTable
=
PRE_CREATE_SUBTBL
;
...
@@ -9662,26 +10710,28 @@ static void setParaFromArg() {
...
@@ -9662,26 +10710,28 @@ static void setParaFromArg() {
"2017-07-14 10:40:00.000"
,
MAX_TB_NAME_SIZE
);
"2017-07-14 10:40:00.000"
,
MAX_TB_NAME_SIZE
);
g_Dbs
.
db
[
0
].
superTbls
[
0
].
timeStampStep
=
g_args
.
timestamp_step
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
timeStampStep
=
g_args
.
timestamp_step
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
insertRows
=
g_args
.
num_of_DPT
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
insertRows
=
g_args
.
insertRows
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
maxSqlLen
=
g_args
.
max_sql_len
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
maxSqlLen
=
g_args
.
max_sql_len
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
=
0
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
=
0
;
for
(
int
i
=
0
;
i
<
MAX_NUM_COLUMNS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_NUM_COLUMNS
;
i
++
)
{
if
(
data_type
[
i
]
==
NULL
)
{
if
(
data_type
[
i
]
==
TSDB_DATA_TYPE_
NULL
)
{
break
;
break
;
}
}
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
data_type
=
data_type
[
i
];
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
data
_type
[
i
],
min
(
DATATYPE_BUFF_LEN
,
strlen
(
data_t
ype
[
i
])
+
1
));
data
Type
[
i
],
min
(
DATATYPE_BUFF_LEN
,
strlen
(
dataT
ype
[
i
])
+
1
));
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
++
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
++
;
}
}
if
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
>
g_args
.
num_of_CPR
)
{
if
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
>
g_args
.
columnCount
)
{
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
=
g_args
.
num_of_CPR
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
=
g_args
.
columnCount
;
}
else
{
}
else
{
for
(
int
i
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
;
for
(
int
i
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
;
i
<
g_args
.
num_of_CPR
;
i
++
)
{
i
<
g_args
.
columnCount
;
i
++
)
{
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
data_type
=
TSDB_DATA_TYPE_INT
;
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
"INT"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"INT"
)
+
1
));
"INT"
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
"INT"
)
+
1
));
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
0
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
0
;
...
@@ -9698,7 +10748,7 @@ static void setParaFromArg() {
...
@@ -9698,7 +10748,7 @@ static void setParaFromArg() {
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tags
[
1
].
dataLen
=
g_args
.
binwidth
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
2
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
2
;
}
else
{
}
else
{
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
n
um_of_
threads
;
g_Dbs
.
threadCountForCreateTbl
=
g_args
.
nthreads
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
0
;
g_Dbs
.
db
[
0
].
superTbls
[
0
].
tagCount
=
0
;
}
}
}
}
...
@@ -9831,8 +10881,8 @@ static void queryResult() {
...
@@ -9831,8 +10881,8 @@ static void queryResult() {
tstrncpy
(
pThreadInfo
->
tb_prefix
,
tstrncpy
(
pThreadInfo
->
tb_prefix
,
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblPrefix
,
TBNAME_PREFIX_LEN
);
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblPrefix
,
TBNAME_PREFIX_LEN
);
}
else
{
}
else
{
pThreadInfo
->
ntables
=
g_args
.
n
um_of_
tables
;
pThreadInfo
->
ntables
=
g_args
.
ntables
;
pThreadInfo
->
end_table_to
=
g_args
.
n
um_of_
tables
-
1
;
pThreadInfo
->
end_table_to
=
g_args
.
ntables
-
1
;
tstrncpy
(
pThreadInfo
->
tb_prefix
,
g_args
.
tb_prefix
,
TSDB_TABLE_NAME_LEN
);
tstrncpy
(
pThreadInfo
->
tb_prefix
,
g_args
.
tb_prefix
,
TSDB_TABLE_NAME_LEN
);
}
}
...
...
tests/pytest/tools/taosdemoTestTblAlt.py
浏览文件 @
6c72fc31
...
@@ -26,7 +26,7 @@ class TDTestCase:
...
@@ -26,7 +26,7 @@ class TDTestCase:
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
numberOfTables
=
10
self
.
numberOfTables
=
8
self
.
numberOfRecords
=
1000000
self
.
numberOfRecords
=
1000000
def
getBuildPath
(
self
):
def
getBuildPath
(
self
):
...
@@ -86,7 +86,7 @@ class TDTestCase:
...
@@ -86,7 +86,7 @@ class TDTestCase:
while
True
:
while
True
:
print
(
"query started"
)
print
(
"query started"
)
try
:
try
:
tdSql
.
query
(
"select * from test.t
9
"
)
tdSql
.
query
(
"select * from test.t
7
"
)
except
Exception
as
e
:
except
Exception
as
e
:
tdLog
.
info
(
"select * test failed"
)
tdLog
.
info
(
"select * test failed"
)
time
.
sleep
(
2
)
time
.
sleep
(
2
)
...
@@ -100,8 +100,8 @@ class TDTestCase:
...
@@ -100,8 +100,8 @@ class TDTestCase:
print
(
"alter table test.meters add column c10 int"
)
print
(
"alter table test.meters add column c10 int"
)
tdSql
.
execute
(
"alter table test.meters add column c10 int"
)
tdSql
.
execute
(
"alter table test.meters add column c10 int"
)
print
(
"insert into test.t
9
values (now, 1, 2, 3, 4, 0)"
)
print
(
"insert into test.t
7
values (now, 1, 2, 3, 4, 0)"
)
tdSql
.
execute
(
"insert into test.t
9
values (now, 1, 2, 3, 4, 0)"
)
tdSql
.
execute
(
"insert into test.t
7
values (now, 1, 2, 3, 4, 0)"
)
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录