Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
dbd4c222
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
dbd4c222
编写于
8月 06, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
8月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2949 from taosdata/feature/pyconn
Feature/pyconn
上级
64a06ba9
44111892
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
14 deletion
+18
-14
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+18
-14
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
dbd4c222
...
@@ -42,10 +42,10 @@ extern char configDir[];
...
@@ -42,10 +42,10 @@ extern char configDir[];
#define BUFFER_SIZE 65536
#define BUFFER_SIZE 65536
#define MAX_DB_NAME_SIZE 64
#define MAX_DB_NAME_SIZE 64
#define MAX_TB_NAME_SIZE 64
#define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE 1
024
#define MAX_DATA_SIZE 1
6000
#define MAX_NUM_DATATYPE
3
0
#define MAX_NUM_DATATYPE
1
0
#define OPT_ABORT 1
/* –abort */
#define OPT_ABORT 1
/* –abort */
#define STRING_LEN
512
#define STRING_LEN
60000
#define MAX_PREPARED_RAND 1000000
#define MAX_PREPARED_RAND 1000000
/* The options we understand. */
/* The options we understand. */
...
@@ -155,7 +155,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -155,7 +155,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
strcasecmp
(
arg
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BOOL"
)
!=
0
&&
strcasecmp
(
arg
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BOOL"
)
!=
0
&&
strcasecmp
(
arg
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
arg
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
arg
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
arg
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
arg
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
arg
,
"BINARY"
))
{
strcasecmp
(
arg
,
"BINARY"
)
&&
strcasecmp
(
arg
,
"NCHAR"
)
)
{
argp_error
(
state
,
"Invalid data_type!"
);
argp_error
(
state
,
"Invalid data_type!"
);
}
}
sptr
[
0
]
=
arg
;
sptr
[
0
]
=
arg
;
...
@@ -171,11 +171,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -171,11 +171,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
strcasecmp
(
token
,
"BOOL"
)
!=
0
&&
strcasecmp
(
token
,
"BOOL"
)
!=
0
&&
strcasecmp
(
token
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
token
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
token
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
token
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
token
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
token
,
"BINARY"
))
{
strcasecmp
(
token
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"NCHAR"
)
)
{
argp_error
(
state
,
"Invalid data_type!"
);
argp_error
(
state
,
"Invalid data_type!"
);
}
}
sptr
[
index
++
]
=
token
;
sptr
[
index
++
]
=
token
;
token
=
strsep
(
&
running
,
",
"
);
token
=
strsep
(
&
running
,
","
);
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
}
}
}
}
...
@@ -412,7 +412,7 @@ int main(int argc, char *argv[]) {
...
@@ -412,7 +412,7 @@ int main(int argc, char *argv[]) {
memset
(
dataString
,
0
,
STRING_LEN
);
memset
(
dataString
,
0
,
STRING_LEN
);
int
len
=
0
;
int
len
=
0
;
if
(
strcasecmp
(
data_type
[
0
],
"BINARY"
)
==
0
||
strcasecmp
(
data_type
[
0
],
"BOOL"
)
==
0
)
{
if
(
strcasecmp
(
data_type
[
0
],
"BINARY"
)
==
0
||
strcasecmp
(
data_type
[
0
],
"BOOL"
)
==
0
||
strcasecmp
(
data_type
[
0
],
"NCHAR"
)
==
0
)
{
do_aggreFunc
=
false
;
do_aggreFunc
=
false
;
}
}
for
(;
count_data_type
<=
MAX_NUM_DATATYPE
;
count_data_type
++
)
{
for
(;
count_data_type
<=
MAX_NUM_DATATYPE
;
count_data_type
++
)
{
...
@@ -438,7 +438,7 @@ int main(int argc, char *argv[]) {
...
@@ -438,7 +438,7 @@ int main(int argc, char *argv[]) {
printf
(
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
printf
(
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
printf
(
"# Datatype of Columns: %s
\n
"
,
dataString
);
printf
(
"# Datatype of Columns: %s
\n
"
,
dataString
);
printf
(
"# Binary Length(If applicable): %d
\n
"
,
printf
(
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
||
strcasestr
(
dataString
,
"NCHAR"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
printf
(
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
printf
(
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
printf
(
"# Number of Threads: %d
\n
"
,
threads
);
printf
(
"# Number of Threads: %d
\n
"
,
threads
);
printf
(
"# Number of Tables: %d
\n
"
,
ntables
);
printf
(
"# Number of Tables: %d
\n
"
,
ntables
);
...
@@ -466,7 +466,7 @@ int main(int argc, char *argv[]) {
...
@@ -466,7 +466,7 @@ int main(int argc, char *argv[]) {
fprintf
(
fp
,
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
fprintf
(
fp
,
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
fprintf
(
fp
,
"# Datatype of Columns: %s
\n
"
,
dataString
);
fprintf
(
fp
,
"# Datatype of Columns: %s
\n
"
,
dataString
);
fprintf
(
fp
,
"# Binary Length(If applicable): %d
\n
"
,
fprintf
(
fp
,
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
||
strcasestr
(
dataString
,
"NCHAR"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
fprintf
(
fp
,
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
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 Tables: %d
\n
"
,
ntables
);
...
@@ -506,23 +506,23 @@ int main(int argc, char *argv[]) {
...
@@ -506,23 +506,23 @@ int main(int argc, char *argv[]) {
len
=
0
;
len
=
0
;
for
(;
colIndex
<
ncols_per_record
-
1
;
colIndex
++
)
{
for
(;
colIndex
<
ncols_per_record
-
1
;
colIndex
++
)
{
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
)
{
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
&&
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"NCHAR"
)
!=
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
}
else
{
}
else
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
}
}
}
}
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
)
{
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
&&
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"NCHAR"
)
!=
0
)
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s
)
"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
}
else
{
}
else
{
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d)
)
"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
}
}
if
(
use_metric
)
{
if
(
use_metric
)
{
/* Create metric table */
/* Create metric table */
printf
(
"Creating meters super table...
\n
"
);
printf
(
"Creating meters super table...
\n
"
);
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.meters (ts timestamp%s tags (areaid int, loc binary(10))"
,
db_name
,
cols
);
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.meters (ts timestamp%s
)
tags (areaid int, loc binary(10))"
,
db_name
,
cols
);
queryDB
(
taos
,
command
);
queryDB
(
taos
,
command
);
printf
(
"meters created!
\n
"
);
printf
(
"meters created!
\n
"
);
}
}
...
@@ -1272,6 +1272,10 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
...
@@ -1272,6 +1272,10 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
char
s
[
len_of_binary
];
char
s
[
len_of_binary
];
rand_string
(
s
,
len_of_binary
);
rand_string
(
s
,
len_of_binary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"nchar"
)
==
0
)
{
char
s
[
len_of_binary
];
rand_string
(
s
,
len_of_binary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
}
}
if
(
pstr
-
res
>
MAX_DATA_SIZE
)
{
if
(
pstr
-
res
>
MAX_DATA_SIZE
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录