Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
482c319b
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
482c319b
编写于
4月 03, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
3ef7d43d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
56 addition
and
47 deletion
+56
-47
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+3
-18
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+1
-1
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+3
-3
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+21
-5
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+28
-20
未找到文件。
include/libs/stream/tstream.h
浏览文件 @
482c319b
...
...
@@ -223,27 +223,12 @@ static FORCE_INLINE void* streamQueueCurItem(SStreamQueue* queue) {
return
queue
->
qItem
;
}
static
FORCE_INLINE
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
)
{
int8_t
dequeueFlag
=
atomic_exchange_8
(
&
queue
->
status
,
STREAM_QUEUE__PROCESSING
);
if
(
dequeueFlag
==
STREAM_QUEUE__FAILED
)
{
ASSERT
(
queue
->
qItem
!=
NULL
);
return
streamQueueCurItem
(
queue
);
}
else
{
queue
->
qItem
=
NULL
;
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
if
(
queue
->
qItem
==
NULL
)
{
taosReadAllQitems
(
queue
->
queue
,
queue
->
qall
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
}
return
streamQueueCurItem
(
queue
);
}
}
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
);
SStreamDataSubmit2
*
streamDataSubmitNew
(
SPackedData
submit
);
void
streamDataSubmitDestroy
(
SStreamDataSubmit2
*
pDataSubmit
);
void
streamDataSubmitRefDec
(
SStreamDataSubmit2
*
pDataSubmit
);
SStreamDataSubmit2
*
streamSubmitRefClone
(
SStreamDataSubmit2
*
pSubmit
);
SStreamDataSubmit2
*
streamSubmitBlockClone
(
SStreamDataSubmit2
*
pSubmit
);
typedef
struct
{
char
*
qmsg
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
482c319b
...
...
@@ -1431,7 +1431,7 @@ int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) {
}
if
(
pSubmit
)
{
streamDataSubmit
RefDec
(
pSubmit
);
streamDataSubmit
Destroy
(
pSubmit
);
taosFreeQitem
(
pSubmit
);
}
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
482c319b
...
...
@@ -30,7 +30,7 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
// update processed
atomic_store_64(&pHandle->pushHandle.processedVer, pSubmit->ver);
streamQueueProcessSuccess(&pHandle->pushHandle.inputQ);
streamDataSubmit
RefDec
(pSubmit);
streamDataSubmit
Destroy
(pSubmit);
if (pRsp->blockNum > 0) {
*ppSubmit = pSubmit;
return 0;
...
...
@@ -58,7 +58,7 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
}
while (pHandle->pushHandle.processedVer > pSubmit->ver + 1) {
streamQueueProcessSuccess(&pHandle->pushHandle.inputQ);
streamDataSubmit
RefDec
(pSubmit);
streamDataSubmit
Destroy
(pSubmit);
pSubmit = streamQueueNextItem(&pHandle->pushHandle.inputQ);
if (pSubmit == NULL) break;
}
...
...
@@ -120,7 +120,7 @@ int32_t tqPreparePush(STQ* pTq, STqHandle* pHandle, int64_t reqId, const SRpcHan
int32_t tqEnqueue(STqHandle* pHandle, SStreamDataSubmit* pSubmit) {
int8_t inputStatus = atomic_load_8(&pHandle->pushHandle.inputStatus);
if (inputStatus == TASK_INPUT_STATUS__NORMAL) {
SStreamDataSubmit* pSubmitClone = streamSubmit
Ref
Clone(pSubmit);
SStreamDataSubmit* pSubmitClone = streamSubmit
Block
Clone(pSubmit);
if (pSubmitClone == NULL) {
return -1;
}
...
...
source/libs/stream/src/stream.c
浏览文件 @
482c319b
...
...
@@ -279,18 +279,18 @@ int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) {
int8_t
type
=
pItem
->
type
;
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
SStreamDataSubmit2
*
pSubmit
Clone
=
streamSubmitRef
Clone
((
SStreamDataSubmit2
*
)
pItem
);
if
(
pSubmit
Clone
==
NULL
)
{
SStreamDataSubmit2
*
pSubmit
Block
=
streamSubmitBlock
Clone
((
SStreamDataSubmit2
*
)
pItem
);
if
(
pSubmit
Block
==
NULL
)
{
qDebug
(
"task %d %p submit enqueue failed since out of memory"
,
pTask
->
taskId
,
pTask
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
return
-
1
;
}
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pSubmit
Clone
);
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pSubmit
Block
);
qDebug
(
"stream task:%d %p submit enqueue %p %p %p msgLen:%d ver:%"
PRId64
", total in queue:%d"
,
pTask
->
taskId
,
pTask
,
pItem
,
pSubmit
Clone
,
pSubmitClone
->
submit
.
msgStr
,
pSubmitClone
->
submit
.
msgLen
,
pSubmit
Clone
->
submit
.
ver
,
pTask
->
inputQueue
->
queue
->
numOfItems
);
pTask
,
pItem
,
pSubmit
Block
,
pSubmitBlock
->
submit
.
msgStr
,
pSubmitBlock
->
submit
.
msgLen
,
pSubmit
Block
->
submit
.
ver
,
pTask
->
inputQueue
->
queue
->
numOfItems
);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
||
type
==
STREAM_INPUT__DATA_RETRIEVE
||
type
==
STREAM_INPUT__REF_DATA_BLOCK
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
...
...
@@ -309,4 +309,20 @@ int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) {
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL);
#endif
return
0
;
}
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
)
{
int8_t
dequeueFlag
=
atomic_exchange_8
(
&
queue
->
status
,
STREAM_QUEUE__PROCESSING
);
if
(
dequeueFlag
==
STREAM_QUEUE__FAILED
)
{
ASSERT
(
queue
->
qItem
!=
NULL
);
return
streamQueueCurItem
(
queue
);
}
else
{
queue
->
qItem
=
NULL
;
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
if
(
queue
->
qItem
==
NULL
)
{
taosReadAllQitems
(
queue
->
queue
,
queue
->
qall
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
}
return
streamQueueCurItem
(
queue
);
}
}
\ No newline at end of file
source/libs/stream/src/streamData.c
浏览文件 @
482c319b
...
...
@@ -48,10 +48,12 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
if
(
pArray
==
NULL
)
{
return
-
1
;
}
taosArrayPush
(
pArray
,
&
(
SSDataBlock
){
0
});
SRetrieveTableRsp
*
pRetrieve
=
pReq
->
pRetrieve
;
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pArray
,
0
);
blockDecode
(
pDataBlock
,
pRetrieve
->
data
);
// TODO: refactor
pDataBlock
->
info
.
window
.
skey
=
be64toh
(
pRetrieve
->
skey
);
pDataBlock
->
info
.
window
.
ekey
=
be64toh
(
pRetrieve
->
ekey
);
...
...
@@ -79,25 +81,40 @@ SStreamDataSubmit2* streamDataSubmitNew(SPackedData submit) {
}
pDataSubmit
->
submit
=
submit
;
*
pDataSubmit
->
dataRef
=
1
;
*
pDataSubmit
->
dataRef
=
1
;
// initialize the reference count to be 1
pDataSubmit
->
type
=
STREAM_INPUT__DATA_SUBMIT
;
return
pDataSubmit
;
}
void
streamDataSubmitDestroy
(
SStreamDataSubmit2
*
pDataSubmit
)
{
int32_t
ref
=
atomic_sub_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
ASSERT
(
ref
>=
0
&&
pDataSubmit
->
type
==
STREAM_INPUT__DATA_SUBMIT
);
if
(
ref
==
0
)
{
taosMemoryFree
(
pDataSubmit
->
submit
.
msgStr
);
taosMemoryFree
(
pDataSubmit
->
dataRef
);
}
}
SStreamMergedSubmit2
*
streamMergedSubmitNew
()
{
SStreamMergedSubmit2
*
pMerged
=
(
SStreamMergedSubmit2
*
)
taosAllocateQitem
(
sizeof
(
SStreamMergedSubmit2
),
DEF_QITEM
,
0
);
if
(
pMerged
==
NULL
)
{
return
NULL
;
}
if
(
pMerged
==
NULL
)
return
NULL
;
pMerged
->
submits
=
taosArrayInit
(
0
,
sizeof
(
SPackedData
));
pMerged
->
dataRefs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
pMerged
->
dataRefs
==
NULL
||
pMerged
->
submits
==
NULL
)
goto
FAIL
;
if
(
pMerged
->
dataRefs
==
NULL
||
pMerged
->
submits
==
NULL
)
{
taosArrayDestroy
(
pMerged
->
submits
);
taosArrayDestroy
(
pMerged
->
dataRefs
);
taosFreeQitem
(
pMerged
);
return
NULL
;
}
pMerged
->
type
=
STREAM_INPUT__MERGED_SUBMIT
;
return
pMerged
;
FAIL:
if
(
pMerged
->
submits
)
taosArrayDestroy
(
pMerged
->
submits
);
if
(
pMerged
->
dataRefs
)
taosArrayDestroy
(
pMerged
->
dataRefs
);
taosFreeQitem
(
pMerged
);
return
NULL
;
}
int32_t
streamMergeSubmit
(
SStreamMergedSubmit2
*
pMerged
,
SStreamDataSubmit2
*
pSubmit
)
{
...
...
@@ -111,26 +128,17 @@ static FORCE_INLINE void streamDataSubmitRefInc(SStreamDataSubmit2* pDataSubmit)
atomic_add_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
}
SStreamDataSubmit2
*
streamSubmit
Ref
Clone
(
SStreamDataSubmit2
*
pSubmit
)
{
SStreamDataSubmit2
*
streamSubmit
Block
Clone
(
SStreamDataSubmit2
*
pSubmit
)
{
SStreamDataSubmit2
*
pSubmitClone
=
taosAllocateQitem
(
sizeof
(
SStreamDataSubmit2
),
DEF_QITEM
,
0
);
if
(
pSubmitClone
==
NULL
)
{
return
NULL
;
}
streamDataSubmitRefInc
(
pSubmit
);
memcpy
(
pSubmitClone
,
pSubmit
,
sizeof
(
SStreamDataSubmit2
));
return
pSubmitClone
;
}
void
streamDataSubmitRefDec
(
SStreamDataSubmit2
*
pDataSubmit
)
{
int32_t
ref
=
atomic_sub_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
ASSERT
(
ref
>=
0
);
if
(
ref
==
0
)
{
taosMemoryFree
(
pDataSubmit
->
submit
.
msgStr
);
taosMemoryFree
(
pDataSubmit
->
dataRef
);
}
}
SStreamQueueItem
*
streamMergeQueueItem
(
SStreamQueueItem
*
dst
,
SStreamQueueItem
*
elem
)
{
ASSERT
(
elem
);
if
(
dst
->
type
==
STREAM_INPUT__DATA_BLOCK
&&
elem
->
type
==
STREAM_INPUT__DATA_BLOCK
)
{
...
...
@@ -168,7 +176,7 @@ void streamFreeQitem(SStreamQueueItem* data) {
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
blockDataFreeRes
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
streamDataSubmit
RefDec
((
SStreamDataSubmit2
*
)
data
);
streamDataSubmit
Destroy
((
SStreamDataSubmit2
*
)
data
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__MERGED_SUBMIT
)
{
SStreamMergedSubmit2
*
pMerge
=
(
SStreamMergedSubmit2
*
)
data
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录