Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
54813175
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看板
提交
54813175
编写于
8月 09, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor stmt functions.
上级
07603323
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
627 addition
and
376 deletion
+627
-376
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+627
-376
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
54813175
...
@@ -295,6 +295,9 @@ typedef struct SSuperTable_S {
...
@@ -295,6 +295,9 @@ typedef struct SSuperTable_S {
uint64_t
lenOfTagOfOneRow
;
uint64_t
lenOfTagOfOneRow
;
char
*
sampleDataBuf
;
char
*
sampleDataBuf
;
#if STMT_IFACE_ENABLED == 1
void
*
sampleBindArray
;
#endif
//int sampleRowCount;
//int sampleRowCount;
//int sampleUsePos;
//int sampleUsePos;
...
@@ -454,7 +457,7 @@ typedef struct SThreadInfo_S {
...
@@ -454,7 +457,7 @@ typedef struct SThreadInfo_S {
int64_t
start_time
;
int64_t
start_time
;
char
*
cols
;
char
*
cols
;
bool
use_metric
;
bool
use_metric
;
SSuperTable
*
s
uperTbl
Info
;
SSuperTable
*
s
tb
Info
;
char
*
buffer
;
// sql cmd buffer
char
*
buffer
;
// sql cmd buffer
// for async insert
// for async insert
...
@@ -3088,7 +3091,7 @@ int createDatabasesAndStables(char *command) {
...
@@ -3088,7 +3091,7 @@ int createDatabasesAndStables(char *command) {
errorPrint
(
"Failed to connect to TDengine, reason:%s
\n
"
,
taos_errstr
(
NULL
));
errorPrint
(
"Failed to connect to TDengine, reason:%s
\n
"
,
taos_errstr
(
NULL
));
return
-
1
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
db
[
i
].
drop
)
{
if
(
g_Dbs
.
db
[
i
].
drop
)
{
sprintf
(
command
,
"drop database if exists %s;"
,
g_Dbs
.
db
[
i
].
dbName
);
sprintf
(
command
,
"drop database if exists %s;"
,
g_Dbs
.
db
[
i
].
dbName
);
...
@@ -3099,35 +3102,43 @@ int createDatabasesAndStables(char *command) {
...
@@ -3099,35 +3102,43 @@ 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"
,
g_Dbs
.
db
[
i
].
dbName
);
BUFFER_SIZE
-
dataLen
,
"create database if not exists %s"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
blocks
);
BUFFER_SIZE
-
dataLen
,
" blocks %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cache
);
BUFFER_SIZE
-
dataLen
,
" cache %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
days
);
BUFFER_SIZE
-
dataLen
,
" days %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
keep
);
BUFFER_SIZE
-
dataLen
,
" keep %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
quorum
);
BUFFER_SIZE
-
dataLen
,
" quorum %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
replica
);
BUFFER_SIZE
-
dataLen
,
" replica %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
BUFFER_SIZE
-
dataLen
,
" update %d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
update
);
}
}
//if (g_Dbs.db[i].dbCfg.maxtablesPerVnode > 0) {
//if (g_Dbs.db[i].dbCfg.maxtablesPerVnode > 0) {
// dataLen += snprintf(command + dataLen,
// dataLen += snprintf(command + dataLen,
...
@@ -3135,42 +3146,48 @@ int createDatabasesAndStables(char *command) {
...
@@ -3135,42 +3146,48 @@ 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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
minRows
);
BUFFER_SIZE
-
dataLen
,
" minrows %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
maxRows
);
BUFFER_SIZE
-
dataLen
,
" maxrows %d"
,
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
BUFFER_SIZE
-
dataLen
,
" comp %d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
comp
);
}
}
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
>
0
)
{
dataLen
+=
snprintf
(
command
+
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
" wal %d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
BUFFER_SIZE
-
dataLen
,
" wal %d"
,
g_Dbs
.
db
[
i
].
dbCfg
.
walLevel
);
}
}
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"
,
g_Dbs
.
db
[
i
].
dbCfg
.
cacheLast
);
BUFFER_SIZE
-
dataLen
,
" cachelast %d"
,
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"
,
strlen
(
"ms"
)
))
if
((
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ms"
,
2
))
#if NANO_SECOND_ENABLED == 1
#if NANO_SECOND_ENABLED == 1
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"ns"
,
strlen
(
"ns"
)
))
"ns"
,
2
))
#endif
#endif
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
"us"
,
strlen
(
"us"
))))
{
"us"
,
2
)))
{
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
dataLen
+=
snprintf
(
command
+
dataLen
,
BUFFER_SIZE
-
dataLen
,
" precision
\'
%s
\'
;"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
" precision
\'
%s
\'
;"
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
);
}
}
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
if
(
0
!=
queryDbExec
(
taos
,
command
,
NO_INSERT_TYPE
,
false
))
{
taos_close
(
taos
);
taos_close
(
taos
);
errorPrint
(
"
\n
create database %s failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
errorPrint
(
"
\n
create database %s failed!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
return
-
1
;
return
-
1
;
}
}
printf
(
"
\n
create database %s success!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
printf
(
"
\n
create database %s success!
\n\n
"
,
g_Dbs
.
db
[
i
].
dbName
);
...
@@ -3217,7 +3234,7 @@ int createDatabasesAndStables(char *command) {
...
@@ -3217,7 +3234,7 @@ int createDatabasesAndStables(char *command) {
static
void
*
createTable
(
void
*
sarg
)
static
void
*
createTable
(
void
*
sarg
)
{
{
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
setThreadName
(
"createTable"
);
setThreadName
(
"createTable"
);
...
@@ -3247,7 +3264,7 @@ static void* createTable(void *sarg)
...
@@ -3247,7 +3264,7 @@ static void* createTable(void *sarg)
g_args
.
tb_prefix
,
i
,
g_args
.
tb_prefix
,
i
,
pThreadInfo
->
cols
);
pThreadInfo
->
cols
);
}
else
{
}
else
{
if
(
s
uperTbl
Info
==
NULL
)
{
if
(
s
tb
Info
==
NULL
)
{
errorPrint
(
"%s() LN%d, use metric, but super table info is NULL
\n
"
,
errorPrint
(
"%s() LN%d, use metric, but super table info is NULL
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
free
(
pThreadInfo
->
buffer
);
free
(
pThreadInfo
->
buffer
);
...
@@ -3260,12 +3277,12 @@ static void* createTable(void *sarg)
...
@@ -3260,12 +3277,12 @@ static void* createTable(void *sarg)
buff_len
-
len
,
"create table "
);
buff_len
-
len
,
"create table "
);
}
}
char
*
tagsValBuf
=
NULL
;
char
*
tagsValBuf
=
NULL
;
if
(
0
==
s
uperTbl
Info
->
tagSource
)
{
if
(
0
==
s
tb
Info
->
tagSource
)
{
tagsValBuf
=
generateTagValuesForStb
(
s
uperTbl
Info
,
i
);
tagsValBuf
=
generateTagValuesForStb
(
s
tb
Info
,
i
);
}
else
{
}
else
{
tagsValBuf
=
getTagValueFromTagSample
(
tagsValBuf
=
getTagValueFromTagSample
(
s
uperTbl
Info
,
s
tb
Info
,
i
%
s
uperTbl
Info
->
tagSampleCount
);
i
%
s
tb
Info
->
tagSampleCount
);
}
}
if
(
NULL
==
tagsValBuf
)
{
if
(
NULL
==
tagsValBuf
)
{
free
(
pThreadInfo
->
buffer
);
free
(
pThreadInfo
->
buffer
);
...
@@ -3274,14 +3291,14 @@ static void* createTable(void *sarg)
...
@@ -3274,14 +3291,14 @@ static void* createTable(void *sarg)
len
+=
snprintf
(
pThreadInfo
->
buffer
+
len
,
len
+=
snprintf
(
pThreadInfo
->
buffer
+
len
,
buff_len
-
len
,
buff_len
-
len
,
"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
,
s
uperTbl
Info
->
childTblPrefix
,
pThreadInfo
->
db_name
,
s
tb
Info
->
childTblPrefix
,
i
,
pThreadInfo
->
db_name
,
i
,
pThreadInfo
->
db_name
,
s
uperTbl
Info
->
sTblName
,
tagsValBuf
);
s
tb
Info
->
sTblName
,
tagsValBuf
);
free
(
tagsValBuf
);
free
(
tagsValBuf
);
batchNum
++
;
batchNum
++
;
if
((
batchNum
<
s
uperTbl
Info
->
batchCreateTableNum
)
if
((
batchNum
<
s
tb
Info
->
batchCreateTableNum
)
&&
((
buff_len
-
len
)
&&
((
buff_len
-
len
)
>=
(
s
uperTbl
Info
->
lenOfTagOfOneRow
+
256
)))
{
>=
(
s
tb
Info
->
lenOfTagOfOneRow
+
256
)))
{
continue
;
continue
;
}
}
}
}
...
@@ -3316,7 +3333,7 @@ static void* createTable(void *sarg)
...
@@ -3316,7 +3333,7 @@ static void* createTable(void *sarg)
static
int
startMultiThreadCreateChildTable
(
static
int
startMultiThreadCreateChildTable
(
char
*
cols
,
int
threads
,
uint64_t
tableFrom
,
int64_t
ntables
,
char
*
cols
,
int
threads
,
uint64_t
tableFrom
,
int64_t
ntables
,
char
*
db_name
,
SSuperTable
*
s
uperTbl
Info
)
{
char
*
db_name
,
SSuperTable
*
s
tb
Info
)
{
pthread_t
*
pids
=
calloc
(
1
,
threads
*
sizeof
(
pthread_t
));
pthread_t
*
pids
=
calloc
(
1
,
threads
*
sizeof
(
pthread_t
));
threadInfo
*
infos
=
calloc
(
1
,
threads
*
sizeof
(
threadInfo
));
threadInfo
*
infos
=
calloc
(
1
,
threads
*
sizeof
(
threadInfo
));
...
@@ -3343,7 +3360,7 @@ static int startMultiThreadCreateChildTable(
...
@@ -3343,7 +3360,7 @@ static int startMultiThreadCreateChildTable(
threadInfo
*
pThreadInfo
=
infos
+
i
;
threadInfo
*
pThreadInfo
=
infos
+
i
;
pThreadInfo
->
threadID
=
i
;
pThreadInfo
->
threadID
=
i
;
tstrncpy
(
pThreadInfo
->
db_name
,
db_name
,
TSDB_DB_NAME_LEN
);
tstrncpy
(
pThreadInfo
->
db_name
,
db_name
,
TSDB_DB_NAME_LEN
);
pThreadInfo
->
s
uperTblInfo
=
superTbl
Info
;
pThreadInfo
->
s
tbInfo
=
stb
Info
;
verbosePrint
(
"%s() %d db_name: %s
\n
"
,
__func__
,
__LINE__
,
db_name
);
verbosePrint
(
"%s() %d db_name: %s
\n
"
,
__func__
,
__LINE__
,
db_name
);
pThreadInfo
->
taos
=
taos_connect
(
pThreadInfo
->
taos
=
taos_connect
(
g_Dbs
.
host
,
g_Dbs
.
host
,
...
@@ -3450,26 +3467,26 @@ static void createChildTables() {
...
@@ -3450,26 +3467,26 @@ static void createChildTables() {
/*
/*
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
readTagFromCsvFileToMem
(
SSuperTable
*
s
uperTbl
Info
)
{
static
int
readTagFromCsvFileToMem
(
SSuperTable
*
s
tb
Info
)
{
size_t
n
=
0
;
size_t
n
=
0
;
ssize_t
readLen
=
0
;
ssize_t
readLen
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
FILE
*
fp
=
fopen
(
s
uperTbl
Info
->
tagsFile
,
"r"
);
FILE
*
fp
=
fopen
(
s
tb
Info
->
tagsFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"Failed to open tags file: %s, reason:%s
\n
"
,
printf
(
"Failed to open tags file: %s, reason:%s
\n
"
,
s
uperTbl
Info
->
tagsFile
,
strerror
(
errno
));
s
tb
Info
->
tagsFile
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
if
(
s
uperTbl
Info
->
tagDataBuf
)
{
if
(
s
tb
Info
->
tagDataBuf
)
{
free
(
s
uperTbl
Info
->
tagDataBuf
);
free
(
s
tb
Info
->
tagDataBuf
);
s
uperTbl
Info
->
tagDataBuf
=
NULL
;
s
tb
Info
->
tagDataBuf
=
NULL
;
}
}
int
tagCount
=
10000
;
int
tagCount
=
10000
;
int
count
=
0
;
int
count
=
0
;
char
*
tagDataBuf
=
calloc
(
1
,
s
uperTbl
Info
->
lenOfTagOfOneRow
*
tagCount
);
char
*
tagDataBuf
=
calloc
(
1
,
s
tb
Info
->
lenOfTagOfOneRow
*
tagCount
);
if
(
tagDataBuf
==
NULL
)
{
if
(
tagDataBuf
==
NULL
)
{
printf
(
"Failed to calloc, reason:%s
\n
"
,
strerror
(
errno
));
printf
(
"Failed to calloc, reason:%s
\n
"
,
strerror
(
errno
));
fclose
(
fp
);
fclose
(
fp
);
...
@@ -3485,20 +3502,20 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
...
@@ -3485,20 +3502,20 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
continue
;
continue
;
}
}
memcpy
(
tagDataBuf
+
count
*
s
uperTbl
Info
->
lenOfTagOfOneRow
,
line
,
readLen
);
memcpy
(
tagDataBuf
+
count
*
s
tb
Info
->
lenOfTagOfOneRow
,
line
,
readLen
);
count
++
;
count
++
;
if
(
count
>=
tagCount
-
1
)
{
if
(
count
>=
tagCount
-
1
)
{
char
*
tmp
=
realloc
(
tagDataBuf
,
char
*
tmp
=
realloc
(
tagDataBuf
,
(
size_t
)
tagCount
*
1
.
5
*
s
uperTbl
Info
->
lenOfTagOfOneRow
);
(
size_t
)
tagCount
*
1
.
5
*
s
tb
Info
->
lenOfTagOfOneRow
);
if
(
tmp
!=
NULL
)
{
if
(
tmp
!=
NULL
)
{
tagDataBuf
=
tmp
;
tagDataBuf
=
tmp
;
tagCount
=
(
int
)(
tagCount
*
1
.
5
);
tagCount
=
(
int
)(
tagCount
*
1
.
5
);
memset
(
tagDataBuf
+
count
*
s
uperTbl
Info
->
lenOfTagOfOneRow
,
memset
(
tagDataBuf
+
count
*
s
tb
Info
->
lenOfTagOfOneRow
,
0
,
(
size_t
)((
tagCount
-
count
)
*
s
uperTbl
Info
->
lenOfTagOfOneRow
));
0
,
(
size_t
)((
tagCount
-
count
)
*
s
tb
Info
->
lenOfTagOfOneRow
));
}
else
{
}
else
{
// exit, if allocate more memory failed
// exit, if allocate more memory failed
printf
(
"realloc fail for save tag val from %s
\n
"
,
s
uperTbl
Info
->
tagsFile
);
printf
(
"realloc fail for save tag val from %s
\n
"
,
s
tb
Info
->
tagsFile
);
tmfree
(
tagDataBuf
);
tmfree
(
tagDataBuf
);
free
(
line
);
free
(
line
);
fclose
(
fp
);
fclose
(
fp
);
...
@@ -3507,8 +3524,8 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
...
@@ -3507,8 +3524,8 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
}
}
}
}
s
uperTbl
Info
->
tagDataBuf
=
tagDataBuf
;
s
tb
Info
->
tagDataBuf
=
tagDataBuf
;
s
uperTbl
Info
->
tagSampleCount
=
count
;
s
tb
Info
->
tagSampleCount
=
count
;
free
(
line
);
free
(
line
);
fclose
(
fp
);
fclose
(
fp
);
...
@@ -3519,28 +3536,28 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
...
@@ -3519,28 +3536,28 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
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
readSampleFromCsvFileToMem
(
SSuperTable
*
s
uperTbl
Info
)
{
SSuperTable
*
s
tb
Info
)
{
size_t
n
=
0
;
size_t
n
=
0
;
ssize_t
readLen
=
0
;
ssize_t
readLen
=
0
;
char
*
line
=
NULL
;
char
*
line
=
NULL
;
int
getRows
=
0
;
int
getRows
=
0
;
FILE
*
fp
=
fopen
(
s
uperTbl
Info
->
sampleFile
,
"r"
);
FILE
*
fp
=
fopen
(
s
tb
Info
->
sampleFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
errorPrint
(
"Failed to open sample file: %s, reason:%s
\n
"
,
errorPrint
(
"Failed to open sample file: %s, reason:%s
\n
"
,
s
uperTbl
Info
->
sampleFile
,
strerror
(
errno
));
s
tb
Info
->
sampleFile
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
assert
(
s
uperTbl
Info
->
sampleDataBuf
);
assert
(
s
tb
Info
->
sampleDataBuf
);
memset
(
s
uperTbl
Info
->
sampleDataBuf
,
0
,
memset
(
s
tb
Info
->
sampleDataBuf
,
0
,
MAX_SAMPLES_ONCE_FROM_FILE
*
s
uperTbl
Info
->
lenOfOneRow
);
MAX_SAMPLES_ONCE_FROM_FILE
*
s
tb
Info
->
lenOfOneRow
);
while
(
1
)
{
while
(
1
)
{
readLen
=
tgetline
(
&
line
,
&
n
,
fp
);
readLen
=
tgetline
(
&
line
,
&
n
,
fp
);
if
(
-
1
==
readLen
)
{
if
(
-
1
==
readLen
)
{
if
(
0
!=
fseek
(
fp
,
0
,
SEEK_SET
))
{
if
(
0
!=
fseek
(
fp
,
0
,
SEEK_SET
))
{
errorPrint
(
"Failed to fseek file: %s, reason:%s
\n
"
,
errorPrint
(
"Failed to fseek file: %s, reason:%s
\n
"
,
s
uperTbl
Info
->
sampleFile
,
strerror
(
errno
));
s
tb
Info
->
sampleFile
,
strerror
(
errno
));
fclose
(
fp
);
fclose
(
fp
);
return
-
1
;
return
-
1
;
}
}
...
@@ -3555,13 +3572,13 @@ static int readSampleFromCsvFileToMem(
...
@@ -3555,13 +3572,13 @@ static int readSampleFromCsvFileToMem(
continue
;
continue
;
}
}
if
(
readLen
>
s
uperTbl
Info
->
lenOfOneRow
)
{
if
(
readLen
>
s
tb
Info
->
lenOfOneRow
)
{
printf
(
"sample row len[%d] overflow define schema len[%"
PRIu64
"], so discard this row
\n
"
,
printf
(
"sample row len[%d] overflow define schema len[%"
PRIu64
"], so discard this row
\n
"
,
(
int32_t
)
readLen
,
s
uperTbl
Info
->
lenOfOneRow
);
(
int32_t
)
readLen
,
s
tb
Info
->
lenOfOneRow
);
continue
;
continue
;
}
}
memcpy
(
s
uperTblInfo
->
sampleDataBuf
+
getRows
*
superTbl
Info
->
lenOfOneRow
,
memcpy
(
s
tbInfo
->
sampleDataBuf
+
getRows
*
stb
Info
->
lenOfOneRow
,
line
,
readLen
);
line
,
readLen
);
getRows
++
;
getRows
++
;
...
@@ -5046,6 +5063,18 @@ static void postFreeResource() {
...
@@ -5046,6 +5063,18 @@ static void postFreeResource() {
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
);
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_IFACE_ENABLED == 1
if
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindArray
)
{
for
(
int
c
=
0
;
c
<
MAX_SAMPLES_ONCE_FROM_FILE
;
c
++
)
{
uintptr_t
*
tmp
=
(
uintptr_t
*
)(
*
(
uintptr_t
*
)(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindArray
+
sizeof
(
uintptr_t
*
)
*
c
));
tmfree
((
char
*
)
tmp
);
}
}
tmfree
((
char
*
)
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleBindArray
);
#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
);
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
=
NULL
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
=
NULL
;
...
@@ -5066,12 +5095,12 @@ static void postFreeResource() {
...
@@ -5066,12 +5095,12 @@ static void postFreeResource() {
tmfree
(
g_randfloat_buff
);
tmfree
(
g_randfloat_buff
);
tmfree
(
g_rand_current_buff
);
tmfree
(
g_rand_current_buff
);
tmfree
(
g_rand_phase_buff
);
tmfree
(
g_rand_phase_buff
);
tmfree
(
g_randdouble_buff
);
}
}
static
int
getRowDataFromSample
(
static
int
getRowDataFromSample
(
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
char
*
dataBuf
,
int64_t
maxLen
,
int64_t
timestamp
,
SSuperTable
*
s
uperTbl
Info
,
int64_t
*
sampleUsePos
)
SSuperTable
*
s
tb
Info
,
int64_t
*
sampleUsePos
)
{
{
if
((
*
sampleUsePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
if
((
*
sampleUsePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
sampleUsePos
=
0
;
*
sampleUsePos
=
0
;
...
@@ -5083,8 +5112,8 @@ static int getRowDataFromSample(
...
@@ -5083,8 +5112,8 @@ static int getRowDataFromSample(
"(%"
PRId64
", "
,
timestamp
);
"(%"
PRId64
", "
,
timestamp
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
"%s"
,
"%s"
,
s
uperTbl
Info
->
sampleDataBuf
s
tb
Info
->
sampleDataBuf
+
s
uperTbl
Info
->
lenOfOneRow
*
(
*
sampleUsePos
));
+
s
tb
Info
->
lenOfOneRow
*
(
*
sampleUsePos
));
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
")"
);
dataLen
+=
snprintf
(
dataBuf
+
dataLen
,
maxLen
-
dataLen
,
")"
);
(
*
sampleUsePos
)
++
;
(
*
sampleUsePos
)
++
;
...
@@ -5257,27 +5286,27 @@ static int64_t generateData(char *recBuf, char **data_type,
...
@@ -5257,27 +5286,27 @@ static int64_t generateData(char *recBuf, char **data_type,
return
(
int32_t
)
strlen
(
recBuf
);
return
(
int32_t
)
strlen
(
recBuf
);
}
}
static
int
prepareSampleDataForSTable
(
SSuperTable
*
s
uperTbl
Info
)
{
static
int
prepareSampleDataForSTable
(
SSuperTable
*
s
tb
Info
)
{
char
*
sampleDataBuf
=
NULL
;
char
*
sampleDataBuf
=
NULL
;
sampleDataBuf
=
calloc
(
sampleDataBuf
=
calloc
(
s
uperTbl
Info
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
1
);
s
tb
Info
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
1
);
if
(
sampleDataBuf
==
NULL
)
{
if
(
sampleDataBuf
==
NULL
)
{
errorPrint
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
errorPrint
(
"%s() LN%d, Failed to calloc %"
PRIu64
" Bytes, reason:%s
\n
"
,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
s
uperTbl
Info
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
s
tb
Info
->
lenOfOneRow
*
MAX_SAMPLES_ONCE_FROM_FILE
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
s
uperTbl
Info
->
sampleDataBuf
=
sampleDataBuf
;
s
tb
Info
->
sampleDataBuf
=
sampleDataBuf
;
int
ret
=
readSampleFromCsvFileToMem
(
s
uperTbl
Info
);
int
ret
=
readSampleFromCsvFileToMem
(
s
tb
Info
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
errorPrint
(
"%s() LN%d, read sample from csv file failed.
\n
"
,
errorPrint
(
"%s() LN%d, read sample from csv file failed.
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
tmfree
(
sampleDataBuf
);
tmfree
(
sampleDataBuf
);
s
uperTbl
Info
->
sampleDataBuf
=
NULL
;
s
tb
Info
->
sampleDataBuf
=
NULL
;
return
-
1
;
return
-
1
;
}
}
...
@@ -5287,14 +5316,14 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) {
...
@@ -5287,14 +5316,14 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) {
static
int32_t
execInsert
(
threadInfo
*
pThreadInfo
,
uint32_t
k
)
static
int32_t
execInsert
(
threadInfo
*
pThreadInfo
,
uint32_t
k
)
{
{
int32_t
affectedRows
;
int32_t
affectedRows
;
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
verbosePrint
(
"[%d] %s() LN%d %s
\n
"
,
pThreadInfo
->
threadID
,
verbosePrint
(
"[%d] %s() LN%d %s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
buffer
);
__func__
,
__LINE__
,
pThreadInfo
->
buffer
);
uint16_t
iface
;
uint16_t
iface
;
if
(
s
uperTbl
Info
)
if
(
s
tb
Info
)
iface
=
s
uperTbl
Info
->
iface
;
iface
=
s
tb
Info
->
iface
;
else
{
else
{
if
(
g_args
.
iface
==
INTERFACE_BUT
)
if
(
g_args
.
iface
==
INTERFACE_BUT
)
iface
=
TAOSC_IFACE
;
iface
=
TAOSC_IFACE
;
...
@@ -5342,7 +5371,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
...
@@ -5342,7 +5371,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
default:
default:
errorPrint
(
"%s() LN%d: unknown insert mode: %d
\n
"
,
errorPrint
(
"%s() LN%d: unknown insert mode: %d
\n
"
,
__func__
,
__LINE__
,
s
uperTbl
Info
->
iface
);
__func__
,
__LINE__
,
s
tb
Info
->
iface
);
affectedRows
=
0
;
affectedRows
=
0
;
}
}
...
@@ -5352,24 +5381,24 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
...
@@ -5352,24 +5381,24 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
static
void
getTableName
(
char
*
pTblName
,
static
void
getTableName
(
char
*
pTblName
,
threadInfo
*
pThreadInfo
,
uint64_t
tableSeq
)
threadInfo
*
pThreadInfo
,
uint64_t
tableSeq
)
{
{
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
if
(
AUTO_CREATE_SUBTBL
!=
s
uperTbl
Info
->
autoCreateTable
)
{
if
(
AUTO_CREATE_SUBTBL
!=
s
tb
Info
->
autoCreateTable
)
{
if
(
s
uperTbl
Info
->
childTblLimit
>
0
)
{
if
(
s
tb
Info
->
childTblLimit
>
0
)
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
s
uperTbl
Info
->
childTblName
+
s
tb
Info
->
childTblName
+
(
tableSeq
-
s
uperTbl
Info
->
childTblOffset
)
*
TSDB_TABLE_NAME_LEN
);
(
tableSeq
-
s
tb
Info
->
childTblOffset
)
*
TSDB_TABLE_NAME_LEN
);
}
else
{
}
else
{
verbosePrint
(
"[%d] %s() LN%d: from=%"
PRIu64
" count=%"
PRId64
" seq=%"
PRIu64
"
\n
"
,
verbosePrint
(
"[%d] %s() LN%d: from=%"
PRIu64
" count=%"
PRId64
" seq=%"
PRIu64
"
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
ntables
,
tableSeq
);
pThreadInfo
->
ntables
,
tableSeq
);
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s"
,
s
uperTbl
Info
->
childTblName
+
tableSeq
*
TSDB_TABLE_NAME_LEN
);
s
tb
Info
->
childTblName
+
tableSeq
*
TSDB_TABLE_NAME_LEN
);
}
}
}
else
{
}
else
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
s
uperTbl
Info
->
childTblPrefix
,
tableSeq
);
s
tb
Info
->
childTblPrefix
,
tableSeq
);
}
}
}
else
{
}
else
{
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
snprintf
(
pTblName
,
TSDB_TABLE_NAME_LEN
,
"%s%"
PRIu64
""
,
...
@@ -5450,7 +5479,7 @@ static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
...
@@ -5450,7 +5479,7 @@ static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
}
}
static
int32_t
generateStbDataTail
(
static
int32_t
generateStbDataTail
(
SSuperTable
*
s
uperTbl
Info
,
SSuperTable
*
s
tb
Info
,
uint32_t
batch
,
char
*
buffer
,
uint32_t
batch
,
char
*
buffer
,
int64_t
remainderBufLen
,
int64_t
insertRows
,
int64_t
remainderBufLen
,
int64_t
insertRows
,
uint64_t
recordFrom
,
int64_t
startTime
,
uint64_t
recordFrom
,
int64_t
startTime
,
...
@@ -5460,7 +5489,7 @@ static int32_t generateStbDataTail(
...
@@ -5460,7 +5489,7 @@ static int32_t generateStbDataTail(
char
*
pstr
=
buffer
;
char
*
pstr
=
buffer
;
bool
tsRand
;
bool
tsRand
;
if
(
0
==
strncasecmp
(
s
uperTbl
Info
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
if
(
0
==
strncasecmp
(
s
tb
Info
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
tsRand
=
true
;
tsRand
=
true
;
}
else
{
}
else
{
tsRand
=
false
;
tsRand
=
false
;
...
@@ -5475,26 +5504,26 @@ static int32_t generateStbDataTail(
...
@@ -5475,26 +5504,26 @@ static int32_t generateStbDataTail(
int64_t
lenOfRow
=
0
;
int64_t
lenOfRow
=
0
;
if
(
tsRand
)
{
if
(
tsRand
)
{
if
(
s
uperTbl
Info
->
disorderRatio
>
0
)
{
if
(
s
tb
Info
->
disorderRatio
>
0
)
{
lenOfRow
=
generateStbRowData
(
s
uperTbl
Info
,
data
,
lenOfRow
=
generateStbRowData
(
s
tb
Info
,
data
,
remainderBufLen
,
remainderBufLen
,
startTime
+
getTSRandTail
(
startTime
+
getTSRandTail
(
s
uperTbl
Info
->
timeStampStep
,
k
,
s
tb
Info
->
timeStampStep
,
k
,
s
uperTbl
Info
->
disorderRatio
,
s
tb
Info
->
disorderRatio
,
s
uperTbl
Info
->
disorderRange
)
s
tb
Info
->
disorderRange
)
);
);
}
else
{
}
else
{
lenOfRow
=
generateStbRowData
(
s
uperTbl
Info
,
data
,
lenOfRow
=
generateStbRowData
(
s
tb
Info
,
data
,
remainderBufLen
,
remainderBufLen
,
startTime
+
s
uperTbl
Info
->
timeStampStep
*
k
startTime
+
s
tb
Info
->
timeStampStep
*
k
);
);
}
}
}
else
{
}
else
{
lenOfRow
=
getRowDataFromSample
(
lenOfRow
=
getRowDataFromSample
(
data
,
data
,
(
remainderBufLen
<
MAX_DATA_SIZE
)
?
remainderBufLen
:
MAX_DATA_SIZE
,
(
remainderBufLen
<
MAX_DATA_SIZE
)
?
remainderBufLen
:
MAX_DATA_SIZE
,
startTime
+
s
uperTbl
Info
->
timeStampStep
*
k
,
startTime
+
s
tb
Info
->
timeStampStep
*
k
,
s
uperTbl
Info
,
s
tb
Info
,
pSamplePos
);
pSamplePos
);
}
}
...
@@ -5550,7 +5579,7 @@ static int generateSQLHeadWithoutStb(char *tableName,
...
@@ -5550,7 +5579,7 @@ static int generateSQLHeadWithoutStb(char *tableName,
}
}
static
int
generateStbSQLHead
(
static
int
generateStbSQLHead
(
SSuperTable
*
s
uperTbl
Info
,
SSuperTable
*
s
tb
Info
,
char
*
tableName
,
int64_t
tableSeq
,
char
*
tableName
,
int64_t
tableSeq
,
char
*
dbName
,
char
*
dbName
,
char
*
buffer
,
int
remainderBufLen
)
char
*
buffer
,
int
remainderBufLen
)
...
@@ -5559,14 +5588,14 @@ static int generateStbSQLHead(
...
@@ -5559,14 +5588,14 @@ static int generateStbSQLHead(
char
headBuf
[
HEAD_BUFF_LEN
];
char
headBuf
[
HEAD_BUFF_LEN
];
if
(
AUTO_CREATE_SUBTBL
==
s
uperTbl
Info
->
autoCreateTable
)
{
if
(
AUTO_CREATE_SUBTBL
==
s
tb
Info
->
autoCreateTable
)
{
char
*
tagsValBuf
=
NULL
;
char
*
tagsValBuf
=
NULL
;
if
(
0
==
s
uperTbl
Info
->
tagSource
)
{
if
(
0
==
s
tb
Info
->
tagSource
)
{
tagsValBuf
=
generateTagValuesForStb
(
s
uperTbl
Info
,
tableSeq
);
tagsValBuf
=
generateTagValuesForStb
(
s
tb
Info
,
tableSeq
);
}
else
{
}
else
{
tagsValBuf
=
getTagValueFromTagSample
(
tagsValBuf
=
getTagValueFromTagSample
(
s
uperTbl
Info
,
s
tb
Info
,
tableSeq
%
s
uperTbl
Info
->
tagSampleCount
);
tableSeq
%
s
tb
Info
->
tagSampleCount
);
}
}
if
(
NULL
==
tagsValBuf
)
{
if
(
NULL
==
tagsValBuf
)
{
errorPrint
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
errorPrint
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
...
@@ -5581,10 +5610,10 @@ static int generateStbSQLHead(
...
@@ -5581,10 +5610,10 @@ static int generateStbSQLHead(
dbName
,
dbName
,
tableName
,
tableName
,
dbName
,
dbName
,
s
uperTbl
Info
->
sTblName
,
s
tb
Info
->
sTblName
,
tagsValBuf
);
tagsValBuf
);
tmfree
(
tagsValBuf
);
tmfree
(
tagsValBuf
);
}
else
if
(
TBL_ALREADY_EXISTS
==
s
uperTbl
Info
->
childTblExists
)
{
}
else
if
(
TBL_ALREADY_EXISTS
==
s
tb
Info
->
childTblExists
)
{
len
=
snprintf
(
len
=
snprintf
(
headBuf
,
headBuf
,
HEAD_BUFF_LEN
,
HEAD_BUFF_LEN
,
...
@@ -5609,12 +5638,12 @@ static int generateStbSQLHead(
...
@@ -5609,12 +5638,12 @@ static int generateStbSQLHead(
}
}
static
int32_t
generateStbInterlaceData
(
static
int32_t
generateStbInterlaceData
(
SSuperTable
*
superTbl
Info
,
threadInfo
*
pThread
Info
,
char
*
tableName
,
uint32_t
batchPerTbl
,
char
*
tableName
,
uint32_t
batchPerTbl
,
uint64_t
i
,
uint64_t
i
,
uint32_t
batchPerTblTimes
,
uint32_t
batchPerTblTimes
,
uint64_t
tableSeq
,
uint64_t
tableSeq
,
threadInfo
*
pThreadInfo
,
char
*
buffer
,
char
*
buffer
,
int64_t
insertRows
,
int64_t
insertRows
,
int64_t
startTime
,
int64_t
startTime
,
uint64_t
*
pRemainderBufLen
)
uint64_t
*
pRemainderBufLen
)
...
@@ -5622,8 +5651,9 @@ static int32_t generateStbInterlaceData(
...
@@ -5622,8 +5651,9 @@ static int32_t generateStbInterlaceData(
assert
(
buffer
);
assert
(
buffer
);
char
*
pstr
=
buffer
;
char
*
pstr
=
buffer
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
int
headLen
=
generateStbSQLHead
(
int
headLen
=
generateStbSQLHead
(
s
uperTbl
Info
,
s
tb
Info
,
tableName
,
tableSeq
,
pThreadInfo
->
db_name
,
tableName
,
tableSeq
,
pThreadInfo
->
db_name
,
pstr
,
*
pRemainderBufLen
);
pstr
,
*
pRemainderBufLen
);
...
@@ -5643,12 +5673,12 @@ static int32_t generateStbInterlaceData(
...
@@ -5643,12 +5673,12 @@ static int32_t generateStbInterlaceData(
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
i
,
batchPerTblTimes
,
batchPerTbl
);
i
,
batchPerTblTimes
,
batchPerTbl
);
if
(
0
==
strncasecmp
(
s
uperTbl
Info
->
startTimestamp
,
"now"
,
3
))
{
if
(
0
==
strncasecmp
(
s
tb
Info
->
startTimestamp
,
"now"
,
3
))
{
startTime
=
taosGetTimestamp
(
pThreadInfo
->
time_precision
);
startTime
=
taosGetTimestamp
(
pThreadInfo
->
time_precision
);
}
}
int32_t
k
=
generateStbDataTail
(
int32_t
k
=
generateStbDataTail
(
s
uperTbl
Info
,
s
tb
Info
,
batchPerTbl
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
0
,
batchPerTbl
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
0
,
startTime
,
startTime
,
&
(
pThreadInfo
->
samplePos
),
&
dataLen
);
&
(
pThreadInfo
->
samplePos
),
&
dataLen
);
...
@@ -5911,14 +5941,14 @@ static int32_t prepareStmtBindArrayByType(TAOS_BIND *bind,
...
@@ -5911,14 +5941,14 @@ static int32_t prepareStmtBindArrayByType(TAOS_BIND *bind,
}
}
static
int32_t
prepareStmtWithoutStb
(
static
int32_t
prepareStmtWithoutStb
(
TAOS_STMT
*
stmt
,
threadInfo
*
pThreadInfo
,
char
*
tableName
,
char
*
tableName
,
uint32_t
batch
,
uint32_t
batch
,
int64_t
insertRows
,
int64_t
insertRows
,
int64_t
recordFrom
,
int64_t
recordFrom
,
int32_t
timePrec
,
int64_t
startTime
)
int64_t
startTime
)
{
{
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
int
ret
=
taos_stmt_set_tbname
(
stmt
,
tableName
);
int
ret
=
taos_stmt_set_tbname
(
stmt
,
tableName
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
errorPrint
(
"failed to execute taos_stmt_set_tbname(%s). return 0x%x. reason: %s
\n
"
,
errorPrint
(
"failed to execute taos_stmt_set_tbname(%s). return 0x%x. reason: %s
\n
"
,
...
@@ -5972,7 +6002,7 @@ static int32_t prepareStmtWithoutStb(
...
@@ -5972,7 +6002,7 @@ static int32_t prepareStmtWithoutStb(
data_type
[
i
],
data_type
[
i
],
g_args
.
len_of_binary
,
g_args
.
len_of_binary
,
&
ptr
,
&
ptr
,
timePrec
,
pThreadInfo
->
time_precision
,
NULL
))
{
NULL
))
{
return
-
1
;
return
-
1
;
}
}
...
@@ -6000,12 +6030,46 @@ static int32_t prepareStmtWithoutStb(
...
@@ -6000,12 +6030,46 @@ static int32_t prepareStmtWithoutStb(
return
k
;
return
k
;
}
}
static
int32_t
prepareStbStmtBind
(
static
int32_t
prepareStbStmtBindTag
(
char
*
bindArray
,
SSuperTable
*
stbInfo
,
bool
sourceRand
,
char
*
bindArray
,
SSuperTable
*
stbInfo
,
char
*
tagsVal
,
int32_t
timePrec
)
{
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.len_of_binary);
if
(
bindBuffer
==
NULL
)
{
errorPrint
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
g_args
.
len_of_binary
);
return
-
1
;
}
char
data
[
MAX_DATA_SIZE
];
memset
(
data
,
0
,
MAX_DATA_SIZE
);
char
*
ptr
=
data
;
TAOS_BIND
*
tag
;
for
(
int
t
=
0
;
t
<
stbInfo
->
tagCount
;
t
++
)
{
tag
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
t
));
if
(
-
1
==
prepareStmtBindArrayByType
(
tag
,
stbInfo
->
tags
[
t
].
dataType
,
stbInfo
->
tags
[
t
].
dataLen
,
&
ptr
,
timePrec
,
NULL
))
{
free
(
bindBuffer
);
return
-
1
;
}
}
free
(
bindBuffer
);
return
0
;
}
static
int32_t
prepareStbStmtBindRand
(
char
*
bindArray
,
SSuperTable
*
stbInfo
,
int64_t
startTime
,
int32_t
recSeq
,
int64_t
startTime
,
int32_t
recSeq
,
int32_t
timePrec
,
int32_t
timePrec
)
int64_t
samplePos
,
bool
isColumn
)
{
{
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.len_of_binary);
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.len_of_binary);
if
(
bindBuffer
==
NULL
)
{
if
(
bindBuffer
==
NULL
)
{
...
@@ -6020,126 +6084,139 @@ static int32_t prepareStbStmtBind(
...
@@ -6020,126 +6084,139 @@ static int32_t prepareStbStmtBind(
TAOS_BIND
*
bind
;
TAOS_BIND
*
bind
;
if
(
isColumn
)
{
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
+
1
;
i
++
)
{
int
cursor
=
0
;
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
i
))
;
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
+
1
;
i
++
)
{
if
(
i
==
0
)
{
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
i
))
;
int64_t
*
bind_ts
;
if
(
i
==
0
)
{
bind_ts
=
(
int64_t
*
)
ptr
;
int64_t
*
bind_ts
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
if
(
stbInfo
->
disorderRatio
)
{
*
bind_ts
=
startTime
+
getTSRandTail
(
stbInfo
->
timeStampStep
,
recSeq
,
stbInfo
->
disorderRatio
,
stbInfo
->
disorderRange
);
}
else
{
*
bind_ts
=
startTime
+
stbInfo
->
timeStampStep
*
recSeq
;
}
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_ts
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
ptr
+=
bind
->
buffer_length
;
}
else
if
(
-
1
==
prepareStmtBindArrayByType
(
bind
,
stbInfo
->
columns
[
i
-
1
].
dataType
,
stbInfo
->
columns
[
i
-
1
].
dataLen
,
&
ptr
,
timePrec
,
NULL
))
{
tmfree
(
bindBuffer
);
return
-
1
;
}
}
bind_ts
=
(
int64_t
*
)
ptr
;
tmfree
(
bindBuffer
);
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
return
0
;
if
(
stbInfo
->
disorderRatio
)
{
}
*
bind_ts
=
startTime
+
getTSRandTail
(
stbInfo
->
timeStampStep
,
recSeq
,
stbInfo
->
disorderRatio
,
stbInfo
->
disorderRange
);
}
else
{
*
bind_ts
=
startTime
+
stbInfo
->
timeStampStep
*
recSeq
;
}
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_ts
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
ptr
+=
bind
->
buffer_length
;
static
int32_t
prepareStbStmtBindWithSample
(
char
*
bindArray
,
SSuperTable
*
stbInfo
,
int64_t
startTime
,
int32_t
recSeq
,
int32_t
timePrec
,
int64_t
samplePos
)
{
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.len_of_binary);
if
(
bindBuffer
==
NULL
)
{
errorPrint
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
g_args
.
len_of_binary
);
return
-
1
;
}
char
data
[
MAX_DATA_SIZE
];
memset
(
data
,
0
,
MAX_DATA_SIZE
);
char
*
ptr
=
data
;
TAOS_BIND
*
bind
;
int
cursor
=
0
;
for
(
int
i
=
0
;
i
<
stbInfo
->
columnCount
+
1
;
i
++
)
{
bind
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
i
));
if
(
i
==
0
)
{
int64_t
*
bind_ts
;
bind_ts
=
(
int64_t
*
)
ptr
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
if
(
stbInfo
->
disorderRatio
)
{
*
bind_ts
=
startTime
+
getTSRandTail
(
stbInfo
->
timeStampStep
,
recSeq
,
stbInfo
->
disorderRatio
,
stbInfo
->
disorderRange
);
}
else
{
}
else
{
*
bind_ts
=
startTime
+
stbInfo
->
timeStampStep
*
recSeq
;
}
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_ts
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
if
(
sourceRand
)
{
ptr
+=
bind
->
buffer_length
;
if
(
-
1
==
prepareStmtBindArrayByType
(
}
else
{
bind
,
char
*
restStr
=
stbInfo
->
sampleDataBuf
stbInfo
->
columns
[
i
-
1
].
dataType
,
+
stbInfo
->
lenOfOneRow
*
samplePos
+
cursor
;
stbInfo
->
columns
[
i
-
1
].
dataLen
,
int
lengthOfRest
=
strlen
(
restStr
);
&
ptr
,
timePrec
,
NULL
))
{
free
(
bindBuffer
);
return
-
1
;
}
}
else
{
char
*
restStr
=
stbInfo
->
sampleDataBuf
+
stbInfo
->
lenOfOneRow
*
samplePos
+
cursor
;
int
lengthOfRest
=
strlen
(
restStr
);
int
index
=
0
;
for
(
index
=
0
;
index
<
lengthOfRest
;
index
++
)
{
if
(
restStr
[
index
]
==
','
)
{
break
;
}
}
memset
(
bindBuffer
,
0
,
DOUBLE_BUFF_LEN
);
int
index
=
0
;
strncpy
(
bindBuffer
,
restStr
,
index
);
for
(
index
=
0
;
index
<
lengthOfRest
;
index
++
)
{
cursor
+=
index
+
1
;
// skip ',' too
if
(
restStr
[
index
]
==
','
)
{
break
;
if
(
-
1
==
prepareStmtBindArrayByType
(
bind
,
stbInfo
->
columns
[
i
-
1
].
dataType
,
stbInfo
->
columns
[
i
-
1
].
dataLen
,
&
ptr
,
timePrec
,
bindBuffer
))
{
free
(
bindBuffer
);
return
-
1
;
}
}
}
}
}
}
}
else
{
TAOS_BIND
*
tag
;
for
(
int
t
=
0
;
t
<
stbInfo
->
tagCount
;
t
++
)
{
memset
(
bindBuffer
,
0
,
DOUBLE_BUFF_LEN
);
tag
=
(
TAOS_BIND
*
)((
char
*
)
bindArray
+
(
sizeof
(
TAOS_BIND
)
*
t
));
strncpy
(
bindBuffer
,
restStr
,
index
);
cursor
+=
index
+
1
;
// skip ',' too
if
(
-
1
==
prepareStmtBindArrayByType
(
if
(
-
1
==
prepareStmtBindArrayByType
(
tag
,
bind
,
stbInfo
->
tags
[
t
].
dataType
,
stbInfo
->
columns
[
i
-
1
].
dataType
,
stbInfo
->
tags
[
t
].
dataLen
,
stbInfo
->
columns
[
i
-
1
].
dataLen
,
&
ptr
,
&
ptr
,
timePrec
,
timePrec
,
NULL
))
{
bindBuffer
))
{
free
(
bindBuffer
);
free
(
bindBuffer
);
return
-
1
;
return
-
1
;
}
}
}
}
}
}
free
(
bindBuffer
);
free
(
bindBuffer
);
return
0
;
return
0
;
}
}
static
int32_t
prepareStbStmt
(
static
int32_t
prepareStbStmtRand
(
SSuperTable
*
stbInfo
,
threadInfo
*
pThreadInfo
,
TAOS_STMT
*
stmt
,
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
)
int32_t
timePrec
,
int64_t
*
pSamplePos
)
{
{
int
ret
;
int
ret
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
bool
sourceRand
;
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
if
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
sourceRand
=
true
;
}
else
{
sourceRand
=
false
;
// from sample data file
}
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
char
*
tagsValBuf
=
NULL
;
char
*
tagsValBuf
=
NULL
;
bool
tagRand
;
if
(
0
==
stbInfo
->
tagSource
)
{
if
(
0
==
stbInfo
->
tagSource
)
{
tagRand
=
true
;
tagsValBuf
=
generateTagValuesForStb
(
stbInfo
,
tableSeq
);
tagsValBuf
=
generateTagValuesForStb
(
stbInfo
,
tableSeq
);
}
else
{
}
else
{
tagRand
=
false
;
tagsValBuf
=
getTagValueFromTagSample
(
tagsValBuf
=
getTagValueFromTagSample
(
stbInfo
,
stbInfo
,
tableSeq
%
stbInfo
->
tagSampleCount
);
tableSeq
%
stbInfo
->
tagSampleCount
);
...
@@ -6159,11 +6236,9 @@ static int32_t prepareStbStmt(
...
@@ -6159,11 +6236,9 @@ static int32_t prepareStbStmt(
return
-
1
;
return
-
1
;
}
}
if
(
-
1
==
prepareStbStmtBind
(
if
(
-
1
==
prepareStbStmtBindTag
(
tagsArray
,
stbInfo
,
tagRand
,
-
1
,
-
1
,
tagsArray
,
stbInfo
,
tagsValBuf
,
pThreadInfo
->
time_precision
timePrec
,
/* is tag */
))
{
*
pSamplePos
,
false
/* is tag */
))
{
tmfree
(
tagsValBuf
);
tmfree
(
tagsValBuf
);
tmfree
(
tagsArray
);
tmfree
(
tagsArray
);
return
-
1
;
return
-
1
;
...
@@ -6198,11 +6273,10 @@ static int32_t prepareStbStmt(
...
@@ -6198,11 +6273,10 @@ static int32_t prepareStbStmt(
uint32_t
k
;
uint32_t
k
;
for
(
k
=
0
;
k
<
batch
;)
{
for
(
k
=
0
;
k
<
batch
;)
{
/* columnCount + 1 (ts) */
/* columnCount + 1 (ts) */
if
(
-
1
==
prepareStbStmtBind
(
bindArray
,
stbInfo
,
sourceRand
,
if
(
-
1
==
prepareStbStmtBind
Rand
(
bindArray
,
stbInfo
,
startTime
,
k
,
startTime
,
k
,
timePrec
,
pThreadInfo
->
time_precision
*
pSamplePos
,
/* is column */
))
{
true
/* is column */
))
{
free
(
bindArray
);
free
(
bindArray
);
return
-
1
;
return
-
1
;
}
}
...
@@ -6225,13 +6299,6 @@ static int32_t prepareStbStmt(
...
@@ -6225,13 +6299,6 @@ static int32_t prepareStbStmt(
k
++
;
k
++
;
recordFrom
++
;
recordFrom
++
;
if
(
!
sourceRand
)
{
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
pSamplePos
=
0
;
}
}
if
(
recordFrom
>=
insertRows
)
{
if
(
recordFrom
>=
insertRows
)
{
break
;
break
;
}
}
...
@@ -6241,56 +6308,129 @@ static int32_t prepareStbStmt(
...
@@ -6241,56 +6308,129 @@ static int32_t prepareStbStmt(
return
k
;
return
k
;
}
}
static
int32_t
prepareStbStmtInterlace
(
static
int32_t
prepareStbStmtWithSample
(
SSuperTable
*
stbInfo
,
threadInfo
*
pThreadInfo
,
TAOS_STMT
*
stmt
,
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
,
int32_t
timePrec
,
int64_t
*
pSamplePos
)
int64_t
*
pSamplePos
)
{
{
return
prepareStbStmt
(
int
ret
;
stbInfo
,
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
stmt
,
TAOS_STMT
*
stmt
=
pThreadInfo
->
stmt
;
tableName
,
tableSeq
,
batch
,
insertRows
,
0
,
startTime
,
timePrec
,
pSamplePos
);
}
static
int32_t
prepareStbStmtProgressive
(
if
(
AUTO_CREATE_SUBTBL
==
stbInfo
->
autoCreateTable
)
{
SSuperTable
*
stbInfo
,
char
*
tagsValBuf
=
NULL
;
TAOS_STMT
*
stmt
,
char
*
tableName
,
if
(
0
==
stbInfo
->
tagSource
)
{
int64_t
tableSeq
,
tagsValBuf
=
generateTagValuesForStb
(
stbInfo
,
tableSeq
);
uint32_t
batch
,
}
else
{
uint64_t
insertRows
,
tagsValBuf
=
getTagValueFromTagSample
(
uint64_t
recordFrom
,
stbInfo
,
int64_t
startTime
,
tableSeq
%
stbInfo
->
tagSampleCount
);
int32_t
timePrec
,
}
int64_t
*
pSamplePos
)
{
if
(
NULL
==
tagsValBuf
)
{
return
prepareStbStmt
(
errorPrint
(
"%s() LN%d, tag buf failed to allocate memory
\n
"
,
stbInfo
,
__func__
,
__LINE__
);
stmt
,
return
-
1
;
tableName
,
}
tableSeq
,
g_args
.
num_of_RPR
,
char
*
tagsArray
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
stbInfo
->
tagCount
);
insertRows
,
recordFrom
,
startTime
,
if
(
NULL
==
tagsArray
)
{
timePrec
,
tmfree
(
tagsValBuf
);
pSamplePos
);
errorPrint
(
"%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
)
{
errorPrint
(
"%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
)
{
errorPrint
(
"%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
)
{
errorPrint
(
"%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
==
prepareStbStmtBindWithSample
(
bindArray
,
stbInfo
,
startTime
,
k
,
pThreadInfo
->
time_precision
,
*
pSamplePos
/* is column */
))
{
free
(
bindArray
);
return
-
1
;
}
ret
=
taos_stmt_bind_param
(
stmt
,
(
TAOS_BIND
*
)
bindArray
);
if
(
0
!=
ret
)
{
errorPrint
(
"%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
)
{
errorPrint
(
"%s() LN%d, stmt_add_batch() failed! reason: %s
\n
"
,
__func__
,
__LINE__
,
taos_stmt_errstr
(
stmt
));
free
(
bindArray
);
return
-
1
;
}
k
++
;
recordFrom
++
;
(
*
pSamplePos
)
++
;
if
((
*
pSamplePos
)
==
MAX_SAMPLES_ONCE_FROM_FILE
)
{
*
pSamplePos
=
0
;
}
if
(
recordFrom
>=
insertRows
)
{
break
;
}
}
free
(
bindArray
);
return
k
;
}
}
#endif
#endif
static
int32_t
generateStbProgressiveData
(
static
int32_t
generateStbProgressiveData
(
SSuperTable
*
s
uperTbl
Info
,
SSuperTable
*
s
tb
Info
,
char
*
tableName
,
char
*
tableName
,
int64_t
tableSeq
,
int64_t
tableSeq
,
char
*
dbName
,
char
*
buffer
,
char
*
dbName
,
char
*
buffer
,
...
@@ -6304,7 +6444,7 @@ static int32_t generateStbProgressiveData(
...
@@ -6304,7 +6444,7 @@ static int32_t generateStbProgressiveData(
memset
(
pstr
,
0
,
*
pRemainderBufLen
);
memset
(
pstr
,
0
,
*
pRemainderBufLen
);
int64_t
headLen
=
generateStbSQLHead
(
int64_t
headLen
=
generateStbSQLHead
(
s
uperTbl
Info
,
s
tb
Info
,
tableName
,
tableSeq
,
dbName
,
tableName
,
tableSeq
,
dbName
,
buffer
,
*
pRemainderBufLen
);
buffer
,
*
pRemainderBufLen
);
...
@@ -6316,7 +6456,7 @@ static int32_t generateStbProgressiveData(
...
@@ -6316,7 +6456,7 @@ static int32_t generateStbProgressiveData(
int64_t
dataLen
;
int64_t
dataLen
;
return
generateStbDataTail
(
s
uperTbl
Info
,
return
generateStbDataTail
(
s
tb
Info
,
g_args
.
num_of_RPR
,
pstr
,
*
pRemainderBufLen
,
g_args
.
num_of_RPR
,
pstr
,
*
pRemainderBufLen
,
insertRows
,
recordFrom
,
insertRows
,
recordFrom
,
startTime
,
startTime
,
...
@@ -6376,26 +6516,34 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -6376,26 +6516,34 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
int64_t
nTimeStampStep
;
int64_t
nTimeStampStep
;
uint64_t
insert_interval
;
uint64_t
insert_interval
;
SSuperTable
*
superTblInfo
=
pThreadInfo
->
superTblInfo
;
bool
sourceRand
;
SSuperTable
*
stbInfo
=
pThreadInfo
->
stbInfo
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
insertRows
=
s
uperTbl
Info
->
insertRows
;
insertRows
=
s
tb
Info
->
insertRows
;
if
((
s
uperTbl
Info
->
interlaceRows
==
0
)
if
((
s
tb
Info
->
interlaceRows
==
0
)
&&
(
g_args
.
interlace_rows
>
0
))
{
&&
(
g_args
.
interlace_rows
>
0
))
{
interlaceRows
=
g_args
.
interlace_rows
;
interlaceRows
=
g_args
.
interlace_rows
;
}
else
{
}
else
{
interlaceRows
=
superTblInfo
->
interlaceRows
;
interlaceRows
=
stbInfo
->
interlaceRows
;
}
maxSqlLen
=
stbInfo
->
maxSqlLen
;
nTimeStampStep
=
stbInfo
->
timeStampStep
;
insert_interval
=
stbInfo
->
insertInterval
;
if
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"rand"
,
4
))
{
sourceRand
=
true
;
}
else
{
sourceRand
=
false
;
// from sample data file
}
}
maxSqlLen
=
superTblInfo
->
maxSqlLen
;
nTimeStampStep
=
superTblInfo
->
timeStampStep
;
insert_interval
=
superTblInfo
->
insertInterval
;
}
else
{
}
else
{
insertRows
=
g_args
.
num_of_DPT
;
insertRows
=
g_args
.
num_of_DPT
;
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
;
insert_interval
=
g_args
.
insert_interval
;
insert_interval
=
g_args
.
insert_interval
;
sourceRand
=
true
;
}
}
debugPrint
(
"[%d] %s() LN%d: start_table_from=%"
PRIu64
" ntables=%"
PRId64
" insertRows=%"
PRIu64
"
\n
"
,
debugPrint
(
"[%d] %s() LN%d: start_table_from=%"
PRIu64
" ntables=%"
PRId64
" insertRows=%"
PRIu64
"
\n
"
,
...
@@ -6475,29 +6623,38 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -6475,29 +6623,38 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
uint64_t
oldRemainderLen
=
remainderBufLen
;
uint64_t
oldRemainderLen
=
remainderBufLen
;
int32_t
generated
;
int32_t
generated
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
if
(
s
uperTbl
Info
->
iface
==
STMT_IFACE
)
{
if
(
s
tb
Info
->
iface
==
STMT_IFACE
)
{
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
generated
=
prepareStbStmtInterlace
(
if
(
sourceRand
)
{
superTblInfo
,
generated
=
prepareStbStmtRand
(
pThreadInfo
->
stmt
,
pThreadInfo
,
tableName
,
tableName
,
tableSeq
,
tableSeq
,
batchPerTbl
,
batchPerTbl
,
insertRows
,
i
,
insertRows
,
0
,
startTime
,
startTime
pThreadInfo
->
time_precision
,
);
&
(
pThreadInfo
->
samplePos
));
}
else
{
generated
=
prepareStbStmtWithSample
(
pThreadInfo
,
tableName
,
tableSeq
,
batchPerTbl
,
insertRows
,
0
,
startTime
,
&
(
pThreadInfo
->
samplePos
));
}
#else
#else
generated
=
-
1
;
generated
=
-
1
;
#endif
#endif
}
else
{
}
else
{
generated
=
generateStbInterlaceData
(
generated
=
generateStbInterlaceData
(
superTbl
Info
,
pThread
Info
,
tableName
,
batchPerTbl
,
i
,
tableName
,
batchPerTbl
,
i
,
batchPerTblTimes
,
batchPerTblTimes
,
tableSeq
,
tableSeq
,
p
ThreadInfo
,
p
str
,
pstr
,
insertRows
,
insertRows
,
startTime
,
startTime
,
&
remainderBufLen
);
&
remainderBufLen
);
...
@@ -6510,10 +6667,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -6510,10 +6667,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
tableName
,
batchPerTbl
,
startTime
);
tableName
,
batchPerTbl
,
startTime
);
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
generated
=
prepareStmtWithoutStb
(
generated
=
prepareStmtWithoutStb
(
pThreadInfo
->
stmt
,
tableName
,
pThreadInfo
,
tableName
,
batchPerTbl
,
batchPerTbl
,
insertRows
,
i
,
insertRows
,
i
,
pThreadInfo
->
time_precision
,
startTime
);
startTime
);
#else
#else
generated
=
-
1
;
generated
=
-
1
;
...
@@ -6653,12 +6810,12 @@ free_of_interlace:
...
@@ -6653,12 +6810,12 @@ free_of_interlace:
static
void
*
syncWriteProgressive
(
threadInfo
*
pThreadInfo
)
{
static
void
*
syncWriteProgressive
(
threadInfo
*
pThreadInfo
)
{
debugPrint
(
"%s() LN%d: ### progressive write
\n
"
,
__func__
,
__LINE__
);
debugPrint
(
"%s() LN%d: ### progressive write
\n
"
,
__func__
,
__LINE__
);
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
uint64_t
maxSqlLen
=
s
uperTblInfo
?
superTbl
Info
->
maxSqlLen
:
g_args
.
max_sql_len
;
uint64_t
maxSqlLen
=
s
tbInfo
?
stb
Info
->
maxSqlLen
:
g_args
.
max_sql_len
;
int64_t
timeStampStep
=
int64_t
timeStampStep
=
s
uperTblInfo
?
superTbl
Info
->
timeStampStep
:
g_args
.
timestamp_step
;
s
tbInfo
?
stb
Info
->
timeStampStep
:
g_args
.
timestamp_step
;
int64_t
insertRows
=
int64_t
insertRows
=
(
s
uperTblInfo
)
?
superTbl
Info
->
insertRows
:
g_args
.
num_of_DPT
;
(
s
tbInfo
)
?
stb
Info
->
insertRows
:
g_args
.
num_of_DPT
;
verbosePrint
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
verbosePrint
(
"%s() LN%d insertRows=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
insertRows
);
__func__
,
__LINE__
,
insertRows
);
...
@@ -6677,6 +6834,17 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -6677,6 +6834,17 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
pThreadInfo
->
totalInsertRows
=
0
;
pThreadInfo
->
totalInsertRows
=
0
;
pThreadInfo
->
totalAffectedRows
=
0
;
pThreadInfo
->
totalAffectedRows
=
0
;
bool
sourceRand
;
if
(
stbInfo
)
{
if
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"rand"
,
4
))
{
sourceRand
=
true
;
}
else
{
sourceRand
=
false
;
// from sample data file
}
}
else
{
sourceRand
=
true
;
}
pThreadInfo
->
samplePos
=
0
;
pThreadInfo
->
samplePos
=
0
;
for
(
uint64_t
tableSeq
=
pThreadInfo
->
start_table_from
;
for
(
uint64_t
tableSeq
=
pThreadInfo
->
start_table_from
;
...
@@ -6707,25 +6875,35 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -6707,25 +6875,35 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
remainderBufLen
-=
len
;
remainderBufLen
-=
len
;
int32_t
generated
;
int32_t
generated
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
if
(
s
uperTbl
Info
->
iface
==
STMT_IFACE
)
{
if
(
s
tb
Info
->
iface
==
STMT_IFACE
)
{
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
generated
=
prepareStbStmtProgressive
(
if
(
sourceRand
)
{
superTblInfo
,
generated
=
prepareStbStmtRand
(
pThreadInfo
->
stmt
,
pThreadInfo
,
tableName
,
tableName
,
tableSeq
,
tableSeq
,
g_args
.
num_of_RPR
,
g_args
.
num_of_RPR
,
insertRows
,
i
,
start_time
,
insertRows
,
pThreadInfo
->
time_precision
,
i
,
start_time
&
(
pThreadInfo
->
samplePos
));
);
}
else
{
generated
=
prepareStbStmtWithSample
(
pThreadInfo
,
tableName
,
tableSeq
,
g_args
.
num_of_RPR
,
insertRows
,
i
,
start_time
,
&
(
pThreadInfo
->
samplePos
));
}
#else
#else
generated
=
-
1
;
generated
=
-
1
;
#endif
#endif
}
else
{
}
else
{
generated
=
generateStbProgressiveData
(
generated
=
generateStbProgressiveData
(
superTblInfo
,
stbInfo
,
tableName
,
tableSeq
,
pThreadInfo
->
db_name
,
pstr
,
tableName
,
tableSeq
,
pThreadInfo
->
db_name
,
pstr
,
insertRows
,
i
,
start_time
,
insertRows
,
i
,
start_time
,
&
(
pThreadInfo
->
samplePos
),
&
(
pThreadInfo
->
samplePos
),
&
remainderBufLen
);
&
remainderBufLen
);
...
@@ -6734,11 +6912,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -6734,11 +6912,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
if
(
g_args
.
iface
==
STMT_IFACE
)
{
if
(
g_args
.
iface
==
STMT_IFACE
)
{
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
generated
=
prepareStmtWithoutStb
(
generated
=
prepareStmtWithoutStb
(
pThreadInfo
->
stmt
,
pThreadInfo
,
tableName
,
tableName
,
g_args
.
num_of_RPR
,
g_args
.
num_of_RPR
,
insertRows
,
i
,
insertRows
,
i
,
pThreadInfo
->
time_precision
,
start_time
);
start_time
);
#else
#else
generated
=
-
1
;
generated
=
-
1
;
...
@@ -6800,9 +6977,9 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -6800,9 +6977,9 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
}
// num_of_DPT
}
// num_of_DPT
if
((
g_args
.
verbose_print
)
&&
if
((
g_args
.
verbose_print
)
&&
(
tableSeq
==
pThreadInfo
->
ntables
-
1
)
&&
(
s
uperTbl
Info
)
(
tableSeq
==
pThreadInfo
->
ntables
-
1
)
&&
(
s
tb
Info
)
&&
(
0
==
strncasecmp
(
&&
(
0
==
strncasecmp
(
s
uperTbl
Info
->
dataSource
,
s
tb
Info
->
dataSource
,
"sample"
,
strlen
(
"sample"
))))
{
"sample"
,
strlen
(
"sample"
))))
{
verbosePrint
(
"%s() LN%d samplePos=%"
PRId64
"
\n
"
,
verbosePrint
(
"%s() LN%d samplePos=%"
PRId64
"
\n
"
,
__func__
,
__LINE__
,
pThreadInfo
->
samplePos
);
__func__
,
__LINE__
,
pThreadInfo
->
samplePos
);
...
@@ -6818,18 +6995,18 @@ free_of_progressive:
...
@@ -6818,18 +6995,18 @@ free_of_progressive:
static
void
*
syncWrite
(
void
*
sarg
)
{
static
void
*
syncWrite
(
void
*
sarg
)
{
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
setThreadName
(
"syncWrite"
);
setThreadName
(
"syncWrite"
);
uint32_t
interlaceRows
;
uint32_t
interlaceRows
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
if
((
s
uperTbl
Info
->
interlaceRows
==
0
)
if
((
s
tb
Info
->
interlaceRows
==
0
)
&&
(
g_args
.
interlace_rows
>
0
))
{
&&
(
g_args
.
interlace_rows
>
0
))
{
interlaceRows
=
g_args
.
interlace_rows
;
interlaceRows
=
g_args
.
interlace_rows
;
}
else
{
}
else
{
interlaceRows
=
s
uperTbl
Info
->
interlaceRows
;
interlaceRows
=
s
tb
Info
->
interlaceRows
;
}
}
}
else
{
}
else
{
interlaceRows
=
g_args
.
interlace_rows
;
interlaceRows
=
g_args
.
interlace_rows
;
...
@@ -6846,10 +7023,10 @@ static void* syncWrite(void *sarg) {
...
@@ -6846,10 +7023,10 @@ static void* syncWrite(void *sarg) {
static
void
callBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
static
void
callBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
param
;
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
param
;
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
int
insert_interval
=
int
insert_interval
=
s
uperTblInfo
?
superTbl
Info
->
insertInterval
:
g_args
.
insert_interval
;
s
tbInfo
?
stb
Info
->
insertInterval
:
g_args
.
insert_interval
;
if
(
insert_interval
)
{
if
(
insert_interval
)
{
pThreadInfo
->
et
=
taosGetTimestampMs
();
pThreadInfo
->
et
=
taosGetTimestampMs
();
if
((
pThreadInfo
->
et
-
pThreadInfo
->
st
)
<
insert_interval
)
{
if
((
pThreadInfo
->
et
-
pThreadInfo
->
st
)
<
insert_interval
)
{
...
@@ -6857,13 +7034,13 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -6857,13 +7034,13 @@ static void callBack(void *param, TAOS_RES *res, int code) {
}
}
}
}
char
*
buffer
=
calloc
(
1
,
pThreadInfo
->
s
uperTbl
Info
->
maxSqlLen
);
char
*
buffer
=
calloc
(
1
,
pThreadInfo
->
s
tb
Info
->
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->s
uperTbl
Info->insertRows) {
// if (pThreadInfo->counter >= pThreadInfo->s
tb
Info->insertRows) {
if
(
pThreadInfo
->
counter
>=
g_args
.
num_of_RPR
)
{
if
(
pThreadInfo
->
counter
>=
g_args
.
num_of_RPR
)
{
pThreadInfo
->
start_table_from
++
;
pThreadInfo
->
start_table_from
++
;
pThreadInfo
->
counter
=
0
;
pThreadInfo
->
counter
=
0
;
...
@@ -6877,15 +7054,15 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -6877,15 +7054,15 @@ static void callBack(void *param, TAOS_RES *res, int code) {
for
(
int
i
=
0
;
i
<
g_args
.
num_of_RPR
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_args
.
num_of_RPR
;
i
++
)
{
int
rand_num
=
taosRandom
()
%
100
;
int
rand_num
=
taosRandom
()
%
100
;
if
(
0
!=
pThreadInfo
->
s
uperTbl
Info
->
disorderRatio
if
(
0
!=
pThreadInfo
->
s
tb
Info
->
disorderRatio
&&
rand_num
<
pThreadInfo
->
s
uperTbl
Info
->
disorderRatio
)
{
&&
rand_num
<
pThreadInfo
->
s
tb
Info
->
disorderRatio
)
{
int64_t
d
=
pThreadInfo
->
lastTs
int64_t
d
=
pThreadInfo
->
lastTs
-
(
taosRandom
()
%
pThreadInfo
->
s
uperTbl
Info
->
disorderRange
+
1
);
-
(
taosRandom
()
%
pThreadInfo
->
s
tb
Info
->
disorderRange
+
1
);
generateStbRowData
(
pThreadInfo
->
s
uperTbl
Info
,
data
,
generateStbRowData
(
pThreadInfo
->
s
tb
Info
,
data
,
MAX_DATA_SIZE
,
MAX_DATA_SIZE
,
d
);
d
);
}
else
{
}
else
{
generateStbRowData
(
pThreadInfo
->
s
uperTbl
Info
,
generateStbRowData
(
pThreadInfo
->
s
tb
Info
,
data
,
data
,
MAX_DATA_SIZE
,
MAX_DATA_SIZE
,
pThreadInfo
->
lastTs
+=
1000
);
pThreadInfo
->
lastTs
+=
1000
);
...
@@ -6893,7 +7070,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -6893,7 +7070,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
pstr
+=
sprintf
(
pstr
,
"%s"
,
data
);
pstr
+=
sprintf
(
pstr
,
"%s"
,
data
);
pThreadInfo
->
counter
++
;
pThreadInfo
->
counter
++
;
if
(
pThreadInfo
->
counter
>=
pThreadInfo
->
s
uperTbl
Info
->
insertRows
)
{
if
(
pThreadInfo
->
counter
>=
pThreadInfo
->
s
tb
Info
->
insertRows
)
{
break
;
break
;
}
}
}
}
...
@@ -6909,7 +7086,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -6909,7 +7086,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
static
void
*
asyncWrite
(
void
*
sarg
)
{
static
void
*
asyncWrite
(
void
*
sarg
)
{
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
threadInfo
*
pThreadInfo
=
(
threadInfo
*
)
sarg
;
SSuperTable
*
s
uperTblInfo
=
pThreadInfo
->
superTbl
Info
;
SSuperTable
*
s
tbInfo
=
pThreadInfo
->
stb
Info
;
setThreadName
(
"asyncWrite"
);
setThreadName
(
"asyncWrite"
);
...
@@ -6918,7 +7095,7 @@ static void *asyncWrite(void *sarg) {
...
@@ -6918,7 +7095,7 @@ static void *asyncWrite(void *sarg) {
pThreadInfo
->
lastTs
=
pThreadInfo
->
start_time
;
pThreadInfo
->
lastTs
=
pThreadInfo
->
start_time
;
int
insert_interval
=
int
insert_interval
=
s
uperTblInfo
?
superTbl
Info
->
insertInterval
:
g_args
.
insert_interval
;
s
tbInfo
?
stb
Info
->
insertInterval
:
g_args
.
insert_interval
;
if
(
insert_interval
)
{
if
(
insert_interval
)
{
pThreadInfo
->
st
=
taosGetTimestampMs
();
pThreadInfo
->
st
=
taosGetTimestampMs
();
}
}
...
@@ -6956,15 +7133,86 @@ static int convertHostToServAddr(char *host, uint16_t port, struct sockaddr_in *
...
@@ -6956,15 +7133,86 @@ static int convertHostToServAddr(char *host, uint16_t port, struct sockaddr_in *
}
}
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
static
void
parseSampleFileToStmt
(
)
static
int
parseSampleFileToStmt
(
SSuperTable
*
stbInfo
,
uint32_t
timePrec
)
{
{
// TODO:
// TODO:
stbInfo
->
sampleBindArray
=
calloc
(
sizeof
(
char
*
),
MAX_SAMPLES_ONCE_FROM_FILE
);
assert
(
stbInfo
->
sampleBindArray
);
char
*
bindBuffer
=
calloc
(
1
,
DOUBLE_BUFF_LEN
);
// g_args.len_of_binary);
if
(
bindBuffer
==
NULL
)
{
errorPrint
(
"%s() LN%d, Failed to allocate %d bind buffer
\n
"
,
__func__
,
__LINE__
,
g_args
.
len_of_binary
);
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
)
{
errorPrint
(
"%s() LN%d, Failed to allocate %d bind params
\n
"
,
__func__
,
__LINE__
,
(
stbInfo
->
columnCount
+
1
));
return
-
1
;
}
char
data
[
MAX_DATA_SIZE
];
memset
(
data
,
0
,
MAX_DATA_SIZE
);
char
*
ptr
=
data
;
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
)
{
int64_t
*
bind_ts
;
bind_ts
=
(
int64_t
*
)
ptr
;
bind
->
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
bind
->
buffer_length
=
sizeof
(
int64_t
);
bind
->
buffer
=
bind_ts
;
bind
->
length
=
&
bind
->
buffer_length
;
bind
->
is_null
=
NULL
;
ptr
+=
bind
->
buffer_length
;
}
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
;
}
}
memset
(
bindBuffer
,
0
,
DOUBLE_BUFF_LEN
);
strncpy
(
bindBuffer
,
restStr
,
index
);
cursor
+=
index
+
1
;
// skip ',' too
if
(
-
1
==
prepareStmtBindArrayByType
(
bind
,
stbInfo
->
columns
[
c
-
1
].
dataType
,
stbInfo
->
columns
[
c
-
1
].
dataLen
,
&
ptr
,
timePrec
,
bindBuffer
))
{
free
(
bindBuffer
);
return
-
1
;
}
}
}
*
((
uintptr_t
*
)(
stbInfo
->
sampleBindArray
+
(
sizeof
(
char
*
))
*
i
))
=
(
uintptr_t
)
bindArray
;
}
free
(
bindBuffer
);
return
0
;
}
}
#endif
#endif
static
void
startMultiThreadInsertData
(
int
threads
,
char
*
db_name
,
static
void
startMultiThreadInsertData
(
int
threads
,
char
*
db_name
,
char
*
precision
,
SSuperTable
*
s
uperTbl
Info
)
{
char
*
precision
,
SSuperTable
*
s
tb
Info
)
{
int32_t
timePrec
=
TSDB_TIME_PRECISION_MILLI
;
int32_t
timePrec
=
TSDB_TIME_PRECISION_MILLI
;
if
(
0
!=
precision
[
0
])
{
if
(
0
!=
precision
[
0
])
{
...
@@ -6983,14 +7231,14 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -6983,14 +7231,14 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
}
int64_t
start_time
;
int64_t
start_time
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
if
(
0
==
strncasecmp
(
s
uperTbl
Info
->
startTimestamp
,
"now"
,
3
))
{
if
(
0
==
strncasecmp
(
s
tb
Info
->
startTimestamp
,
"now"
,
3
))
{
start_time
=
taosGetTimestamp
(
timePrec
);
start_time
=
taosGetTimestamp
(
timePrec
);
}
else
{
}
else
{
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
s
uperTbl
Info
->
startTimestamp
,
s
tb
Info
->
startTimestamp
,
&
start_time
,
&
start_time
,
strlen
(
s
uperTbl
Info
->
startTimestamp
),
strlen
(
s
tb
Info
->
startTimestamp
),
timePrec
,
0
))
{
timePrec
,
0
))
{
ERROR_EXIT
(
"failed to parse time!
\n
"
);
ERROR_EXIT
(
"failed to parse time!
\n
"
);
}
}
...
@@ -7004,9 +7252,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7004,9 +7252,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t
start
=
taosGetTimestampMs
();
int64_t
start
=
taosGetTimestampMs
();
// read sample data from file first
// read sample data from file first
if
((
s
uperTblInfo
)
&&
(
0
==
strncasecmp
(
superTbl
Info
->
dataSource
,
if
((
s
tbInfo
)
&&
(
0
==
strncasecmp
(
stb
Info
->
dataSource
,
"sample"
,
strlen
(
"sample"
))))
{
"sample"
,
strlen
(
"sample"
))))
{
if
(
0
!=
prepareSampleDataForSTable
(
s
uperTbl
Info
))
{
if
(
0
!=
prepareSampleDataForSTable
(
s
tb
Info
))
{
errorPrint
(
"%s() LN%d, prepare sample data for stable failed!
\n
"
,
errorPrint
(
"%s() LN%d, prepare sample data for stable failed!
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
exit
(
-
1
);
exit
(
-
1
);
...
@@ -7025,52 +7273,52 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7025,52 +7273,52 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t
ntables
=
0
;
int64_t
ntables
=
0
;
uint64_t
tableFrom
;
uint64_t
tableFrom
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
int64_t
limit
;
int64_t
limit
;
uint64_t
offset
;
uint64_t
offset
;
if
((
NULL
!=
g_args
.
sqlFile
)
if
((
NULL
!=
g_args
.
sqlFile
)
&&
(
s
uperTbl
Info
->
childTblExists
==
TBL_NO_EXISTS
)
&&
(
s
tb
Info
->
childTblExists
==
TBL_NO_EXISTS
)
&&
((
s
uperTbl
Info
->
childTblOffset
!=
0
)
&&
((
s
tb
Info
->
childTblOffset
!=
0
)
||
(
s
uperTbl
Info
->
childTblLimit
>=
0
)))
{
||
(
s
tb
Info
->
childTblLimit
>=
0
)))
{
printf
(
"WARNING: offset and limit will not be used since the child tables not exists!
\n
"
);
printf
(
"WARNING: offset and limit will not be used since the child tables not exists!
\n
"
);
}
}
if
(
s
uperTbl
Info
->
childTblExists
==
TBL_ALREADY_EXISTS
)
{
if
(
s
tb
Info
->
childTblExists
==
TBL_ALREADY_EXISTS
)
{
if
((
s
uperTbl
Info
->
childTblLimit
<
0
)
if
((
s
tb
Info
->
childTblLimit
<
0
)
||
((
s
uperTbl
Info
->
childTblOffset
||
((
s
tb
Info
->
childTblOffset
+
s
uperTbl
Info
->
childTblLimit
)
+
s
tb
Info
->
childTblLimit
)
>
(
s
uperTbl
Info
->
childTblCount
)))
{
>
(
s
tb
Info
->
childTblCount
)))
{
s
uperTbl
Info
->
childTblLimit
=
s
tb
Info
->
childTblLimit
=
s
uperTblInfo
->
childTblCount
-
superTbl
Info
->
childTblOffset
;
s
tbInfo
->
childTblCount
-
stb
Info
->
childTblOffset
;
}
}
offset
=
s
uperTbl
Info
->
childTblOffset
;
offset
=
s
tb
Info
->
childTblOffset
;
limit
=
s
uperTbl
Info
->
childTblLimit
;
limit
=
s
tb
Info
->
childTblLimit
;
}
else
{
}
else
{
limit
=
s
uperTbl
Info
->
childTblCount
;
limit
=
s
tb
Info
->
childTblCount
;
offset
=
0
;
offset
=
0
;
}
}
ntables
=
limit
;
ntables
=
limit
;
tableFrom
=
offset
;
tableFrom
=
offset
;
if
((
s
uperTbl
Info
->
childTblExists
!=
TBL_NO_EXISTS
)
if
((
s
tb
Info
->
childTblExists
!=
TBL_NO_EXISTS
)
&&
((
s
uperTblInfo
->
childTblOffset
+
superTblInfo
->
childTblLimit
)
&&
((
s
tbInfo
->
childTblOffset
+
stbInfo
->
childTblLimit
)
>
s
uperTbl
Info
->
childTblCount
))
{
>
s
tb
Info
->
childTblCount
))
{
printf
(
"WARNING: specified offset + limit > child table count!
\n
"
);
printf
(
"WARNING: specified offset + limit > child table count!
\n
"
);
prompt
();
prompt
();
}
}
if
((
s
uperTbl
Info
->
childTblExists
!=
TBL_NO_EXISTS
)
if
((
s
tb
Info
->
childTblExists
!=
TBL_NO_EXISTS
)
&&
(
0
==
s
uperTbl
Info
->
childTblLimit
))
{
&&
(
0
==
s
tb
Info
->
childTblLimit
))
{
printf
(
"WARNING: specified limit = 0, which cannot find table name to insert or query!
\n
"
);
printf
(
"WARNING: specified limit = 0, which cannot find table name to insert or query!
\n
"
);
prompt
();
prompt
();
}
}
s
uperTbl
Info
->
childTblName
=
(
char
*
)
calloc
(
1
,
s
tb
Info
->
childTblName
=
(
char
*
)
calloc
(
1
,
limit
*
TSDB_TABLE_NAME_LEN
);
limit
*
TSDB_TABLE_NAME_LEN
);
if
(
s
uperTbl
Info
->
childTblName
==
NULL
)
{
if
(
s
tb
Info
->
childTblName
==
NULL
)
{
errorPrint
(
"%s() LN%d, alloc memory failed!
\n
"
,
__func__
,
__LINE__
);
errorPrint
(
"%s() LN%d, alloc memory failed!
\n
"
,
__func__
,
__LINE__
);
taos_close
(
taos0
);
taos_close
(
taos0
);
exit
(
-
1
);
exit
(
-
1
);
...
@@ -7079,8 +7327,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7079,8 +7327,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t
childTblCount
;
int64_t
childTblCount
;
getChildNameOfSuperTableWithLimitAndOffset
(
getChildNameOfSuperTableWithLimitAndOffset
(
taos0
,
taos0
,
db_name
,
s
uperTbl
Info
->
sTblName
,
db_name
,
s
tb
Info
->
sTblName
,
&
s
uperTbl
Info
->
childTblName
,
&
childTblCount
,
&
s
tb
Info
->
childTblName
,
&
childTblCount
,
limit
,
limit
,
offset
);
offset
);
}
else
{
}
else
{
...
@@ -7101,8 +7349,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7101,8 +7349,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
b
=
ntables
%
threads
;
b
=
ntables
%
threads
;
}
}
if
((
s
uperTbl
Info
)
if
((
s
tb
Info
)
&&
(
s
uperTbl
Info
->
iface
==
REST_IFACE
))
{
&&
(
s
tb
Info
->
iface
==
REST_IFACE
))
{
if
(
convertHostToServAddr
(
if
(
convertHostToServAddr
(
g_Dbs
.
host
,
g_Dbs
.
port
,
&
(
g_Dbs
.
serv_addr
))
!=
0
)
{
g_Dbs
.
host
,
g_Dbs
.
port
,
&
(
g_Dbs
.
serv_addr
))
!=
0
)
{
exit
(
-
1
);
exit
(
-
1
);
...
@@ -7122,16 +7370,16 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7122,16 +7370,16 @@ 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
((
g_args
.
iface
==
STMT_IFACE
)
if
((
g_args
.
iface
==
STMT_IFACE
)
||
((
s
uperTbl
Info
)
||
((
s
tb
Info
)
&&
(
s
uperTbl
Info
->
iface
==
STMT_IFACE
)))
{
&&
(
s
tb
Info
->
iface
==
STMT_IFACE
)))
{
char
*
pstr
=
stmtBuffer
;
char
*
pstr
=
stmtBuffer
;
if
((
s
uperTbl
Info
)
if
((
s
tb
Info
)
&&
(
AUTO_CREATE_SUBTBL
&&
(
AUTO_CREATE_SUBTBL
==
s
uperTbl
Info
->
autoCreateTable
))
{
==
s
tb
Info
->
autoCreateTable
))
{
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? USING %s TAGS(?"
,
pstr
+=
sprintf
(
pstr
,
"INSERT INTO ? USING %s TAGS(?"
,
s
uperTbl
Info
->
sTblName
);
s
tb
Info
->
sTblName
);
for
(
int
tag
=
0
;
tag
<
(
s
uperTbl
Info
->
tagCount
-
1
);
for
(
int
tag
=
0
;
tag
<
(
s
tb
Info
->
tagCount
-
1
);
tag
++
)
{
tag
++
)
{
pstr
+=
sprintf
(
pstr
,
",?"
);
pstr
+=
sprintf
(
pstr
,
",?"
);
}
}
...
@@ -7141,8 +7389,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7141,8 +7389,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
}
int
columnCount
;
int
columnCount
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
columnCount
=
s
uperTbl
Info
->
columnCount
;
columnCount
=
s
tb
Info
->
columnCount
;
}
else
{
}
else
{
columnCount
=
g_args
.
num_of_CPR
;
columnCount
=
g_args
.
num_of_CPR
;
}
}
...
@@ -7154,7 +7402,10 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7154,7 +7402,10 @@ static void startMultiThreadInsertData(int threads, char* db_name,
debugPrint
(
"%s() LN%d, stmtBuffer: %s"
,
__func__
,
__LINE__
,
stmtBuffer
);
debugPrint
(
"%s() LN%d, stmtBuffer: %s"
,
__func__
,
__LINE__
,
stmtBuffer
);
parseSampleFileToStmt
();
if
((
stbInfo
)
&&
(
0
==
strncasecmp
(
stbInfo
->
dataSource
,
"sample"
,
strlen
(
"sample"
))))
{
parseSampleFileToStmt
(
stbInfo
,
timePrec
);
}
}
}
#endif
#endif
...
@@ -7164,13 +7415,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7164,13 +7415,13 @@ static void startMultiThreadInsertData(int threads, char* db_name,
tstrncpy
(
pThreadInfo
->
db_name
,
db_name
,
TSDB_DB_NAME_LEN
);
tstrncpy
(
pThreadInfo
->
db_name
,
db_name
,
TSDB_DB_NAME_LEN
);
pThreadInfo
->
time_precision
=
timePrec
;
pThreadInfo
->
time_precision
=
timePrec
;
pThreadInfo
->
s
uperTblInfo
=
superTbl
Info
;
pThreadInfo
->
s
tbInfo
=
stb
Info
;
pThreadInfo
->
start_time
=
start_time
;
pThreadInfo
->
start_time
=
start_time
;
pThreadInfo
->
minDelay
=
UINT64_MAX
;
pThreadInfo
->
minDelay
=
UINT64_MAX
;
if
((
NULL
==
s
uperTbl
Info
)
||
if
((
NULL
==
s
tb
Info
)
||
(
s
uperTbl
Info
->
iface
!=
REST_IFACE
))
{
(
s
tb
Info
->
iface
!=
REST_IFACE
))
{
//t_info->taos = taos;
//t_info->taos = taos;
pThreadInfo
->
taos
=
taos_connect
(
pThreadInfo
->
taos
=
taos_connect
(
g_Dbs
.
host
,
g_Dbs
.
user
,
g_Dbs
.
host
,
g_Dbs
.
user
,
...
@@ -7186,8 +7437,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7186,8 +7437,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
#if STMT_IFACE_ENABLED == 1
#if STMT_IFACE_ENABLED == 1
if
((
g_args
.
iface
==
STMT_IFACE
)
if
((
g_args
.
iface
==
STMT_IFACE
)
||
((
s
uperTbl
Info
)
||
((
s
tb
Info
)
&&
(
s
uperTbl
Info
->
iface
==
STMT_IFACE
)))
{
&&
(
s
tb
Info
->
iface
==
STMT_IFACE
)))
{
pThreadInfo
->
stmt
=
taos_stmt_init
(
pThreadInfo
->
taos
);
pThreadInfo
->
stmt
=
taos_stmt_init
(
pThreadInfo
->
taos
);
...
@@ -7216,8 +7467,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7216,8 +7467,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
pThreadInfo
->
taos
=
NULL
;
pThreadInfo
->
taos
=
NULL
;
}
}
/* if ((NULL == s
uperTbl
Info)
/* if ((NULL == s
tb
Info)
|| (0 == s
uperTbl
Info->multiThreadWriteOneTbl)) {
|| (0 == s
tb
Info->multiThreadWriteOneTbl)) {
*/
*/
pThreadInfo
->
start_table_from
=
tableFrom
;
pThreadInfo
->
start_table_from
=
tableFrom
;
pThreadInfo
->
ntables
=
i
<
b
?
a
+
1
:
a
;
pThreadInfo
->
ntables
=
i
<
b
?
a
+
1
:
a
;
...
@@ -7225,7 +7476,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7225,7 +7476,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
tableFrom
=
pThreadInfo
->
end_table_to
+
1
;
/* } else {
/* } else {
pThreadInfo->start_table_from = 0;
pThreadInfo->start_table_from = 0;
pThreadInfo->ntables = s
uperTbl
Info->childTblCount;
pThreadInfo->ntables = s
tb
Info->childTblCount;
pThreadInfo->start_time = pThreadInfo->start_time + rand_int() % 10000 - rand_tinyint();
pThreadInfo->start_time = pThreadInfo->start_time + rand_int() % 10000 - rand_tinyint();
}
}
*/
*/
...
@@ -7268,9 +7519,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7268,9 +7519,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
__func__
,
__LINE__
,
__func__
,
__LINE__
,
pThreadInfo
->
threadID
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
threadID
,
pThreadInfo
->
totalInsertRows
,
pThreadInfo
->
totalAffectedRows
);
pThreadInfo
->
totalAffectedRows
);
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
s
uperTbl
Info
->
totalAffectedRows
+=
pThreadInfo
->
totalAffectedRows
;
s
tb
Info
->
totalAffectedRows
+=
pThreadInfo
->
totalAffectedRows
;
s
uperTbl
Info
->
totalInsertRows
+=
pThreadInfo
->
totalInsertRows
;
s
tb
Info
->
totalInsertRows
+=
pThreadInfo
->
totalInsertRows
;
}
else
{
}
else
{
g_args
.
totalAffectedRows
+=
pThreadInfo
->
totalAffectedRows
;
g_args
.
totalAffectedRows
+=
pThreadInfo
->
totalAffectedRows
;
g_args
.
totalInsertRows
+=
pThreadInfo
->
totalInsertRows
;
g_args
.
totalInsertRows
+=
pThreadInfo
->
totalInsertRows
;
...
@@ -7291,22 +7542,22 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -7291,22 +7542,22 @@ static void startMultiThreadInsertData(int threads, char* db_name,
double
tInMs
=
t
/
1000
.
0
;
double
tInMs
=
t
/
1000
.
0
;
if
(
s
uperTbl
Info
)
{
if
(
s
tb
Info
)
{
fprintf
(
stderr
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
fprintf
(
stderr
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
tInMs
,
s
uperTbl
Info
->
totalInsertRows
,
tInMs
,
s
tb
Info
->
totalInsertRows
,
s
uperTbl
Info
->
totalAffectedRows
,
s
tb
Info
->
totalAffectedRows
,
threads
,
db_name
,
s
uperTbl
Info
->
sTblName
,
threads
,
db_name
,
s
tb
Info
->
sTblName
,
(
tInMs
)
?
(
tInMs
)
?
(
double
)(
s
uperTbl
Info
->
totalInsertRows
/
tInMs
)
:
FLT_MAX
);
(
double
)(
s
tb
Info
->
totalInsertRows
/
tInMs
)
:
FLT_MAX
);
if
(
g_fpOfInsertResult
)
{
if
(
g_fpOfInsertResult
)
{
fprintf
(
g_fpOfInsertResult
,
fprintf
(
g_fpOfInsertResult
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s.%s. %.2f records/second
\n\n
"
,
tInMs
,
s
uperTbl
Info
->
totalInsertRows
,
tInMs
,
s
tb
Info
->
totalInsertRows
,
s
uperTbl
Info
->
totalAffectedRows
,
s
tb
Info
->
totalAffectedRows
,
threads
,
db_name
,
s
uperTbl
Info
->
sTblName
,
threads
,
db_name
,
s
tb
Info
->
sTblName
,
(
tInMs
)
?
(
tInMs
)
?
(
double
)(
s
uperTbl
Info
->
totalInsertRows
/
tInMs
)
:
FLT_MAX
);
(
double
)(
s
tb
Info
->
totalInsertRows
/
tInMs
)
:
FLT_MAX
);
}
}
}
else
{
}
else
{
fprintf
(
stderr
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s %.2f records/second
\n\n
"
,
fprintf
(
stderr
,
"Spent %.2f seconds to insert rows: %"
PRIu64
", affected rows: %"
PRIu64
" with %d thread(s) into %s %.2f records/second
\n\n
"
,
...
@@ -7361,8 +7612,8 @@ static void *readTable(void *sarg) {
...
@@ -7361,8 +7612,8 @@ static void *readTable(void *sarg) {
}
}
int64_t
num_of_DPT
;
int64_t
num_of_DPT
;
/* if (pThreadInfo->s
uperTbl
Info) {
/* if (pThreadInfo->s
tb
Info) {
num_of_DPT = pThreadInfo->s
uperTbl
Info->insertRows; // nrecords_per_table;
num_of_DPT = pThreadInfo->s
tb
Info->insertRows; // nrecords_per_table;
} else {
} else {
*/
*/
num_of_DPT
=
g_args
.
num_of_DPT
;
num_of_DPT
=
g_args
.
num_of_DPT
;
...
@@ -7436,7 +7687,7 @@ static void *readMetric(void *sarg) {
...
@@ -7436,7 +7687,7 @@ static void *readMetric(void *sarg) {
return
NULL
;
return
NULL
;
}
}
int64_t
num_of_DPT
=
pThreadInfo
->
s
uperTbl
Info
->
insertRows
;
int64_t
num_of_DPT
=
pThreadInfo
->
s
tb
Info
->
insertRows
;
int64_t
num_of_tables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
num_of_tables
=
pThreadInfo
->
ntables
;
// rinfo->end_table_to - rinfo->start_table_from + 1;
int64_t
totalData
=
num_of_DPT
*
num_of_tables
;
int64_t
totalData
=
num_of_DPT
*
num_of_tables
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
bool
do_aggreFunc
=
g_Dbs
.
do_aggreFunc
;
...
@@ -7575,14 +7826,14 @@ static int insertTestProcess() {
...
@@ -7575,14 +7826,14 @@ static int insertTestProcess() {
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
SSuperTable
*
s
uperTbl
Info
=
&
g_Dbs
.
db
[
i
].
superTbls
[
j
];
SSuperTable
*
s
tb
Info
=
&
g_Dbs
.
db
[
i
].
superTbls
[
j
];
if
(
s
uperTblInfo
&&
(
superTbl
Info
->
insertRows
>
0
))
{
if
(
s
tbInfo
&&
(
stb
Info
->
insertRows
>
0
))
{
startMultiThreadInsertData
(
startMultiThreadInsertData
(
g_Dbs
.
threadCount
,
g_Dbs
.
threadCount
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
dbName
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
g_Dbs
.
db
[
i
].
dbCfg
.
precision
,
s
uperTbl
Info
);
s
tb
Info
);
}
}
}
}
}
}
...
@@ -8697,7 +8948,7 @@ static void queryResult() {
...
@@ -8697,7 +8948,7 @@ static void queryResult() {
if
(
g_args
.
use_metric
)
{
if
(
g_args
.
use_metric
)
{
pThreadInfo
->
ntables
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
;
pThreadInfo
->
ntables
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
;
pThreadInfo
->
end_table_to
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
-
1
;
pThreadInfo
->
end_table_to
=
g_Dbs
.
db
[
0
].
superTbls
[
0
].
childTblCount
-
1
;
pThreadInfo
->
s
uperTbl
Info
=
&
g_Dbs
.
db
[
0
].
superTbls
[
0
];
pThreadInfo
->
s
tb
Info
=
&
g_Dbs
.
db
[
0
].
superTbls
[
0
];
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
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录