Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f9f28d03
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
提交
f9f28d03
编写于
5月 29, 2020
作者:
S
Shuaiqiang Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add del tables
上级
bb3b6d1e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
6 deletion
+74
-6
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+74
-6
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
f9f28d03
...
...
@@ -64,8 +64,9 @@ 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
,
'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
,
'D'
,
"delete table"
,
0
,
"Delete data methods——0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database"
,
1
},
{
0
}};
/* Used by main to communicate with parse_opt. */
...
...
@@ -90,6 +91,7 @@ typedef struct DemoArguments {
int
abort
;
int
order
;
int
rate
;
int
method_of_delete
;
char
**
arg_list
;
}
SDemoArguments
;
...
...
@@ -200,12 +202,18 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
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
'D'
:
arguments
->
method_of_delete
=
atoi
(
arg
);
if
(
arguments
->
method_of_delete
<
0
||
arguments
->
method_of_delete
>
3
)
{
arguments
->
method_of_delete
=
0
;
}
break
;
case
OPT_ABORT
:
arguments
->
abort
=
1
;
break
;
...
...
@@ -284,6 +292,8 @@ void *readMetric(void *sarg);
void
*
syncWrite
(
void
*
sarg
);
void
*
deleteTable
();
void
*
asyncWrite
(
void
*
sarg
);
void
generateData
(
char
*
res
,
char
**
data_type
,
int
num_of_cols
,
int64_t
timestamp
,
int
len_of_binary
);
...
...
@@ -324,6 +334,7 @@ int main(int argc, char *argv[]) {
0
,
// abort
0
,
// order
0
,
// rate
0
,
// method_of_delete
NULL
// arg_list
};
...
...
@@ -360,6 +371,7 @@ int main(int argc, char *argv[]) {
int
ncols_per_record
=
arguments
.
num_of_CPR
;
int
order
=
arguments
.
order
;
int
rate
=
arguments
.
rate
;
int
method_of_delete
=
arguments
.
method_of_delete
;
int
ntables
=
arguments
.
num_of_tables
;
int
threads
=
arguments
.
num_of_threads
;
int
nrecords_per_table
=
arguments
.
num_of_DPT
;
...
...
@@ -409,10 +421,11 @@ int main(int argc, char *argv[]) {
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
(
"# Data order: %d
\n
"
,
order
);
printf
(
"# Data out of order rate: %d
\n
"
,
rate
);
}
printf
(
"# Delete method: %d
\n
"
,
method_of_delete
);
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
"
);
...
...
@@ -428,12 +441,18 @@ int main(int argc, char *argv[]) {
fprintf
(
fp
,
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
fprintf
(
fp
,
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
fprintf
(
fp
,
"# Number of Threads: %d
\n
"
,
threads
);
fprintf
(
fp
,
"# Number of Threads:
%d
\n
"
,
threads
);
fprintf
(
fp
,
"# Number of Tables: %d
\n
"
,
ntables
);
fprintf
(
fp
,
"# Number of Data per Table: %d
\n
"
,
nrecords_per_table
);
fprintf
(
fp
,
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
fprintf
(
fp
,
"# Database name: %s
\n
"
,
db_name
);
fprintf
(
fp
,
"# Table prefix: %s
\n
"
,
tb_prefix
);
if
(
order
==
1
)
{
printf
(
"# Data order: %d
\n
"
,
order
);
printf
(
"# Data out of order rate: %d
\n
"
,
rate
);
}
fprintf
(
fp
,
"# 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
);
fprintf
(
fp
,
"###################################################################
\n\n
"
);
...
...
@@ -589,6 +608,55 @@ int main(int argc, char *argv[]) {
free
(
infos
);
fclose
(
fp
);
if
(
method_of_delete
!=
0
)
{
TAOS
*
dtaos
=
taos_connect
(
ip_addr
,
user
,
pass
,
db_name
,
port
);
double
dts
=
getCurrentTime
();
printf
(
"Deleteing %d table(s)......
\n
"
,
ntables
);
switch
(
method_of_delete
)
{
case
1
:
// delete by table
/* Create all the tables; */
for
(
int
i
=
0
;
i
<
ntables
;
i
++
)
{
sprintf
(
command
,
"drop table %s.%s%d;"
,
db_name
,
tb_prefix
,
i
);
queryDB
(
dtaos
,
command
);
}
break
;
case
2
:
// delete by stable
if
(
!
use_metric
)
{
break
;
}
else
{
sprintf
(
command
,
"drop table %s.meters;"
,
db_name
);
queryDB
(
dtaos
,
command
);
}
break
;
case
3
:
// delete by database
sprintf
(
command
,
"drop database %s;"
,
db_name
);
queryDB
(
dtaos
,
command
);
break
;
default:
break
;
}
printf
(
"Table(s) droped!
\n
"
);
taos_close
(
dtaos
);
double
dt
=
getCurrentTime
()
-
dts
;
printf
(
"Spent %.4f seconds to drop %d tables
\n
"
,
dt
,
ntables
);
FILE
*
fp
=
fopen
(
arguments
.
output_file
,
"a"
);
fprintf
(
fp
,
"Spent %.4f seconds to drop %d tables
\n
"
,
dt
,
ntables
);
fclose
(
fp
);
}
if
(
!
insert_only
)
{
// query data
pthread_t
read_id
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录