Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
812a40f9
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看板
提交
812a40f9
编写于
7月 14, 2022
作者:
D
dingbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: mockdatasoruce.py
上级
b2037f7a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
18 addition
and
11 deletion
+18
-11
docs/examples/python/highvolume_faster_queue.py
docs/examples/python/highvolume_faster_queue.py
+2
-2
docs/examples/python/mockdatasoruce.py
docs/examples/python/mockdatasoruce.py
+16
-9
未找到文件。
docs/examples/python/highvolume_faster_queue.py
浏览文件 @
812a40f9
...
@@ -47,11 +47,11 @@ def run_read_task(task_id: int, task_queues: List[Queue]):
...
@@ -47,11 +47,11 @@ def run_read_task(task_id: int, task_queues: List[Queue]):
data_source
=
MockDataSource
(
f
"tb
{
task_id
}
"
,
table_count_per_task
)
data_source
=
MockDataSource
(
f
"tb
{
task_id
}
"
,
table_count_per_task
)
try
:
try
:
for
batch
in
data_source
:
for
batch
in
data_source
:
for
table_id
,
row
in
batch
:
for
table_id
,
row
s
in
batch
:
# hash data to different queue
# hash data to different queue
i
=
table_id
%
len
(
task_queues
)
i
=
table_id
%
len
(
task_queues
)
# block putting forever when the queue is full
# block putting forever when the queue is full
task_queues
[
i
].
put
(
row
,
block
=
True
,
timeout
=-
1
)
task_queues
[
i
].
put
_many
(
rows
,
block
=
True
,
timeout
=-
1
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
pass
pass
...
...
docs/examples/python/mockdatasoruce.py
浏览文件 @
812a40f9
...
@@ -14,7 +14,8 @@ class MockDataSource:
...
@@ -14,7 +14,8 @@ class MockDataSource:
self
.
table_name_prefix
=
tb_name_prefix
+
"_"
self
.
table_name_prefix
=
tb_name_prefix
+
"_"
self
.
table_count
=
table_count
self
.
table_count
=
table_count
self
.
max_rows
=
10000000
self
.
max_rows
=
10000000
self
.
start_ms
=
round
(
time
.
time
()
*
1000
)
-
self
.
max_rows
*
100
self
.
current_ts
=
round
(
time
.
time
()
*
1000
)
-
self
.
max_rows
*
100
# [(tableId, tableName, values),]
self
.
data
=
self
.
_init_data
()
self
.
data
=
self
.
_init_data
()
def
_init_data
(
self
):
def
_init_data
(
self
):
...
@@ -31,15 +32,21 @@ class MockDataSource:
...
@@ -31,15 +32,21 @@ class MockDataSource:
def
__next__
(
self
):
def
__next__
(
self
):
"""
"""
next
row
for each table.
next
1000 rows
for each table.
[(tableId, row),(tableId, row)]
return: {tableId:[row,...]}
"""
"""
self
.
row
+=
1
# generate 1000 timestamps
ts
=
self
.
start_ms
+
100
*
self
.
row
ts
=
[]
for
_
in
range
(
1000
):
# just add timestamp to each row
self
.
current_ts
+=
100
# (tableId, "tableName,ts,current,voltage,phase,location,groupId")
ts
.
append
(
self
.
current_ts
)
return
map
(
lambda
t
:
(
t
[
0
],
t
[
1
]
+
str
(
ts
)
+
","
+
t
[
2
]),
self
.
data
)
# add timestamp to each row
# [(tableId, ["tableName,ts,current,voltage,phase,location,groupId"])]
result
=
[]
for
table_id
,
table_name
,
values
in
self
.
data
:
rows
=
[
table_name
+
','
+
t
+
','
+
values
for
t
in
ts
]
result
.
append
((
table_id
,
rows
))
return
result
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录