Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3d00f6ce
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3d00f6ce
编写于
5月 14, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
8e15c644
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
24 deletion
+25
-24
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+20
-19
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+5
-5
未找到文件。
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
3d00f6ce
...
...
@@ -19,10 +19,10 @@
#define MAX_CATCH_NUM 10240
typedef
struct
ST
bl
Info
{
typedef
struct
ST
ableSink
Info
{
uint64_t
uid
;
char
tbName
[
TSDB_TABLE_NAME_LEN
];
}
ST
bl
Info
;
}
ST
ableSink
Info
;
int32_t
tqBuildDeleteReq
(
const
char
*
stbFullName
,
const
SSDataBlock
*
pDataBlock
,
SBatchDeleteReq
*
deleteReq
,
const
char
*
pIdStr
)
{
...
...
@@ -97,16 +97,17 @@ end:
return
ret
;
}
int32_t
tqGetTableInfo
(
SSHashObj
*
tblInfo
,
uint64_t
groupId
,
STblInfo
**
pTbl
)
{
void
*
pVal
=
tSimpleHashGet
(
tblInfo
,
&
groupId
,
sizeof
(
uint64_t
));
static
int32_t
tqGetTableInfo
(
SSHashObj
*
pTableInfoMap
,
uint64_t
groupId
,
STableSinkInfo
**
pInfo
)
{
void
*
pVal
=
tSimpleHashGet
(
pTableInfoMap
,
&
groupId
,
sizeof
(
uint64_t
));
if
(
pVal
)
{
*
p
Tbl
=
*
(
STbl
Info
**
)
pVal
;
*
p
Info
=
*
(
STableSink
Info
**
)
pVal
;
return
TSDB_CODE_SUCCESS
;
}
return
TSDB_CODE_FAILED
;
}
int32_t
tqPutTableInfo
(
SSHashObj
*
tblInfo
,
uint64_t
groupId
,
ST
bl
Info
*
pTbl
)
{
int32_t
tqPutTableInfo
(
SSHashObj
*
tblInfo
,
uint64_t
groupId
,
ST
ableSink
Info
*
pTbl
)
{
if
(
tSimpleHashGetSize
(
tblInfo
)
>
MAX_CATCH_NUM
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -274,7 +275,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
crTblArray
=
NULL
;
}
else
{
SSubmitTbData
tbData
=
{
0
};
tqDebug
(
"tq sink pipe, convert block
1 %d, rows:
%d"
,
i
,
rows
);
tqDebug
(
"tq sink pipe, convert block
:%d, rows:
%d"
,
i
,
rows
);
if
(
!
(
tbData
.
aRowP
=
taosArrayInit
(
rows
,
sizeof
(
SRow
*
))))
{
goto
_end
;
...
...
@@ -283,35 +284,35 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
tbData
.
suid
=
suid
;
tbData
.
uid
=
0
;
// uid is assigned by vnode
tbData
.
sver
=
pTSchema
->
version
;
STblInfo
*
pTblMeta
=
NULL
;
int32_t
res
=
tqGetTableInfo
(
pTask
->
tbSink
.
pTblInfo
,
pDataBlock
->
info
.
id
.
groupId
,
&
pTblMeta
);
STableSinkInfo
*
pTableSinkInfo
=
NULL
;
int32_t
res
=
tqGetTableInfo
(
pTask
->
tbSink
.
pTblInfo
,
pDataBlock
->
info
.
id
.
groupId
,
&
pTableSinkInfo
);
if
(
res
!=
TSDB_CODE_SUCCESS
)
{
pT
blMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STbl
Info
));
pT
ableSinkInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableSink
Info
));
}
char
*
ctbName
=
pDataBlock
->
info
.
parTbName
;
if
(
!
ctbName
[
0
])
{
if
(
res
==
TSDB_CODE_SUCCESS
)
{
memcpy
(
ctbName
,
pT
blMeta
->
tbName
,
strlen
(
pTblMeta
->
tbName
));
memcpy
(
ctbName
,
pT
ableSinkInfo
->
tbName
,
strlen
(
pTableSinkInfo
->
tbName
));
}
else
{
char
*
tmp
=
buildCtbNameByGroupId
(
stbFullName
,
pDataBlock
->
info
.
id
.
groupId
);
memcpy
(
ctbName
,
tmp
,
strlen
(
tmp
));
memcpy
(
pT
blMeta
->
tbName
,
tmp
,
strlen
(
tmp
));
memcpy
(
pT
ableSinkInfo
->
tbName
,
tmp
,
strlen
(
tmp
));
taosMemoryFree
(
tmp
);
tqDebug
(
"vgId:%d, gropu
id:%"
PRIu64
" datablock tabel
name is null"
,
TD_VID
(
pVnode
),
tqDebug
(
"vgId:%d, gropu
Id:%"
PRIu64
" datablock table
name is null"
,
TD_VID
(
pVnode
),
pDataBlock
->
info
.
id
.
groupId
);
}
}
if
(
res
==
TSDB_CODE_SUCCESS
)
{
tbData
.
uid
=
pT
blMeta
->
uid
;
tbData
.
uid
=
pT
ableSinkInfo
->
uid
;
}
else
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mr
,
ctbName
)
<
0
)
{
metaReaderClear
(
&
mr
);
taosMemoryFree
(
pT
blMeta
);
taosMemoryFree
(
pT
ableSinkInfo
);
tqDebug
(
"vgId:%d, stream write into %s, table auto created"
,
TD_VID
(
pVnode
),
ctbName
);
SVCreateTbReq
*
pCreateTbReq
=
NULL
;
...
...
@@ -371,7 +372,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
tqError
(
"vgId:%d, failed to write into %s, since table type incorrect, type %d"
,
TD_VID
(
pVnode
),
ctbName
,
mr
.
me
.
type
);
metaReaderClear
(
&
mr
);
taosMemoryFree
(
pT
blMeta
);
taosMemoryFree
(
pT
ableSinkInfo
);
continue
;
}
...
...
@@ -380,13 +381,13 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
", actual suid %"
PRId64
""
,
TD_VID
(
pVnode
),
ctbName
,
suid
,
mr
.
me
.
ctbEntry
.
suid
);
metaReaderClear
(
&
mr
);
taosMemoryFree
(
pT
blMeta
);
taosMemoryFree
(
pT
ableSinkInfo
);
continue
;
}
tbData
.
uid
=
mr
.
me
.
uid
;
pT
blMeta
->
uid
=
mr
.
me
.
uid
;
tqPutTableInfo
(
pTask
->
tbSink
.
pTblInfo
,
pDataBlock
->
info
.
id
.
groupId
,
pT
blMeta
);
pT
ableSinkInfo
->
uid
=
mr
.
me
.
uid
;
tqPutTableInfo
(
pTask
->
tbSink
.
pTblInfo
,
pDataBlock
->
info
.
id
.
groupId
,
pT
ableSinkInfo
);
metaReaderClear
(
&
mr
);
}
}
...
...
source/libs/stream/src/stream.c
浏览文件 @
3d00f6ce
...
...
@@ -284,7 +284,9 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S
}
bool
tInputQueueIsFull
(
const
SStreamTask
*
pTask
)
{
return
taosQueueItemSize
((
pTask
->
inputQueue
->
queue
))
>=
STREAM_TASK_INPUT_QUEUEU_CAPACITY
;
bool
isFull
=
taosQueueItemSize
((
pTask
->
inputQueue
->
queue
))
>=
STREAM_TASK_INPUT_QUEUEU_CAPACITY
;
double
size
=
QUEUE_MEM_SIZE_IN_MB
(
pTask
->
inputQueue
->
queue
);
return
(
isFull
||
size
>=
STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE
);
}
int32_t
tAppendDataToInputQueue
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pItem
)
{
...
...
@@ -298,8 +300,7 @@ int32_t tAppendDataToInputQueue(SStreamTask* pTask, SStreamQueueItem* pItem) {
qDebug
(
"s-task:%s submit enqueue msgLen:%d ver:%"
PRId64
", total in queue:%d, size:%.2fMiB"
,
pTask
->
id
.
idStr
,
px
->
submit
.
msgLen
,
px
->
submit
.
ver
,
numOfBlocks
,
size
);
if
((
pTask
->
taskLevel
==
TASK_LEVEL__SOURCE
)
&&
(
numOfBlocks
>
STREAM_TASK_INPUT_QUEUEU_CAPACITY
||
(
size
>=
STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE
)))
{
if
((
pTask
->
taskLevel
==
TASK_LEVEL__SOURCE
)
&&
tInputQueueIsFull
(
pTask
))
{
qError
(
"s-task:%s input queue is full, capacity(size:%d num:%dMiB), current(blocks:%d, size:%.2fMiB) abort"
,
pTask
->
id
.
idStr
,
STREAM_TASK_INPUT_QUEUEU_CAPACITY
,
STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE
,
numOfBlocks
,
size
);
...
...
@@ -320,8 +321,7 @@ int32_t tAppendDataToInputQueue(SStreamTask* pTask, SStreamQueueItem* pItem) {
int32_t
numOfBlocks
=
taosQueueItemSize
(
pTask
->
inputQueue
->
queue
)
+
1
;
double
size
=
QUEUE_MEM_SIZE_IN_MB
(
pTask
->
inputQueue
->
queue
);
if
((
pTask
->
taskLevel
==
TASK_LEVEL__SOURCE
)
&&
(
numOfBlocks
>
STREAM_TASK_INPUT_QUEUEU_CAPACITY
||
(
size
>=
STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE
)))
{
if
((
pTask
->
taskLevel
==
TASK_LEVEL__SOURCE
)
&&
(
tInputQueueIsFull
(
pTask
)))
{
qError
(
"s-task:%s input queue is full, capacity:%d size:%d MiB, current(blocks:%d, size:%.2fMiB) abort"
,
pTask
->
id
.
idStr
,
STREAM_TASK_INPUT_QUEUEU_CAPACITY
,
STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE
,
numOfBlocks
,
size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录