Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
e6947142
T
TDengine
项目概览
qq_50753323
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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,发现更多精彩内容 >>
提交
e6947142
编写于
1月 07, 2020
作者:
X
xieyinglin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add savetb option
上级
0c22f9d8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
5 deletion
+12
-5
importSampleData/README.md
importSampleData/README.md
+4
-0
importSampleData/app/main.go
importSampleData/app/main.go
+8
-5
importSampleData/bin/taosimport
importSampleData/bin/taosimport
+0
-0
未找到文件。
importSampleData/README.md
浏览文件 @
e6947142
...
@@ -97,6 +97,10 @@ go build -o bin/taosimport app/main.go
...
@@ -97,6 +97,10 @@ go build -o bin/taosimport app/main.go
是否保存统计信息到 tdengine 的 statistic 表中,1 是,0 否, 默认 0。
是否保存统计信息到 tdengine 的 statistic 表中,1 是,0 否, 默认 0。
*
-savetb int
当 save 为 1 时保存统计信息的表名, 默认 statistic。
*
-auto int
*
-auto int
是否自动生成样例数据中的主键时间戳,1 是,0 否, 默认 0。
是否自动生成样例数据中的主键时间戳,1 是,0 否, 默认 0。
...
...
importSampleData/app/main.go
浏览文件 @
e6947142
...
@@ -28,6 +28,7 @@ const (
...
@@ -28,6 +28,7 @@ const (
DEFAULT_STARTTIME
int64
=
-
1
DEFAULT_STARTTIME
int64
=
-
1
DEFAULT_INTERVAL
int64
=
1
*
1000
DEFAULT_INTERVAL
int64
=
1
*
1000
DEFAULT_DELAY
int64
=
-
1
DEFAULT_DELAY
int64
=
-
1
DEFAULT_STATISTIC_TABLE
=
"statistic"
JSON_FORMAT
=
"json"
JSON_FORMAT
=
"json"
CSV_FORMAT
=
"csv"
CSV_FORMAT
=
"csv"
...
@@ -37,7 +38,6 @@ const (
...
@@ -37,7 +38,6 @@ const (
DRIVER_NAME
=
"taosSql"
DRIVER_NAME
=
"taosSql"
STARTTIME_LAYOUT
=
"2006-01-02 15:04:05.000"
STARTTIME_LAYOUT
=
"2006-01-02 15:04:05.000"
INSERT_PREFIX
=
"insert into "
INSERT_PREFIX
=
"insert into "
STATISTIC_TABLE
=
"statistic"
)
)
var
(
var
(
...
@@ -75,6 +75,7 @@ var (
...
@@ -75,6 +75,7 @@ var (
delay
int64
// default 10 milliseconds
delay
int64
// default 10 milliseconds
tick
int64
tick
int64
save
int
save
int
saveTable
string
)
)
type
superTableConfig
struct
{
type
superTableConfig
struct
{
...
@@ -278,9 +279,9 @@ func staticSpeed(){
...
@@ -278,9 +279,9 @@ func staticSpeed(){
if
save
==
1
{
if
save
==
1
{
connection
.
Exec
(
"use "
+
db
)
connection
.
Exec
(
"use "
+
db
)
_
,
err
:=
connection
.
Exec
(
"create table if not exists "
+
STATISTIC_TABLE
+
"(ts timestamp, speed int)"
)
_
,
err
:=
connection
.
Exec
(
"create table if not exists "
+
saveTable
+
"(ts timestamp, speed int)"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"create %s Table error: %s
\n
"
,
STATISTIC_TABLE
,
err
)
log
.
Fatalf
(
"create %s Table error: %s
\n
"
,
saveTable
,
err
)
}
}
}
}
...
@@ -297,7 +298,7 @@ func staticSpeed(){
...
@@ -297,7 +298,7 @@ func staticSpeed(){
log
.
Printf
(
"insert %d rows, used %d ms, speed %d rows/s"
,
currentSuccessRows
,
usedTime
/
1e6
,
speed
)
log
.
Printf
(
"insert %d rows, used %d ms, speed %d rows/s"
,
currentSuccessRows
,
usedTime
/
1e6
,
speed
)
if
save
==
1
{
if
save
==
1
{
insertSql
:=
fmt
.
Sprintf
(
"insert into %s values(%d, %d)"
,
STATISTIC_TABLE
,
currentTime
.
UnixNano
()
/
1e6
,
speed
)
insertSql
:=
fmt
.
Sprintf
(
"insert into %s values(%d, %d)"
,
saveTable
,
currentTime
.
UnixNano
()
/
1e6
,
speed
)
connection
.
Exec
(
insertSql
)
connection
.
Exec
(
insertSql
)
}
}
...
@@ -353,7 +354,7 @@ func createStatisticTable(){
...
@@ -353,7 +354,7 @@ func createStatisticTable(){
connection
:=
getConnection
()
connection
:=
getConnection
()
defer
connection
.
Close
()
defer
connection
.
Close
()
_
,
err
:=
connection
.
Exec
(
"create table if not exist "
+
db
+
"."
+
STATISTIC_TABLE
+
"(ts timestamp, speed int)"
)
_
,
err
:=
connection
.
Exec
(
"create table if not exist "
+
db
+
"."
+
saveTable
+
"(ts timestamp, speed int)"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"createStatisticTable error: %s
\n
"
,
err
)
log
.
Fatalf
(
"createStatisticTable error: %s
\n
"
,
err
)
}
}
...
@@ -1037,6 +1038,7 @@ func parseArg() {
...
@@ -1037,6 +1038,7 @@ func parseArg() {
flag
.
Int64Var
(
&
delay
,
"delay"
,
DEFAULT_DELAY
,
"the delay time interval(millisecond) to continue generating data when vnum set 0."
)
flag
.
Int64Var
(
&
delay
,
"delay"
,
DEFAULT_DELAY
,
"the delay time interval(millisecond) to continue generating data when vnum set 0."
)
flag
.
Int64Var
(
&
tick
,
"tick"
,
2000
,
"the tick time interval(millisecond) to print statistic info."
)
flag
.
Int64Var
(
&
tick
,
"tick"
,
2000
,
"the tick time interval(millisecond) to print statistic info."
)
flag
.
IntVar
(
&
save
,
"save"
,
0
,
"whether to save the statistical info into 'statistic' table. 0 is disabled and 1 is enabled."
)
flag
.
IntVar
(
&
save
,
"save"
,
0
,
"whether to save the statistical info into 'statistic' table. 0 is disabled and 1 is enabled."
)
flag
.
StringVar
(
&
saveTable
,
"savetb"
,
DEFAULT_STATISTIC_TABLE
,
"the table to save 'statistic' info when save set 1."
)
flag
.
IntVar
(
&
thread
,
"thread"
,
10
,
"number of threads to import data."
)
flag
.
IntVar
(
&
thread
,
"thread"
,
10
,
"number of threads to import data."
)
flag
.
IntVar
(
&
batch
,
"batch"
,
100
,
"rows of records in one import batch."
)
flag
.
IntVar
(
&
batch
,
"batch"
,
100
,
"rows of records in one import batch."
)
flag
.
IntVar
(
&
auto
,
"auto"
,
0
,
"whether to use the starttime and interval specified by users when simulating the data. 0 is disabled and 1 is enabled."
)
flag
.
IntVar
(
&
auto
,
"auto"
,
0
,
"whether to use the starttime and interval specified by users when simulating the data. 0 is disabled and 1 is enabled."
)
...
@@ -1062,6 +1064,7 @@ func printArg() {
...
@@ -1062,6 +1064,7 @@ func printArg() {
fmt
.
Println
(
"-delay:"
,
delay
)
fmt
.
Println
(
"-delay:"
,
delay
)
fmt
.
Println
(
"-tick:"
,
tick
)
fmt
.
Println
(
"-tick:"
,
tick
)
fmt
.
Println
(
"-save:"
,
save
)
fmt
.
Println
(
"-save:"
,
save
)
fmt
.
Println
(
"-savetb:"
,
saveTable
)
fmt
.
Println
(
"-thread:"
,
thread
)
fmt
.
Println
(
"-thread:"
,
thread
)
fmt
.
Println
(
"-batch:"
,
batch
)
fmt
.
Println
(
"-batch:"
,
batch
)
fmt
.
Println
(
"-auto:"
,
auto
)
fmt
.
Println
(
"-auto:"
,
auto
)
...
...
importSampleData/bin/taosimport
浏览文件 @
e6947142
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录