Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2fc88d32
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
2fc88d32
编写于
7月 12, 2022
作者:
D
dingbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: test python example
上级
21bcfbce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
15 deletion
+91
-15
docs/examples/python/highvolume_example.py
docs/examples/python/highvolume_example.py
+13
-11
docs/zh/07-develop/03-insert-data/05-high-volume.md
docs/zh/07-develop/03-insert-data/05-high-volume.md
+78
-4
未找到文件。
docs/examples/python/highvolume_example.py
浏览文件 @
2fc88d32
...
@@ -47,16 +47,12 @@ class DataBaseMonitor:
...
@@ -47,16 +47,12 @@ class DataBaseMonitor:
return
int
(
r
[
1
])
return
int
(
r
[
1
])
def
stat_and_print
(
self
):
def
stat_and_print
(
self
):
try
:
last_count
=
0
last_count
=
0
while
True
:
while
True
:
time
.
sleep
(
10
)
time
.
sleep
(
10
)
count
=
self
.
get_count
()
count
=
self
.
get_count
()
logging
.
info
(
f
"count=
{
count
}
speed=
{
(
count
-
last_count
)
/
10
}
"
)
logging
.
info
(
f
"count=
{
count
}
speed=
{
(
count
-
last_count
)
/
10
}
"
)
last_count
=
count
last_count
=
count
except
KeyboardInterrupt
:
[
p
.
terminate
()
for
p
in
read_processes
]
[
p
.
terminate
()
for
p
in
write_processes
]
# ANCHOR_END: DataBaseMonitor
# ANCHOR_END: DataBaseMonitor
...
@@ -154,6 +150,7 @@ class SQLWriter:
...
@@ -154,6 +150,7 @@ class SQLWriter:
self
.
_buffered_count
=
0
self
.
_buffered_count
=
0
def
execute_sql
(
self
,
sql
):
def
execute_sql
(
self
,
sql
):
self
.
log
.
debug
(
sql
)
try
:
try
:
self
.
_conn
.
execute
(
sql
)
self
.
_conn
.
execute
(
sql
)
except
taos
.
Error
as
e
:
except
taos
.
Error
as
e
:
...
@@ -258,7 +255,12 @@ def main():
...
@@ -258,7 +255,12 @@ def main():
p
.
start
()
p
.
start
()
read_processes
.
append
(
p
)
read_processes
.
append
(
p
)
database_monitor
.
stat_and_print
()
try
:
database_monitor
.
stat_and_print
()
except
KeyboardInterrupt
:
[
p
.
terminate
()
for
p
in
read_processes
]
[
p
.
terminate
()
for
p
in
write_processes
]
exit
()
# ANCHOR_END: main
# ANCHOR_END: main
...
...
docs/zh/07-develop/03-insert-data/05-high-volume.md
浏览文件 @
2fc88d32
...
@@ -39,9 +39,13 @@ title: 高效写入
...
@@ -39,9 +39,13 @@ title: 高效写入
3.
模拟生成的总表数。默认为 1000。将会平分给各个读线程。
3.
模拟生成的总表数。默认为 1000。将会平分给各个读线程。
4.
每批最大数据量。默认为 3000。
4.
每批最大数据量。默认为 3000。
```
java title="主程序"
<details>
<summary>
主程序
</summary>
```
java
{{
#
include
docs
/
examples
/
java
/
src
/
main
/
java
/
com
/
taos
/
example
/
highvolume
/
FastWriteExample
.
java
:
main
}}
{{
#
include
docs
/
examples
/
java
/
src
/
main
/
java
/
com
/
taos
/
example
/
highvolume
/
FastWriteExample
.
java
:
main
}}
```
```
</details>
队列容量(taskQueueCapacity)也是与性能有关的参数,可通过修改程序调节。一般来讲,队列容量越大,入队被阻塞的概率越小,队列的吞吐量越大,但是内存占用也会越大。
队列容量(taskQueueCapacity)也是与性能有关的参数,可通过修改程序调节。一般来讲,队列容量越大,入队被阻塞的概率越小,队列的吞吐量越大,但是内存占用也会越大。
...
@@ -163,8 +167,78 @@ TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata"
...
@@ -163,8 +167,78 @@ TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata"
## Python 示例程序
## Python 示例程序
在 Python 示例程序中采用参数绑定的写入方式。(开发中)
在 Python 示例程序中采用多进程的架构。写任务中同样采用拼装 SQL 的方式写入。
### 主进程
<details>
<summary>
main 函数
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:main}}
```
</details>
<details>
<summary>
DataBaseMonitor
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:DataBaseMonitor}}
```
</details>
### 读进程
<details>
<summary>
启动函数
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:read}}
```
</details>
<details>
<summary>
MockDataSource
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:MockDataSource}}
```
</details>
<!--
```python title="Python 示例程序"
### 写进程
<details>
<summary>
启动函数
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:write}}
```
```
-->
</details>
<details>
<summary>
SQLWriter
</summary>
```
python
{{
#include docs/examples/python/highvolume_example.py:SQLWriter}}
```
</details>
### 执行示例程序
```
git clone git@github.com:taosdata/TDengine.git
git checkout -t 2.6
cd docs/examples/python/
python3 highvolume_example.py
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录