Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ccc2407f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
ccc2407f
编写于
11月 26, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18459 from taosdata/feature/stream
enh(stream): new api for stream queue
上级
7eb5ac34
48894c8b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
135 addition
and
48 deletion
+135
-48
docs/zh/12-taos-sql/14-stream.md
docs/zh/12-taos-sql/14-stream.md
+1
-1
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+29
-4
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+10
-8
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+1
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+0
-1
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+31
-25
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+6
-5
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+0
-1
source/libs/stream/src/streamQueue.c
source/libs/stream/src/streamQueue.c
+56
-0
tests/script/tsim/show/basic.sim
tests/script/tsim/show/basic.sim
+1
-1
未找到文件。
docs/zh/12-taos-sql/14-stream.md
浏览文件 @
ccc2407f
...
...
@@ -72,7 +72,7 @@ SHOW STREAMS;
若要展示更详细的信息,可以使用:
```
sql
SELECT
*
from
performance_schema
.
`perf
_streams`
;
SELECT
*
from
information_schema
.
`ins
_streams`
;
```
## 流式计算的触发模式
...
...
include/libs/stream/tstream.h
浏览文件 @
ccc2407f
...
...
@@ -140,15 +140,40 @@ typedef struct {
int8_t
type
;
}
SStreamCheckpoint
;
typedef
struct
{
int8_t
type
;
}
SStreamTaskDestroy
;
typedef
struct
{
int8_t
type
;
SSDataBlock
*
pBlock
;
}
SStreamTrigger
;
typedef
struct
SStreamQueueNode
SStreamQueueNode
;
struct
SStreamQueueNode
{
SStreamQueueItem
*
item
;
SStreamQueueNode
*
next
;
};
typedef
struct
{
SStreamQueueNode
*
head
;
int64_t
size
;
}
SStreamQueueRes
;
void
streamFreeQitem
(
SStreamQueueItem
*
data
);
bool
streamQueueResEmpty
(
const
SStreamQueueRes
*
pRes
);
int64_t
streamQueueResSize
(
const
SStreamQueueRes
*
pRes
);
SStreamQueueNode
*
streamQueueResFront
(
SStreamQueueRes
*
pRes
);
SStreamQueueNode
*
streamQueueResPop
(
SStreamQueueRes
*
pRes
);
void
streamQueueResClear
(
SStreamQueueRes
*
pRes
);
SStreamQueueRes
streamQueueBuildRes
(
SStreamQueueNode
*
pNode
);
typedef
struct
{
SStreamQueueNode
*
pHead
;
}
SStreamQueue1
;
bool
streamQueueHasTask
(
const
SStreamQueue1
*
pQueue
);
int32_t
streamQueuePush
(
SStreamQueue1
*
pQueue
,
SStreamQueueItem
*
pItem
);
SStreamQueueRes
streamQueueGetRes
(
SStreamQueue1
*
pQueue
);
typedef
struct
{
STaosQueue
*
queue
;
STaosQall
*
qall
;
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
ccc2407f
...
...
@@ -324,15 +324,15 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
}
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqHbReq
req
=
{
0
};
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqHbReq
req
=
{
0
};
if
(
tDeserializeSMqHbReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
int64_t
consumerId
=
req
.
consumerId
;
int64_t
consumerId
=
req
.
consumerId
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
mError
(
"consumer %"
PRId64
" not exist"
,
consumerId
);
...
...
@@ -363,17 +363,17 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
}
static
int32_t
mndProcessAskEpReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqAskEpReq
req
=
{
0
};
SMqAskEpRsp
rsp
=
{
0
};
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqAskEpReq
req
=
{
0
};
SMqAskEpRsp
rsp
=
{
0
};
if
(
tDeserializeSMqAskEpReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
int64_t
consumerId
=
req
.
consumerId
;
int32_t
epoch
=
req
.
epoch
;
int64_t
consumerId
=
req
.
consumerId
;
int32_t
epoch
=
req
.
epoch
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
...
...
@@ -457,6 +457,8 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
if
(
topicEp
.
vgs
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
taosRUnLockLatch
(
&
pConsumer
->
lock
);
taosRUnLockLatch
(
&
pSub
->
lock
);
mndReleaseSubscribe
(
pMnode
,
pSub
);
goto
FAIL
;
}
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
ccc2407f
...
...
@@ -317,9 +317,9 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
bool
externalTargetDB
=
strcmp
(
pStream
->
sourceDb
,
pStream
->
targetDb
)
!=
0
;
SDbObj
*
pDbObj
=
mndAcquireDb
(
pMnode
,
pStream
->
targetDb
);
ASSERT
(
pDbObj
!=
NULL
);
sdbRelease
(
pSdb
,
pDbObj
);
bool
multiTarget
=
pDbObj
->
cfg
.
numOfVgroups
>
1
;
sdbRelease
(
pSdb
,
pDbObj
);
if
(
planTotLevel
==
2
||
externalTargetDB
||
multiTarget
||
pStream
->
fixedSinkVgId
)
{
/*if (true) {*/
...
...
@@ -451,7 +451,6 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
SStreamChildEpInfo
*
pEpInfo
=
taosMemoryMalloc
(
sizeof
(
SStreamChildEpInfo
));
if
(
pEpInfo
==
NULL
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
sdbRelease
(
pSdb
,
pVgroup
);
qDestroyQueryPlan
(
pPlan
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
ccc2407f
...
...
@@ -379,7 +379,6 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t version, char* msg, int32_t m
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
offset
.
subKey
,
strlen
(
offset
.
subKey
));
if
(
pHandle
)
{
if
(
walRefVer
(
pHandle
->
pRef
,
offset
.
val
.
version
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
}
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
ccc2407f
...
...
@@ -915,33 +915,39 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
}
pDest
->
info
.
rows
++
;
if
(
pInfo
->
tbnameCalSup
.
numOfExprs
>
0
&&
i
==
0
)
{
SSDataBlock
*
pTmpBlock
=
blockCopyOneRow
(
pSrc
,
rowIndex
);
SSDataBlock
*
pResBlock
=
createDataBlock
();
pResBlock
->
info
.
rowSize
=
TSDB_TABLE_NAME_LEN
;
SColumnInfoData
data
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
TSDB_TABLE_NAME_LEN
,
0
);
taosArrayPush
(
pResBlock
->
pDataBlock
,
&
data
);
blockDataEnsureCapacity
(
pResBlock
,
1
);
projectApplyFunctions
(
pInfo
->
tbnameCalSup
.
pExprInfo
,
pResBlock
,
pTmpBlock
,
pInfo
->
tbnameCalSup
.
pCtx
,
1
,
NULL
);
ASSERT
(
pResBlock
->
info
.
rows
==
1
);
ASSERT
(
taosArrayGetSize
(
pResBlock
->
pDataBlock
)
==
1
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
0
);
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_VARCHAR
);
void
*
pData
=
colDataGetVarData
(
pCol
,
0
);
// TODO check tbname validity
if
(
pData
!=
(
void
*
)
-
1
)
{
memset
(
pDest
->
info
.
parTbName
,
0
,
TSDB_TABLE_NAME_LEN
);
int32_t
len
=
TMIN
(
varDataLen
(
pData
),
TSDB_TABLE_NAME_LEN
-
1
);
memcpy
(
pDest
->
info
.
parTbName
,
varDataVal
(
pData
),
len
);
/*pDest->info.parTbName[len + 1] = 0;*/
void
*
tbname
=
NULL
;
if
(
streamStateGetParName
(
pOperator
->
pTaskInfo
->
streamInfo
.
pState
,
pParInfo
->
groupId
,
&
tbname
)
==
0
)
{
memcpy
(
pDest
->
info
.
parTbName
,
tbname
,
TSDB_TABLE_NAME_LEN
);
tdbFree
(
tbname
);
}
else
{
pDest
->
info
.
parTbName
[
0
]
=
0
;
}
if
(
pParInfo
->
groupId
&&
pDest
->
info
.
parTbName
[
0
])
{
streamStatePutParName
(
pOperator
->
pTaskInfo
->
streamInfo
.
pState
,
pParInfo
->
groupId
,
pDest
->
info
.
parTbName
);
SSDataBlock
*
pTmpBlock
=
blockCopyOneRow
(
pSrc
,
rowIndex
);
SSDataBlock
*
pResBlock
=
createDataBlock
();
pResBlock
->
info
.
rowSize
=
TSDB_TABLE_NAME_LEN
;
SColumnInfoData
data
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
TSDB_TABLE_NAME_LEN
,
0
);
taosArrayPush
(
pResBlock
->
pDataBlock
,
&
data
);
blockDataEnsureCapacity
(
pResBlock
,
1
);
projectApplyFunctions
(
pInfo
->
tbnameCalSup
.
pExprInfo
,
pResBlock
,
pTmpBlock
,
pInfo
->
tbnameCalSup
.
pCtx
,
1
,
NULL
);
ASSERT
(
pResBlock
->
info
.
rows
==
1
);
ASSERT
(
taosArrayGetSize
(
pResBlock
->
pDataBlock
)
==
1
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
0
);
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_VARCHAR
);
void
*
pData
=
colDataGetVarData
(
pCol
,
0
);
// TODO check tbname validity
if
(
pData
!=
(
void
*
)
-
1
)
{
memset
(
pDest
->
info
.
parTbName
,
0
,
TSDB_TABLE_NAME_LEN
);
int32_t
len
=
TMIN
(
varDataLen
(
pData
),
TSDB_TABLE_NAME_LEN
-
1
);
memcpy
(
pDest
->
info
.
parTbName
,
varDataVal
(
pData
),
len
);
/*pDest->info.parTbName[len + 1] = 0;*/
}
else
{
pDest
->
info
.
parTbName
[
0
]
=
0
;
}
if
(
pParInfo
->
groupId
&&
pDest
->
info
.
parTbName
[
0
])
{
streamStatePutParName
(
pOperator
->
pTaskInfo
->
streamInfo
.
pState
,
pParInfo
->
groupId
,
pDest
->
info
.
parTbName
);
}
/*printf("\n\n set name %s\n\n", pDest->info.parTbName);*/
blockDataDestroy
(
pTmpBlock
);
blockDataDestroy
(
pResBlock
);
}
/*printf("\n\n set name %s\n\n", pDest->info.parTbName);*/
blockDataDestroy
(
pTmpBlock
);
blockDataDestroy
(
pResBlock
);
}
}
taosArrayDestroy
(
pParInfo
->
rowIds
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
ccc2407f
...
...
@@ -163,8 +163,8 @@ static SResultRow* getTableGroupOutputBuf(SOperatorInfo* pOperator, uint64_t gro
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SResultRowPosition
*
p1
=
(
SResultRowPosition
*
)
tSimpleHashGet
(
pTableScanInfo
->
base
.
pdInfo
.
pAggSup
->
pResultRowHashTable
,
buf
,
GET_RES_WINDOW_KEY_LEN
(
sizeof
(
groupId
)));
SResultRowPosition
*
p1
=
(
SResultRowPosition
*
)
tSimpleHashGet
(
pTableScanInfo
->
base
.
pdInfo
.
pAggSup
->
pResultRowHashTable
,
buf
,
GET_RES_WINDOW_KEY_LEN
(
sizeof
(
groupId
)));
if
(
p1
==
NULL
)
{
return
NULL
;
...
...
@@ -306,7 +306,7 @@ void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
static
int32_t
loadDataBlock
(
SOperatorInfo
*
pOperator
,
STableScanBase
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SFileBlockLoadRecorder
*
pCost
=
&
pTableScanInfo
->
readRecorder
;
pCost
->
totalBlocks
+=
1
;
...
...
@@ -1312,6 +1312,7 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS
memcpy
(
varDataVal
(
tbname
),
parTbname
,
TSDB_TABLE_NAME_LEN
);
varDataSetLen
(
tbname
,
strlen
(
varDataVal
(
tbname
)));
tdbFree
(
parTbname
);
}
appendOneRowToStreamSpecialBlock
(
pDestBlock
,
srcStartTsCol
+
i
,
srcEndTsCol
+
i
,
srcUidData
+
i
,
&
groupId
,
tbname
[
0
]
==
0
?
NULL
:
tbname
);
...
...
@@ -1932,6 +1933,7 @@ FETCH_NEXT_BLOCK:
if
(
pInfo
->
validBlockIndex
>=
totBlockNum
)
{
updateInfoDestoryColseWinSBF
(
pInfo
->
pUpdateInfo
);
doClearBufferedBlocks
(
pInfo
);
qDebug
(
"stream scan return empty, consume block %d"
,
totBlockNum
);
return
NULL
;
}
...
...
@@ -2566,7 +2568,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
uint32_t
status
=
0
;
loadDataBlock
(
pOperator
,
&
pTableScanInfo
->
base
,
pBlock
,
&
status
);
// code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status);
// code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -2897,7 +2899,6 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
goto
_error
;
}
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
pInfo
->
pResBlock
=
createResDataBlock
(
pDescNode
);
blockDataEnsureCapacity
(
pInfo
->
pResBlock
,
pOperator
->
resultInfo
.
capacity
);
...
...
source/libs/stream/inc/streamInc.h
浏览文件 @
ccc2407f
...
...
@@ -47,7 +47,6 @@ int32_t streamDispatchOneRecoverFinishReq(SStreamTask* pTask, const SStreamRecov
SEpSet
*
pEpSet
);
SStreamQueueItem
*
streamMergeQueueItem
(
SStreamQueueItem
*
dst
,
SStreamQueueItem
*
elem
);
void
streamFreeQitem
(
SStreamQueueItem
*
data
);
#ifdef __cplusplus
}
...
...
source/libs/stream/src/streamQueue.c
浏览文件 @
ccc2407f
...
...
@@ -45,3 +45,59 @@ void streamQueueClose(SStreamQueue* queue) {
taosCloseQueue
(
queue
->
queue
);
taosMemoryFree
(
queue
);
}
bool
streamQueueResEmpty
(
const
SStreamQueueRes
*
pRes
)
{
//
return
true
;
}
int64_t
streamQueueResSize
(
const
SStreamQueueRes
*
pRes
)
{
return
pRes
->
size
;
}
SStreamQueueNode
*
streamQueueResFront
(
SStreamQueueRes
*
pRes
)
{
return
pRes
->
head
;
}
SStreamQueueNode
*
streamQueueResPop
(
SStreamQueueRes
*
pRes
)
{
SStreamQueueNode
*
pRet
=
pRes
->
head
;
pRes
->
head
=
pRes
->
head
->
next
;
return
pRet
;
}
void
streamQueueResClear
(
SStreamQueueRes
*
pRes
)
{
while
(
pRes
->
head
)
{
SStreamQueueNode
*
pNode
=
pRes
->
head
;
streamFreeQitem
(
pRes
->
head
->
item
);
pRes
->
head
=
pNode
;
}
}
SStreamQueueRes
streamQueueBuildRes
(
SStreamQueueNode
*
pTail
)
{
int64_t
size
=
0
;
SStreamQueueNode
*
head
=
NULL
;
while
(
pTail
)
{
SStreamQueueNode
*
pTmp
=
pTail
->
next
;
pTail
->
next
=
head
;
head
=
pTail
;
pTail
=
pTmp
;
size
++
;
}
return
(
SStreamQueueRes
){.
head
=
head
,
.
size
=
size
};
}
bool
streamQueueHasTask
(
const
SStreamQueue1
*
pQueue
)
{
return
atomic_load_ptr
(
pQueue
->
pHead
);
}
int32_t
streamQueuePush
(
SStreamQueue1
*
pQueue
,
SStreamQueueItem
*
pItem
)
{
SStreamQueueNode
*
pNode
=
taosMemoryMalloc
(
sizeof
(
SStreamQueueNode
));
pNode
->
item
=
pItem
;
SStreamQueueNode
*
pHead
=
atomic_load_ptr
(
pQueue
->
pHead
);
while
(
1
)
{
pNode
->
next
=
pHead
;
SStreamQueueNode
*
pOld
=
atomic_val_compare_exchange_ptr
(
pQueue
->
pHead
,
pHead
,
pNode
);
if
(
pOld
==
pHead
)
{
break
;
}
}
return
0
;
}
SStreamQueueRes
streamQueueGetRes
(
SStreamQueue1
*
pQueue
)
{
SStreamQueueNode
*
pNode
=
atomic_exchange_ptr
(
pQueue
->
pHead
,
NULL
);
if
(
pNode
)
return
streamQueueBuildRes
(
pNode
);
return
(
SStreamQueueRes
){
0
};
}
tests/script/tsim/show/basic.sim
浏览文件 @
ccc2407f
...
...
@@ -195,7 +195,7 @@ sql select * from information_schema.ins_stables
if $rows != 1 then
return -1
endi
#sql select * from
performance_schema.perf
_streams
#sql select * from
information_schema.ins
_streams
sql select * from information_schema.ins_tables
if $rows <= 0 then
return -1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录