Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
87cdb1c5
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87cdb1c5
编写于
5月 26, 2020
作者:
S
Shuaiqiang Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: taosdemo params error
上级
dfbe9ace
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
26 deletion
+28
-26
importSampleData/app/main.go
importSampleData/app/main.go
+3
-1
importSampleData/bin/taosimport
importSampleData/bin/taosimport
+0
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+25
-25
未找到文件。
importSampleData/app/main.go
浏览文件 @
87cdb1c5
...
...
@@ -18,7 +18,7 @@ import (
"sync"
"time"
_
"github.com/taosdata/TDengine/src/connector/go/
src/
taosSql"
_
"github.com/taosdata/TDengine/src/connector/go/taosSql"
)
const
(
...
...
@@ -634,6 +634,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows []
if
appendRows
==
batch
{
// executebatch
insertSql
:=
buffers
.
String
()
connection
.
Exec
(
"use "
+
db
)
affectedRows
:=
executeBatchInsert
(
insertSql
,
connection
)
successRows
[
threadIndex
]
+=
affectedRows
...
...
@@ -658,6 +659,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows []
if
appendRows
>
0
{
// executebatch
insertSql
:=
buffers
.
String
()
connection
.
Exec
(
"use "
+
db
)
affectedRows
:=
executeBatchInsert
(
insertSql
,
connection
)
successRows
[
threadIndex
]
+=
affectedRows
...
...
importSampleData/bin/taosimport
浏览文件 @
87cdb1c5
无法预览此类型文件
src/kit/taosdemo/taosdemo.c
浏览文件 @
87cdb1c5
...
...
@@ -50,7 +50,7 @@ static struct argp_option options[] = {
{
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
,
'
d
'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'
P
'
,
"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
},
...
...
@@ -58,11 +58,11 @@ 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
,
'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
,
'
c'
,
"num_of_conns"
,
0
,
"The number of connection
s. Default is 10."
,
9
},
{
0
,
'
T'
,
"num_of_threads"
,
0
,
"The number of thread
s. Default is 10."
,
9
},
{
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
,
'n'
,
"num_of_records_per_table"
,
0
,
"The number of records per table. Default is 100000."
,
12
},
{
0
,
'
f
'
,
"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
}};
...
...
@@ -81,7 +81,7 @@ typedef struct DemoArguments {
char
*
datatype
[
MAX_NUM_DATATYPE
];
int
len_of_binary
;
int
num_of_CPR
;
int
num_of_
connection
s
;
int
num_of_
thread
s
;
int
num_of_RPR
;
int
num_of_tables
;
int
num_of_DPT
;
...
...
@@ -106,7 +106,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'u'
:
arguments
->
user
=
arg
;
break
;
case
'
a
'
:
case
'
P
'
:
arguments
->
password
=
arg
;
break
;
case
'o'
:
...
...
@@ -115,8 +115,8 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'q'
:
arguments
->
mode
=
atoi
(
arg
);
break
;
case
'
c
'
:
arguments
->
num_of_
connection
s
=
atoi
(
arg
);
case
'
T
'
:
arguments
->
num_of_
thread
s
=
atoi
(
arg
);
break
;
case
'r'
:
arguments
->
num_of_RPR
=
atoi
(
arg
);
...
...
@@ -176,7 +176,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'x'
:
arguments
->
insert_only
=
true
;
break
;
case
'
f
'
:
case
'
c
'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
return
-
1
;
...
...
@@ -291,7 +291,7 @@ int main(int argc, char *argv[]) {
},
8
,
// len_of_binary
1
,
// num_of_CPR
1
,
// num_of_connections
1
,
// num_of_connections
/thread
1
,
// num_of_RPR
1
,
// num_of_tables
50000
,
// num_of_DPT
...
...
@@ -304,7 +304,7 @@ int main(int argc, char *argv[]) {
// For demo use, change default values for some parameters;
arguments
.
num_of_tables
=
10000
;
arguments
.
num_of_CPR
=
3
;
arguments
.
num_of_
connection
s
=
10
;
arguments
.
num_of_
thread
s
=
10
;
arguments
.
num_of_DPT
=
100000
;
arguments
.
num_of_RPR
=
1000
;
arguments
.
use_metric
=
true
;
...
...
@@ -331,7 +331,7 @@ int main(int argc, char *argv[]) {
int
len_of_binary
=
arguments
.
len_of_binary
;
int
ncols_per_record
=
arguments
.
num_of_CPR
;
int
ntables
=
arguments
.
num_of_tables
;
int
nconnections
=
arguments
.
num_of_connection
s
;
int
threads
=
arguments
.
num_of_thread
s
;
int
nrecords_per_table
=
arguments
.
num_of_DPT
;
int
nrecords_per_request
=
arguments
.
num_of_RPR
;
bool
use_metric
=
arguments
.
use_metric
;
...
...
@@ -371,7 +371,7 @@ int main(int argc, char *argv[]) {
printf
(
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
printf
(
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
printf
(
"# Number of
Connections: %d
\n
"
,
nconnection
s
);
printf
(
"# Number of
Threads: %d
\n
"
,
thread
s
);
printf
(
"# Number of Tables: %d
\n
"
,
ntables
);
printf
(
"# Number of Data per Table: %d
\n
"
,
nrecords_per_table
);
printf
(
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
...
...
@@ -392,7 +392,7 @@ 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
Connections: %d
\n
"
,
nconnection
s
);
fprintf
(
fp
,
"# Number of
Threads: %d
\n
"
,
thread
s
);
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
);
...
...
@@ -414,7 +414,7 @@ int main(int argc, char *argv[]) {
sprintf
(
command
,
"drop database %s;"
,
db_name
);
taos_query
(
taos
,
command
);
sleep
(
3
);
sprintf
(
command
,
"create database %s;"
,
db_name
);
taos_query
(
taos
,
command
);
...
...
@@ -479,22 +479,22 @@ int main(int argc, char *argv[]) {
taos_close
(
taos
);
}
/* Wait for table to create */
sleep
(
5
);
/* Insert data */
double
ts
=
getCurrentTime
();
printf
(
"Inserting data......
\n
"
);
pthread_t
*
pids
=
malloc
(
nconnection
s
*
sizeof
(
pthread_t
));
info
*
infos
=
malloc
(
nconnection
s
*
sizeof
(
info
));
pthread_t
*
pids
=
malloc
(
thread
s
*
sizeof
(
pthread_t
));
info
*
infos
=
malloc
(
thread
s
*
sizeof
(
info
));
int
a
=
ntables
/
nconnection
s
;
int
a
=
ntables
/
thread
s
;
if
(
a
<
1
)
{
nconnection
s
=
ntables
;
thread
s
=
ntables
;
a
=
1
;
}
int
b
=
ntables
%
nconnection
s
;
int
b
=
ntables
%
thread
s
;
int
last
=
0
;
for
(
int
i
=
0
;
i
<
nconnection
s
;
i
++
)
{
for
(
int
i
=
0
;
i
<
thread
s
;
i
++
)
{
info
*
t_info
=
infos
+
i
;
t_info
->
threadID
=
i
;
strcpy
(
t_info
->
db_name
,
db_name
);
...
...
@@ -520,15 +520,15 @@ int main(int argc, char *argv[]) {
pthread_create
(
pids
+
i
,
NULL
,
asyncWrite
,
t_info
);
}
}
for
(
int
i
=
0
;
i
<
nconnection
s
;
i
++
)
{
for
(
int
i
=
0
;
i
<
thread
s
;
i
++
)
{
pthread_join
(
pids
[
i
],
NULL
);
}
double
t
=
getCurrentTime
()
-
ts
;
if
(
query_mode
==
SYNC
)
{
printf
(
"SYNC Insert with %d connections:
\n
"
,
nconnection
s
);
printf
(
"SYNC Insert with %d connections:
\n
"
,
thread
s
);
}
else
{
printf
(
"ASYNC Insert with %d connections:
\n
"
,
nconnection
s
);
printf
(
"ASYNC Insert with %d connections:
\n
"
,
thread
s
);
}
fprintf
(
fp
,
"|%10.d | %10.2f | %10.2f | %10.4f |
\n\n
"
,
...
...
@@ -540,7 +540,7 @@ int main(int argc, char *argv[]) {
t
,
ntables
*
nrecords_per_table
,
nrecords_per_request
,
ntables
*
nrecords_per_table
/
t
);
for
(
int
i
=
0
;
i
<
nconnection
s
;
i
++
)
{
for
(
int
i
=
0
;
i
<
thread
s
;
i
++
)
{
info
*
t_info
=
infos
+
i
;
taos_close
(
t_info
->
taos
);
sem_destroy
(
&
(
t_info
->
mutex_sem
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录