Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
78222a17
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
78222a17
编写于
4月 21, 2022
作者:
L
Liu Jicong
提交者:
GitHub
4月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11706 from taosdata/feature/tq
refactor(tmq): rewrite tq read function
上级
b602a77c
3dd3ad1e
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
216 addition
and
157 deletion
+216
-157
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
source/dnode/mnode/impl/inc/mndScheduler.h
source/dnode/mnode/impl/inc/mndScheduler.h
+2
-0
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+48
-0
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+21
-26
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+143
-129
未找到文件。
include/libs/planner/planner.h
浏览文件 @
78222a17
...
...
@@ -30,6 +30,7 @@ typedef struct SPlanContext {
SNode
*
pAstRoot
;
bool
topicQuery
;
bool
streamQuery
;
bool
rSmaQuery
;
bool
showRewrite
;
int8_t
triggerType
;
int64_t
watermark
;
...
...
source/dnode/mnode/impl/inc/mndScheduler.h
浏览文件 @
78222a17
...
...
@@ -29,6 +29,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
78222a17
...
...
@@ -34,6 +34,54 @@
extern
bool
tsStreamSchedV
;
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
)
{
SNode
*
pAst
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SPlanContext
cxt
=
{
.
pAstRoot
=
pAst
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
rSmaQuery
=
true
,
.
triggerType
=
triggerType
,
.
watermark
=
watermark
,
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
int32_t
levelNum
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
if
(
levelNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SNodeListNode
*
inner
=
nodesListGetNode
(
pPlan
->
pSubplans
,
0
);
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
if
(
opNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
if
(
qSubPlanToString
(
plan
,
pStr
,
pLen
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
END:
if
(
pAst
)
nodesDestroyNode
(
pAst
);
if
(
pPlan
)
nodesDestroyNode
(
pPlan
);
return
terrno
;
}
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
SCoder
encoder
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
78222a17
...
...
@@ -109,8 +109,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
);
// need to reposition
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
78222a17
...
...
@@ -82,16 +82,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
return
false
;
}
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
// currently only rows are used
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
// pBlockInfo->uid = pHandle->pBlock->uid; // the uid can not be assigned to pBlockData.
return
0
;
}
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
)
{
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
)
{
/*int32_t sversion = pHandle->pBlock->sversion;*/
// TODO set to real sversion
int32_t
sversion
=
0
;
...
...
@@ -112,7 +103,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
STSchema
*
pTschema
=
pHandle
->
pSchema
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
int32_t
n
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
*
pN
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
...
...
@@ -120,10 +111,11 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNumNeed
=
pSchemaWrapper
->
nCols
;
}
SArray
*
pArray
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
if
(
pArray
==
NULL
)
{
return
NULL
;
*
ppCols
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
if
(
*
ppCols
==
NULL
)
{
return
-
1
;
}
int32_t
colMeta
=
0
;
int32_t
colNeed
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
...
...
@@ -136,21 +128,24 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNeed
++
;
}
else
{
SColumnInfoData
colInfo
=
{
0
};
/*int sz = numOfRows * pColSchema->bytes;*/
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
numOfRows
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
return
NULL
;
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
*
pNumOfRows
)
<
0
)
{
goto
FAIL
;
}
taosArrayPush
(
pArray
,
&
colInfo
);
taosArrayPush
(
*
ppCols
,
&
colInfo
);
colMeta
++
;
colNeed
++
;
}
}
int32_t
colActual
=
taosArrayGetSize
(
*
ppCols
);
// TODO in stream shuffle case, fetch groupId
*
pGroupId
=
0
;
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pTschema
);
STSRow
*
row
;
...
...
@@ -159,22 +154,22 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
tdSTSRowIterReset
(
&
iter
,
row
);
// get all wanted col of that block
int32_t
colTot
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
colTot
;
i
++
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
pArray
,
i
);
for
(
int32_t
i
=
0
;
i
<
colActual
;
i
++
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
*
ppCols
,
i
);
SCellVal
sVal
=
{
0
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
break
;
}
/*if (colDataAppend(pColData, curRow, sVal.val, false) < 0) {*/
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
return
NULL
;
goto
FAIL
;
}
}
curRow
++
;
}
return
pArray
;
return
0
;
FAIL:
taosArrayDestroy
(
*
ppCols
);
return
-
1
;
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
78222a17
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录