Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
6b582a78
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,体验更适合开发者的 AI 搜索 >>
提交
6b582a78
编写于
10月 26, 2020
作者:
Z
zyyang-taosdata
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1722]<hotfix>: fix dynamic link error for win32
上级
edadef71
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
654 addition
and
589 deletion
+654
-589
src/connector/nodejs/nodetaos/cinterface.js
src/connector/nodejs/nodetaos/cinterface.js
+508
-495
src/connector/nodejs/nodetaos/connection.js
src/connector/nodejs/nodetaos/connection.js
+38
-37
src/connector/nodejs/package-lock.json
src/connector/nodejs/package-lock.json
+5
-0
src/connector/nodejs/package.json
src/connector/nodejs/package.json
+1
-0
src/connector/nodejs/tdengine.js
src/connector/nodejs/tdengine.js
+4
-4
src/connector/nodejs/test/nodejsChecker.js
src/connector/nodejs/test/nodejsChecker.js
+40
-0
src/connector/nodejs/test/performance.js
src/connector/nodejs/test/performance.js
+58
-53
未找到文件。
src/connector/nodejs/nodetaos/cinterface.js
浏览文件 @
6b582a78
此差异已折叠。
点击以展开。
src/connector/nodejs/nodetaos/connection.js
浏览文件 @
6b582a78
const
TDengineCursor
=
require
(
'
./cursor
'
)
const
CTaosInterface
=
require
(
'
./cinterface
'
)
const
TDengineCursor
=
require
(
'
./cursor
'
)
;
const
CTaosInterface
=
require
(
'
./cinterface
'
)
;
module
.
exports
=
TDengineConnection
;
/**
...
...
@@ -14,61 +14,62 @@ module.exports = TDengineConnection;
*
*/
function
TDengineConnection
(
options
)
{
this
.
_conn
=
null
;
this
.
_host
=
null
;
this
.
_user
=
"
root
"
;
//The default user
this
.
_password
=
"
taosdata
"
;
//The default password
this
.
_database
=
null
;
this
.
_port
=
0
;
this
.
_config
=
null
;
this
.
_chandle
=
null
;
this
.
_configConn
(
options
)
return
this
;
this
.
_conn
=
null
;
this
.
_host
=
null
;
this
.
_user
=
"
root
"
;
//The default user
this
.
_password
=
"
taosdata
"
;
//The default password
this
.
_database
=
null
;
this
.
_port
=
0
;
this
.
_config
=
null
;
this
.
_chandle
=
null
;
this
.
_configConn
(
options
)
return
this
;
}
/**
* Configure the connection to TDengine
* @private
* @memberof TDengineConnection
*/
TDengineConnection
.
prototype
.
_configConn
=
function
_configConn
(
options
)
{
if
(
options
[
'
host
'
])
{
this
.
_host
=
options
[
'
host
'
];
}
if
(
options
[
'
user
'
])
{
this
.
_user
=
options
[
'
user
'
];
}
if
(
options
[
'
password
'
])
{
this
.
_password
=
options
[
'
password
'
];
}
if
(
options
[
'
database
'
])
{
this
.
_database
=
options
[
'
database
'
];
}
if
(
options
[
'
port
'
])
{
this
.
_port
=
options
[
'
port
'
];
}
if
(
options
[
'
config
'
])
{
this
.
_config
=
options
[
'
config
'
];
}
this
.
_chandle
=
new
CTaosInterface
(
this
.
_config
);
this
.
_conn
=
this
.
_chandle
.
connect
(
this
.
_host
,
this
.
_user
,
this
.
_password
,
this
.
_database
,
this
.
_port
);
if
(
options
[
'
host
'
])
{
this
.
_host
=
options
[
'
host
'
];
}
if
(
options
[
'
user
'
])
{
this
.
_user
=
options
[
'
user
'
];
}
if
(
options
[
'
password
'
])
{
this
.
_password
=
options
[
'
password
'
];
}
if
(
options
[
'
database
'
])
{
this
.
_database
=
options
[
'
database
'
];
}
if
(
options
[
'
port
'
])
{
this
.
_port
=
options
[
'
port
'
];
}
if
(
options
[
'
config
'
])
{
this
.
_config
=
options
[
'
config
'
];
}
this
.
_chandle
=
new
CTaosInterface
(
this
.
_config
);
this
.
_conn
=
this
.
_chandle
.
connect
(
this
.
_host
,
this
.
_user
,
this
.
_password
,
this
.
_database
,
this
.
_port
);
}
/** Close the connection to TDengine */
TDengineConnection
.
prototype
.
close
=
function
close
()
{
this
.
_chandle
.
close
(
this
.
_conn
);
this
.
_chandle
.
close
(
this
.
_conn
);
}
/**
* Initialize a new cursor to interact with TDengine with
* @return {TDengineCursor}
*/
TDengineConnection
.
prototype
.
cursor
=
function
cursor
()
{
//Pass the connection object to the cursor
return
new
TDengineCursor
(
this
);
//Pass the connection object to the cursor
return
new
TDengineCursor
(
this
);
}
TDengineConnection
.
prototype
.
commit
=
function
commit
()
{
return
this
;
return
this
;
}
TDengineConnection
.
prototype
.
rollback
=
function
rollback
()
{
return
this
;
return
this
;
}
/**
* Clear the results from connector
...
...
src/connector/nodejs/package-lock.json
浏览文件 @
6b582a78
...
...
@@ -563,6 +563,11 @@
"wrappy"
:
"1"
}
},
"os"
:
{
"version"
:
"0.1.1"
,
"resolved"
:
"https://registry.npm.taobao.org/os/download/os-0.1.1.tgz"
,
"integrity"
:
"sha1-IIhF6J4ZOtTZcUdLk5R3NqVtE/M="
},
"path-is-absolute"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
,
...
...
src/connector/nodejs/package.json
浏览文件 @
6b582a78
...
...
@@ -17,6 +17,7 @@
"dependencies"
:
{
"ffi"
:
"^2.3.0"
,
"node-gyp"
:
"^5.0.2"
,
"os"
:
"^0.1.1"
,
"ref"
:
"^1.3.5"
,
"ref-array"
:
"^1.2.0"
},
...
...
src/connector/nodejs/tdengine.js
浏览文件 @
6b582a78
var
TDengineConnection
=
require
(
'
./nodetaos/connection.js
'
)
module
.
exports
.
connect
=
function
(
connection
=
null
)
{
return
new
TDengineConnection
(
connection
);
}
var
TDengineConnection
=
require
(
'
./nodetaos/connection.js
'
)
;
module
.
exports
.
connect
=
function
(
connection
=
null
)
{
return
new
TDengineConnection
(
connection
);
}
;
src/connector/nodejs/test/nodejsChecker.js
0 → 100644
浏览文件 @
6b582a78
const
taos
=
require
(
'
../tdengine
'
);
// establish connection
var
conn
=
taos
.
connect
({
host
:
"
192.168.1.59
"
,
user
:
"
root
"
,
password
:
"
taosdata
"
,
port
:
6030
});
var
cursor
=
conn
.
cursor
();
// create database
executeSql
(
"
create database if not exists jschecker
"
,
0
);
// use db
executeSql
(
"
use jschecker
"
,
0
);
// drop table
executeSql
(
"
drop table if exists jschecker.weather
"
,
0
);
// create table
executeSql
(
"
create table if not exists jschecker.weather(ts timestamp, temperature float, humidity int)
"
,
0
);
// insert
executeSql
(
"
insert into jschecker.weather (ts, temperature, humidity) values(now, 20.5, 34)
"
,
1
);
// select
executeQuery
(
"
select * from jschecker.weather
"
);
// close connection
conn
.
close
();
function
executeQuery
(
sql
)
{
var
start
=
new
Date
().
getTime
();
var
promise
=
cursor
.
query
(
sql
,
true
);
var
end
=
new
Date
().
getTime
();
printSql
(
sql
,
promise
!=
null
,
(
end
-
start
));
promise
.
then
(
function
(
result
)
{
result
.
pretty
();
});
}
function
executeSql
(
sql
,
affectRows
)
{
var
start
=
new
Date
().
getTime
();
var
promise
=
cursor
.
execute
(
sql
);
var
end
=
new
Date
().
getTime
();
printSql
(
sql
,
promise
==
affectRows
,
(
end
-
start
));
}
function
printSql
(
sql
,
succeed
,
cost
)
{
console
.
log
(
"
[
"
+
(
succeed
?
"
OK
"
:
"
ERROR!
"
)
+
"
] time cost:
"
+
cost
+
"
ms, execute statement ====>
"
+
sql
);
}
src/connector/nodejs/test/performance.js
浏览文件 @
6b582a78
function
memoryUsageData
()
{
let
s
=
process
.
memoryUsage
()
for
(
key
in
s
)
{
s
[
key
]
=
(
s
[
key
]
/
1000000
).
toFixed
(
3
)
+
"
MB
"
;
}
return
s
;
let
s
=
process
.
memoryUsage
();
for
(
key
in
s
)
{
s
[
key
]
=
(
s
[
key
]
/
1000000
).
toFixed
(
3
)
+
"
MB
"
;
}
return
s
;
}
console
.
log
(
"
initial mem usage:
"
,
memoryUsageData
());
const
{
PerformanceObserver
,
performance
}
=
require
(
'
perf_hooks
'
);
const
{
PerformanceObserver
,
performance
}
=
require
(
'
perf_hooks
'
);
const
taos
=
require
(
'
../tdengine
'
);
var
conn
=
taos
.
connect
({
host
:
"
127.0.0.1
"
,
user
:
"
root
"
,
password
:
"
taosdata
"
,
config
:
"
/etc/taos
"
,
port
:
0
});
var
conn
=
taos
.
connect
({
host
:
"
127.0.0.1
"
,
user
:
"
root
"
,
password
:
"
taosdata
"
,
config
:
"
/etc/taos
"
,
port
:
0
});
var
c1
=
conn
.
cursor
();
// Initialize env
...
...
@@ -25,65 +26,69 @@ var insertTime = 0;
var
insertTime5000
=
0
;
var
avgInsert5ktime
=
0
;
const
obs
=
new
PerformanceObserver
((
items
)
=>
{
let
entry
=
items
.
getEntries
()[
0
];
let
entry
=
items
.
getEntries
()[
0
];
if
(
entry
.
name
==
'
Data Prep
'
)
{
dataPrepTime
+=
entry
.
duration
;
}
else
if
(
entry
.
name
==
'
Insert
'
)
{
insertTime
+=
entry
.
duration
}
else
{
console
.
log
(
entry
.
name
+
'
:
'
+
(
entry
.
duration
/
1000
).
toFixed
(
8
)
+
'
s
'
);
}
performance
.
clearMarks
();
if
(
entry
.
name
==
'
Data Prep
'
)
{
dataPrepTime
+=
entry
.
duration
;
}
else
if
(
entry
.
name
==
'
Insert
'
)
{
insertTime
+=
entry
.
duration
}
else
{
console
.
log
(
entry
.
name
+
'
:
'
+
(
entry
.
duration
/
1000
).
toFixed
(
8
)
+
'
s
'
);
}
performance
.
clearMarks
();
});
obs
.
observe
({
entryTypes
:
[
'
measure
'
]
});
obs
.
observe
({
entryTypes
:
[
'
measure
'
]
});
function
R
(
l
,
r
)
{
return
Math
.
random
()
*
(
r
-
l
)
-
r
;
function
R
(
l
,
r
)
{
return
Math
.
random
()
*
(
r
-
l
)
-
r
;
}
function
randomBool
()
{
if
(
Math
.
random
()
<
0.5
)
{
return
true
;
}
return
false
;
if
(
Math
.
random
()
<
0.5
)
{
return
true
;
}
return
false
;
}
function
insertN
(
n
)
{
for
(
let
i
=
0
;
i
<
n
;
i
++
)
{
performance
.
mark
(
'
A3
'
);
let
insertData
=
[
"
now +
"
+
i
+
"
m
"
,
// Timestamp
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// Int
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// BigInt
parseFloat
(
R
(
-
3.4E38
,
3.4E38
)
),
// Float
parseFloat
(
R
(
-
1.7E308
,
1.7E308
)
),
// Double
"
\"
Long Binary
\"
"
,
// Binary
parseInt
(
R
(
-
32767
,
32767
)
),
// Small Int
parseInt
(
R
(
-
127
,
127
)
),
// Tiny Int
randomBool
(),
"
\"
Nchars 一些中文字幕
\"
"
];
// Bool
let
query
=
'
insert into td_connector_test.all_types values(
'
+
insertData
.
join
(
'
,
'
)
+
'
);
'
;
performance
.
mark
(
'
B3
'
);
performance
.
measure
(
'
Data Prep
'
,
'
A3
'
,
'
B3
'
);
performance
.
mark
(
'
A2
'
);
c1
.
execute
(
query
,
{
quiet
:
true
});
performance
.
mark
(
'
B2
'
);
performance
.
measure
(
'
Insert
'
,
'
A2
'
,
'
B2
'
);
if
(
i
%
5000
==
4999
)
{
console
.
log
(
"
Insert #
"
+
(
i
+
1
));
console
.
log
(
'
Insert 5k records:
'
+
((
insertTime
-
insertTime5000
)
/
1000
).
toFixed
(
8
)
+
'
s
'
);
insertTime5000
=
insertTime
;
avgInsert5ktime
=
(
avgInsert5ktime
/
1000
*
Math
.
floor
(
i
/
5000
)
+
insertTime5000
/
1000
)
/
Math
.
ceil
(
i
/
5000
);
console
.
log
(
'
DataPrepTime So Far:
'
+
(
dataPrepTime
/
1000
).
toFixed
(
8
)
+
'
s | Inserting time So Far:
'
+
(
insertTime
/
1000
).
toFixed
(
8
)
+
'
s | Avg. Insert 5k time:
'
+
avgInsert5ktime
.
toFixed
(
8
));
for
(
let
i
=
0
;
i
<
n
;
i
++
)
{
performance
.
mark
(
'
A3
'
);
let
insertData
=
[
"
now +
"
+
i
+
"
m
"
,
// Timestamp
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// Int
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// BigInt
parseFloat
(
R
(
-
3.4E38
,
3.4E38
)
),
// Float
parseFloat
(
R
(
-
1.7E308
,
1.7E308
)
),
// Double
"
\"
Long Binary
\"
"
,
// Binary
parseInt
(
R
(
-
32767
,
32767
)
),
// Small Int
parseInt
(
R
(
-
127
,
127
)
),
// Tiny Int
randomBool
(),
"
\"
Nchars 一些中文字幕
\"
"
];
// Bool
let
query
=
'
insert into td_connector_test.all_types values(
'
+
insertData
.
join
(
'
,
'
)
+
'
);
'
;
performance
.
mark
(
'
B3
'
);
performance
.
measure
(
'
Data Prep
'
,
'
A3
'
,
'
B3
'
);
performance
.
mark
(
'
A2
'
);
c1
.
execute
(
query
,
{
quiet
:
true
});
performance
.
mark
(
'
B2
'
);
performance
.
measure
(
'
Insert
'
,
'
A2
'
,
'
B2
'
);
if
(
i
%
5000
==
4999
)
{
console
.
log
(
"
Insert #
"
+
(
i
+
1
));
console
.
log
(
'
Insert 5k records:
'
+
((
insertTime
-
insertTime5000
)
/
1000
).
toFixed
(
8
)
+
'
s
'
);
insertTime5000
=
insertTime
;
avgInsert5ktime
=
(
avgInsert5ktime
/
1000
*
Math
.
floor
(
i
/
5000
)
+
insertTime5000
/
1000
)
/
Math
.
ceil
(
i
/
5000
);
console
.
log
(
'
DataPrepTime So Far:
'
+
(
dataPrepTime
/
1000
).
toFixed
(
8
)
+
'
s | Inserting time So Far:
'
+
(
insertTime
/
1000
).
toFixed
(
8
)
+
'
s | Avg. Insert 5k time:
'
+
avgInsert5ktime
.
toFixed
(
8
));
}
}
}
}
performance
.
mark
(
'
insert 1E5
'
)
insertN
(
1
E5
);
performance
.
mark
(
'
insert 1E5 2
'
)
performance
.
measure
(
'
Insert With Logs
'
,
'
insert 1E5
'
,
'
insert 1E5 2
'
);
console
.
log
(
'
DataPrepTime:
'
+
(
dataPrepTime
/
1000
).
toFixed
(
8
)
+
'
s | Inserting time:
'
+
(
insertTime
/
1000
).
toFixed
(
8
)
+
'
s
'
);
dataPrepTime
=
0
;
insertTime
=
0
;
console
.
log
(
'
DataPrepTime:
'
+
(
dataPrepTime
/
1000
).
toFixed
(
8
)
+
'
s | Inserting time:
'
+
(
insertTime
/
1000
).
toFixed
(
8
)
+
'
s
'
);
dataPrepTime
=
0
;
insertTime
=
0
;
//'insert into td_connector_test.all_types values (now, null,null,null,null,null,null,null,null,null);'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录