Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
1b638069
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
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[] = {
{
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
,
'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
'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'
P
'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
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'
,
0
,
0
,
"Use metric flag."
,
13
},
{
0
,
'o'
,
"outputfile"
,
0
,
"Direct output to the named file. Default is './output.txt'."
,
14
},
...
...
@@ -64,6 +64,8 @@ static struct argp_option options[] = {
{
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
,
'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
}};
/* Used by main to communicate with parse_opt. */
...
...
@@ -86,6 +88,8 @@ typedef struct DemoArguments {
int
num_of_tables
;
int
num_of_DPT
;
int
abort
;
int
order
;
int
rate
;
char
**
arg_list
;
}
SDemoArguments
;
...
...
@@ -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
]);
wordfree
(
&
full_path
);
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
:
arguments
->
abort
=
1
;
break
;
...
...
@@ -217,6 +239,8 @@ typedef struct {
int
ncols_per_record
;
int
nrecords_per_table
;
int
nrecords_per_request
;
int
data_of_order
;
int
data_of_rate
;
int64_t
start_time
;
bool
do_aggreFunc
;
...
...
@@ -296,6 +320,8 @@ int main(int argc, char *argv[]) {
1
,
// num_of_tables
50000
,
// num_of_DPT
0
,
// abort
0
,
// order
0
,
// rate
NULL
// arg_list
};
...
...
@@ -330,6 +356,8 @@ int main(int argc, char *argv[]) {
char
*
tb_prefix
=
arguments
.
tb_prefix
;
int
len_of_binary
=
arguments
.
len_of_binary
;
int
ncols_per_record
=
arguments
.
num_of_CPR
;
int
order
=
arguments
.
order
;
int
rate
=
arguments
.
rate
;
int
ntables
=
arguments
.
num_of_tables
;
int
threads
=
arguments
.
num_of_threads
;
int
nrecords_per_table
=
arguments
.
num_of_DPT
;
...
...
@@ -377,6 +405,12 @@ int main(int argc, char *argv[]) {
printf
(
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
printf
(
"# Database name: %s
\n
"
,
db_name
);
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
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
printf
(
"###################################################################
\n\n
"
);
...
...
@@ -507,6 +541,8 @@ int main(int argc, char *argv[]) {
t_info
->
len_of_binary
=
len_of_binary
;
t_info
->
nrecords_per_request
=
nrecords_per_request
;
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
;
last
=
t_info
->
end_table_id
+
1
;
...
...
@@ -735,7 +771,15 @@ void *syncWrite(void *sarg) {
pstr
+=
sprintf
(
pstr
,
"insert into %s.%s%d values"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
tID
);
int
k
;
for
(
k
=
0
;
k
<
winfo
->
nrecords_per_request
;)
{
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
);
inserted
++
;
k
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录