Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
443e8e25
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看板
提交
443e8e25
编写于
2月 10, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): add limit/offset for sys table scan operator.
上级
d69b57fa
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
35 addition
and
37 deletion
+35
-37
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+35
-37
未找到文件。
source/libs/executor/src/sysscanoperator.c
浏览文件 @
443e8e25
...
...
@@ -65,7 +65,7 @@ typedef struct SSysTableScanInfo {
SSDataBlock
*
pRes
;
int64_t
numOfBlocks
;
// extract basic running information.
SLoadRemoteDataInfo
loadInfo
;
SLimitInfo
limitInfo
;
int32_t
tbnameSlotId
;
}
SSysTableScanInfo
;
...
...
@@ -133,7 +133,6 @@ static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capac
static
SSDataBlock
*
buildInfoSchemaTableMetaBlock
(
char
*
tableName
);
static
void
destroySysScanOperator
(
void
*
param
);
static
int32_t
loadSysTableCallback
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
);
static
SSDataBlock
*
doFilterResult
(
SSDataBlock
*
pDataBlock
,
SFilterInfo
*
pFilterInfo
);
static
__optSysFilter
optSysGetFilterFunc
(
int32_t
ctype
,
bool
*
reverse
);
static
int32_t
sysTableUserTagsFillOneTableTags
(
const
SSysTableScanInfo
*
pInfo
,
SMetaReader
*
smrSuperTable
,
...
...
@@ -351,7 +350,7 @@ static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt);
static
SSDataBlock
*
sysTableScanFromMNode
(
SOperatorInfo
*
pOperator
,
SSysTableScanInfo
*
pInfo
,
const
char
*
name
,
SExecTaskInfo
*
pTaskInfo
);
void
extractTbnameSlotId
(
SSysTableScanInfo
*
pInfo
,
const
SScanPhysiNode
*
pScanNode
);
static
SSDataBlock
*
sysTableScanFillTbName
(
SOperatorInfo
*
pOperator
,
const
SSysTableScanInfo
*
pInfo
,
static
void
sysTableScanFillTbName
(
SOperatorInfo
*
pOperator
,
const
SSysTableScanInfo
*
pInfo
,
const
char
*
name
,
SSDataBlock
*
pBlock
);
__optSysFilter
optSysGetFilterFunc
(
int32_t
ctype
,
bool
*
reverse
)
{
if
(
ctype
==
OP_TYPE_LOWER_EQUAL
||
ctype
==
OP_TYPE_LOWER_THAN
)
{
...
...
@@ -556,7 +555,7 @@ void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfR
pInfo
->
pRes
->
info
.
rows
=
numOfRows
;
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
matchInfo
.
pList
,
dataBlock
->
pDataBlock
,
false
);
doFilter
Result
(
pInfo
->
pRes
,
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pFilterInfo
,
NULL
);
blockDataCleanup
(
dataBlock
);
}
...
...
@@ -975,7 +974,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
pInfo
->
pRes
->
info
.
rows
=
numOfRows
;
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
matchInfo
.
pList
,
p
->
pDataBlock
,
false
);
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
blockDataCleanup
(
p
);
numOfRows
=
0
;
...
...
@@ -991,7 +990,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
pInfo
->
pRes
->
info
.
rows
=
numOfRows
;
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
matchInfo
.
pList
,
p
->
pDataBlock
,
false
);
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
blockDataCleanup
(
p
);
numOfRows
=
0
;
...
...
@@ -1152,7 +1151,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
pInfo
->
pRes
->
info
.
rows
=
numOfRows
;
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
matchInfo
.
pList
,
p
->
pDataBlock
,
false
);
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
blockDataCleanup
(
p
);
numOfRows
=
0
;
...
...
@@ -1168,7 +1167,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
pInfo
->
pRes
->
info
.
rows
=
numOfRows
;
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
matchInfo
.
pList
,
p
->
pDataBlock
,
false
);
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
blockDataCleanup
(
p
);
numOfRows
=
0
;
...
...
@@ -1199,7 +1198,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
if
(
pInfo
->
readHandle
.
mnd
!=
NULL
)
{
buildSysDbTableInfo
(
pInfo
,
pOperator
->
resultInfo
.
capacity
);
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
pInfo
->
loadInfo
.
totalRows
+=
pInfo
->
pRes
->
info
.
rows
;
setOperatorCompleted
(
pOperator
);
...
...
@@ -1324,6 +1323,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
getDBNameFromCondition
(
pInfo
->
pCondition
,
dbName
);
sprintf
(
pInfo
->
req
.
db
,
"%d.%s"
,
pInfo
->
accountId
,
dbName
);
}
SSDataBlock
*
pBlock
=
NULL
;
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TABLES
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
pBlock
=
sysTableScanUserTables
(
pOperator
);
...
...
@@ -1336,28 +1336,35 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pBlock
=
sysTableScanFromMNode
(
pOperator
,
pInfo
,
name
,
pTaskInfo
);
}
return
sysTableScanFillTbName
(
pOperator
,
pInfo
,
name
,
pBlock
);
sysTableScanFillTbName
(
pOperator
,
pInfo
,
name
,
pBlock
);
if
(
pBlock
!=
NULL
)
{
bool
limitReached
=
applyLimitOffset
(
&
pInfo
->
limitInfo
,
pBlock
,
pTaskInfo
);
if
(
limitReached
)
{
setOperatorCompleted
(
pOperator
);
}
return
pBlock
->
info
.
rows
>
0
?
pBlock
:
NULL
;
}
else
{
return
NULL
;
}
}
static
SSDataBlock
*
sysTableScanFillTbName
(
SOperatorInfo
*
pOperator
,
const
SSysTableScanInfo
*
pInfo
,
const
char
*
name
,
SSDataBlock
*
pBlock
)
{
if
(
pBlock
!=
NULL
)
{
static
void
sysTableScanFillTbName
(
SOperatorInfo
*
pOperator
,
const
SSysTableScanInfo
*
pInfo
,
const
char
*
name
,
SSDataBlock
*
pBlock
)
{
if
(
pBlock
==
NULL
)
{
return
;
}
if
(
pInfo
->
tbnameSlotId
!=
-
1
)
{
SColumnInfoData
*
pColumnInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
pInfo
->
tbnameSlotId
);
char
varTbName
[
TSDB_TABLE_FNAME_LEN
-
1
+
VARSTR_HEADER_SIZE
]
=
{
0
};
memcpy
(
varDataVal
(
varTbName
),
name
,
strlen
(
name
));
varDataSetLen
(
varTbName
,
strlen
(
name
));
for
(
int
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
colDataAppend
(
pColumnInfoData
,
i
,
varTbName
,
NULL
);
}
doFilterResult
(
pBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
}
}
if
(
pBlock
&&
pBlock
->
info
.
rows
!=
0
)
{
return
pBlock
;
}
else
{
return
NULL
;
colDataAppendNItems
(
pColumnInfoData
,
0
,
varTbName
,
pBlock
->
info
.
rows
);
}
doFilter
(
pBlock
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
}
static
SSDataBlock
*
sysTableScanFromMNode
(
SOperatorInfo
*
pOperator
,
SSysTableScanInfo
*
pInfo
,
const
char
*
name
,
...
...
@@ -1423,7 +1430,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
updateLoadRemoteInfo
(
&
pInfo
->
loadInfo
,
pRsp
->
numOfRows
,
pRsp
->
compLen
,
startTs
,
pOperator
);
// todo log the filter info
doFilter
Result
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
);
doFilter
(
pInfo
->
pRes
,
pOperator
->
exprSupp
.
pFilterInfo
,
NULL
);
taosMemoryFree
(
pRsp
);
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
return
pInfo
->
pRes
;
...
...
@@ -1457,13 +1464,13 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
pInfo
->
sysInfo
=
pScanPhyNode
->
sysInfo
;
pInfo
->
showRewrite
=
pScanPhyNode
->
showRewrite
;
pInfo
->
pRes
=
createDataBlockFromDescNode
(
pDescNode
);
pInfo
->
pCondition
=
pScanNode
->
node
.
pConditions
;
code
=
filterInitFromNode
(
pScanNode
->
node
.
pConditions
,
&
pOperator
->
exprSupp
.
pFilterInfo
,
0
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
initLimitInfo
(
pScanPhyNode
->
scan
.
node
.
pLimit
,
pScanPhyNode
->
scan
.
node
.
pSlimit
,
&
pInfo
->
limitInfo
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
...
...
@@ -1556,15 +1563,6 @@ int32_t loadSysTableCallback(void* param, SDataBuf* pMsg, int32_t code) {
return
TSDB_CODE_SUCCESS
;
}
SSDataBlock
*
doFilterResult
(
SSDataBlock
*
pDataBlock
,
SFilterInfo
*
pFilterInfo
)
{
if
(
pFilterInfo
==
NULL
)
{
return
pDataBlock
->
info
.
rows
==
0
?
NULL
:
pDataBlock
;
}
doFilter
(
pDataBlock
,
pFilterInfo
,
NULL
);
return
pDataBlock
->
info
.
rows
==
0
?
NULL
:
pDataBlock
;
}
static
int32_t
sysChkFilter__Comm
(
SNode
*
pNode
)
{
// impl
SOperatorNode
*
pOper
=
(
SOperatorNode
*
)
pNode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录