Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1b638069
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1b638069
编写于
5月 28, 2020
作者:
S
Shuaiqiang Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add out of order data
上级
03335a74
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
4 deletion
+48
-4
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+48
-4
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
1b638069
...
@@ -49,8 +49,8 @@ static struct argp_option options[] = {
...
@@ -49,8 +49,8 @@ static struct argp_option options[] = {
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TDEngine. Default is localhost."
,
0
},
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TDEngine. Default is localhost."
,
0
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'u'
,
"user"
,
0
,
"The TDEngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'u'
,
"user"
,
0
,
"The TDEngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'
a
'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'
P
'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'
P
'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'
d
'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
{
0
,
'M'
,
0
,
0
,
"Use metric flag."
,
13
},
{
0
,
'M'
,
0
,
0
,
"Use metric flag."
,
13
},
{
0
,
'o'
,
"outputfile"
,
0
,
"Direct output to the named file. Default is './output.txt'."
,
14
},
{
0
,
'o'
,
"outputfile"
,
0
,
"Direct output to the named file. Default is './output.txt'."
,
14
},
...
@@ -58,12 +58,14 @@ static struct argp_option options[] = {
...
@@ -58,12 +58,14 @@ static struct argp_option options[] = {
{
0
,
'b'
,
"type_of_cols"
,
0
,
"The data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."
,
7
},
{
0
,
'b'
,
"type_of_cols"
,
0
,
"The data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."
,
7
},
{
0
,
'w'
,
"length_of_binary"
,
0
,
"The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"
,
8
},
{
0
,
'w'
,
"length_of_binary"
,
0
,
"The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"
,
8
},
{
0
,
'l'
,
"num_of_cols_per_record"
,
0
,
"The number of columns per record. Default is 3."
,
8
},
{
0
,
'l'
,
"num_of_cols_per_record"
,
0
,
"The number of columns per record. Default is 3."
,
8
},
{
0
,
'T'
,
"num_of_threads"
,
0
,
"The number of threads. Default is 10."
,
9
},
{
0
,
'T'
,
"num_of_threads"
,
0
,
"The number of threads. Default is 10."
,
9
},
{
0
,
'r'
,
"num_of_records_per_req"
,
0
,
"The number of records per request. Default is 1000."
,
10
},
{
0
,
'r'
,
"num_of_records_per_req"
,
0
,
"The number of records per request. Default is 1000."
,
10
},
{
0
,
't'
,
"num_of_tables"
,
0
,
"The number of tables. Default is 10000."
,
11
},
{
0
,
't'
,
"num_of_tables"
,
0
,
"The number of tables. Default is 10000."
,
11
},
{
0
,
'n'
,
"num_of_records_per_table"
,
0
,
"The number of records per table. Default is 100000."
,
12
},
{
0
,
'n'
,
"num_of_records_per_table"
,
0
,
"The number of records per table. Default is 100000."
,
12
},
{
0
,
'c'
,
"config_directory"
,
0
,
"Configuration directory. Default is '/etc/taos/'."
,
14
},
{
0
,
'c'
,
"config_directory"
,
0
,
"Configuration directory. Default is '/etc/taos/'."
,
14
},
{
0
,
'x'
,
0
,
0
,
"Insert only flag."
,
13
},
{
0
,
'x'
,
0
,
0
,
"Insert only flag."
,
13
},
{
0
,
'O'
,
"order"
,
0
,
"Insert mode--0: In order, 1: Out of order. Default is in order"
,
1
},
{
0
,
'R'
,
"rate"
,
0
,
"Out of order data's rate--if order=1 Default 10"
,
1
},
{
0
}};
{
0
}};
/* Used by main to communicate with parse_opt. */
/* Used by main to communicate with parse_opt. */
...
@@ -86,6 +88,8 @@ typedef struct DemoArguments {
...
@@ -86,6 +88,8 @@ typedef struct DemoArguments {
int
num_of_tables
;
int
num_of_tables
;
int
num_of_DPT
;
int
num_of_DPT
;
int
abort
;
int
abort
;
int
order
;
int
rate
;
char
**
arg_list
;
char
**
arg_list
;
}
SDemoArguments
;
}
SDemoArguments
;
...
@@ -184,6 +188,24 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -184,6 +188,24 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
taos_options
(
TSDB_OPTION_CONFIGDIR
,
full_path
.
we_wordv
[
0
]);
taos_options
(
TSDB_OPTION_CONFIGDIR
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
break
;
break
;
case
'O'
:
arguments
->
order
=
atoi
(
arg
);
if
(
arguments
->
order
>
1
||
arguments
->
order
<
0
)
{
arguments
->
order
=
0
;
}
else
if
(
arguments
->
order
==
1
)
{
arguments
->
rate
=
10
;
}
break
;
case
'R'
:
arguments
->
rate
=
atoi
(
arg
);
printf
(
"%d"
,
arguments
->
rate
);
if
(
arguments
->
order
==
1
&&
(
arguments
->
rate
>
50
||
arguments
->
rate
<=
0
))
{
arguments
->
rate
=
10
;
}
break
;
case
OPT_ABORT
:
case
OPT_ABORT
:
arguments
->
abort
=
1
;
arguments
->
abort
=
1
;
break
;
break
;
...
@@ -217,6 +239,8 @@ typedef struct {
...
@@ -217,6 +239,8 @@ typedef struct {
int
ncols_per_record
;
int
ncols_per_record
;
int
nrecords_per_table
;
int
nrecords_per_table
;
int
nrecords_per_request
;
int
nrecords_per_request
;
int
data_of_order
;
int
data_of_rate
;
int64_t
start_time
;
int64_t
start_time
;
bool
do_aggreFunc
;
bool
do_aggreFunc
;
...
@@ -296,6 +320,8 @@ int main(int argc, char *argv[]) {
...
@@ -296,6 +320,8 @@ int main(int argc, char *argv[]) {
1
,
// num_of_tables
1
,
// num_of_tables
50000
,
// num_of_DPT
50000
,
// num_of_DPT
0
,
// abort
0
,
// abort
0
,
// order
0
,
// rate
NULL
// arg_list
NULL
// arg_list
};
};
...
@@ -330,6 +356,8 @@ int main(int argc, char *argv[]) {
...
@@ -330,6 +356,8 @@ int main(int argc, char *argv[]) {
char
*
tb_prefix
=
arguments
.
tb_prefix
;
char
*
tb_prefix
=
arguments
.
tb_prefix
;
int
len_of_binary
=
arguments
.
len_of_binary
;
int
len_of_binary
=
arguments
.
len_of_binary
;
int
ncols_per_record
=
arguments
.
num_of_CPR
;
int
ncols_per_record
=
arguments
.
num_of_CPR
;
int
order
=
arguments
.
order
;
int
rate
=
arguments
.
rate
;
int
ntables
=
arguments
.
num_of_tables
;
int
ntables
=
arguments
.
num_of_tables
;
int
threads
=
arguments
.
num_of_threads
;
int
threads
=
arguments
.
num_of_threads
;
int
nrecords_per_table
=
arguments
.
num_of_DPT
;
int
nrecords_per_table
=
arguments
.
num_of_DPT
;
...
@@ -377,6 +405,12 @@ int main(int argc, char *argv[]) {
...
@@ -377,6 +405,12 @@ int main(int argc, char *argv[]) {
printf
(
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
printf
(
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
printf
(
"# Database name: %s
\n
"
,
db_name
);
printf
(
"# Database name: %s
\n
"
,
db_name
);
printf
(
"# Table prefix: %s
\n
"
,
tb_prefix
);
printf
(
"# Table prefix: %s
\n
"
,
tb_prefix
);
if
(
order
==
1
)
{
printf
(
"# Data order: %d
\n
"
,
order
);
printf
(
"# Data out of order rate: %d
\n
"
,
rate
);
}
printf
(
"# Test time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
printf
(
"# Test time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
printf
(
"###################################################################
\n\n
"
);
printf
(
"###################################################################
\n\n
"
);
...
@@ -507,6 +541,8 @@ int main(int argc, char *argv[]) {
...
@@ -507,6 +541,8 @@ int main(int argc, char *argv[]) {
t_info
->
len_of_binary
=
len_of_binary
;
t_info
->
len_of_binary
=
len_of_binary
;
t_info
->
nrecords_per_request
=
nrecords_per_request
;
t_info
->
nrecords_per_request
=
nrecords_per_request
;
t_info
->
start_table_id
=
last
;
t_info
->
start_table_id
=
last
;
t_info
->
data_of_order
=
order
;
t_info
->
data_of_rate
=
rate
;
t_info
->
end_table_id
=
i
<
b
?
last
+
a
:
last
+
a
-
1
;
t_info
->
end_table_id
=
i
<
b
?
last
+
a
:
last
+
a
-
1
;
last
=
t_info
->
end_table_id
+
1
;
last
=
t_info
->
end_table_id
+
1
;
...
@@ -735,7 +771,15 @@ void *syncWrite(void *sarg) {
...
@@ -735,7 +771,15 @@ void *syncWrite(void *sarg) {
pstr
+=
sprintf
(
pstr
,
"insert into %s.%s%d values"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
tID
);
pstr
+=
sprintf
(
pstr
,
"insert into %s.%s%d values"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
tID
);
int
k
;
int
k
;
for
(
k
=
0
;
k
<
winfo
->
nrecords_per_request
;)
{
for
(
k
=
0
;
k
<
winfo
->
nrecords_per_request
;)
{
generateData
(
data
,
data_type
,
ncols_per_record
,
tmp_time
++
,
len_of_binary
);
int
rand_num
=
rand
()
%
100
;
if
(
winfo
->
data_of_order
==
1
&&
rand_num
<
winfo
->
data_of_rate
)
{
printf
(
"insert out of order data: %d, time: %ld
\n
"
,
rand_num
,
tmp_time
-
rand
()
%
100000
);
generateData
(
data
,
data_type
,
ncols_per_record
,
tmp_time
-
rand
()
%
1000
,
len_of_binary
);
}
else
{
generateData
(
data
,
data_type
,
ncols_per_record
,
tmp_time
++
,
len_of_binary
);
}
pstr
+=
sprintf
(
pstr
,
" %s"
,
data
);
pstr
+=
sprintf
(
pstr
,
" %s"
,
data
);
inserted
++
;
inserted
++
;
k
++
;
k
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录