Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
be5b72b2
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看板
提交
be5b72b2
编写于
11月 07, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): add cache for table meta entry in table scan.
上级
c1794e02
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
25 deletion
+45
-25
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+3
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-2
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+39
-20
未找到文件。
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
be5b72b2
...
@@ -153,7 +153,7 @@ bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) {
...
@@ -153,7 +153,7 @@ bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) {
int
metaGetTableEntryByUid
(
SMetaReader
*
pReader
,
tb_uid_t
uid
)
{
int
metaGetTableEntryByUid
(
SMetaReader
*
pReader
,
tb_uid_t
uid
)
{
SMeta
*
pMeta
=
pReader
->
pMeta
;
SMeta
*
pMeta
=
pReader
->
pMeta
;
int64_t
version
;
int64_t
version
1
;
// query uid.idx
// query uid.idx
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
...
@@ -161,8 +161,8 @@ int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
...
@@ -161,8 +161,8 @@ int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
return
-
1
;
return
-
1
;
}
}
version
=
((
SUidIdxVal
*
)
pReader
->
pBuf
)[
0
].
version
;
version
1
=
((
SUidIdxVal
*
)
pReader
->
pBuf
)[
0
].
version
;
return
metaGetTableEntryByVersion
(
pReader
,
version
,
uid
);
return
metaGetTableEntryByVersion
(
pReader
,
version
1
,
uid
);
}
}
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
)
{
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
)
{
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
be5b72b2
...
@@ -318,6 +318,7 @@ typedef struct STableScanInfo {
...
@@ -318,6 +318,7 @@ typedef struct STableScanInfo {
int8_t
scanMode
;
int8_t
scanMode
;
SAggOptrPushDownInfo
pdInfo
;
SAggOptrPushDownInfo
pdInfo
;
int8_t
assignBlockUid
;
int8_t
assignBlockUid
;
SLRUCache
*
pTableMetaEntryCache
;
// 100 by default
}
STableScanInfo
;
}
STableScanInfo
;
typedef
struct
STableMergeScanInfo
{
typedef
struct
STableMergeScanInfo
{
...
@@ -896,8 +897,8 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul
...
@@ -896,8 +897,8 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
,
SColMatchInfo
*
pColMatchInfo
,
SFilterInfo
*
pFilterInfo
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
,
SColMatchInfo
*
pColMatchInfo
,
SFilterInfo
*
pFilterInfo
);
int32_t
addTagPseudoColumnData
(
SReadHandle
*
pHandle
,
SExprInfo
*
pPseudoExpr
,
int32_t
numOfPseudo
Expr
,
int32_t
addTagPseudoColumnData
(
SReadHandle
*
pHandle
,
const
SExprInfo
*
pExpr
,
int32_t
numOf
Expr
,
SSDataBlock
*
pBlock
,
int32_t
rows
,
const
char
*
idStr
);
SSDataBlock
*
pBlock
,
int32_t
rows
,
const
char
*
idStr
,
SLRUCache
*
pCache
);
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
STupleHandle
*
pTupleHandle
);
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
STupleHandle
*
pTupleHandle
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
be5b72b2
...
@@ -495,51 +495,68 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
...
@@ -495,51 +495,68 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
SET_REVERSE_SCAN_FLAG
(
pTableScanInfo
);
SET_REVERSE_SCAN_FLAG
(
pTableScanInfo
);
switchCtxOrder
(
pCtx
,
numOfOutput
);
switchCtxOrder
(
pCtx
,
numOfOutput
);
// setupQueryRangeForReverseScan(pTableScanInfo);
pTableScanInfo
->
cond
.
order
=
TSDB_ORDER_DESC
;
pTableScanInfo
->
cond
.
order
=
TSDB_ORDER_DESC
;
STimeWindow
*
pTWindow
=
&
pTableScanInfo
->
cond
.
twindows
;
STimeWindow
*
pTWindow
=
&
pTableScanInfo
->
cond
.
twindows
;
TSWAP
(
pTWindow
->
skey
,
pTWindow
->
ekey
);
TSWAP
(
pTWindow
->
skey
,
pTWindow
->
ekey
);
}
}
int32_t
addTagPseudoColumnData
(
SReadHandle
*
pHandle
,
SExprInfo
*
pPseudoExpr
,
int32_t
numOfPseudoExpr
,
typedef
struct
STableCachedVal
{
SSDataBlock
*
pBlock
,
int32_t
rows
,
const
char
*
idStr
)
{
const
char
*
pName
;
STag
*
pTags
;
}
STableCachedVal
;
int32_t
addTagPseudoColumnData
(
SReadHandle
*
pHandle
,
const
SExprInfo
*
pExpr
,
int32_t
numOfExpr
,
SSDataBlock
*
pBlock
,
int32_t
rows
,
const
char
*
idStr
,
SLRUCache
*
pCache
)
{
// currently only the tbname pseudo column
// currently only the tbname pseudo column
if
(
numOf
Pseudo
Expr
<=
0
)
{
if
(
numOfExpr
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
0
;
// backup the rows
// backup the rows
int32_t
backupRows
=
pBlock
->
info
.
rows
;
int32_t
backupRows
=
pBlock
->
info
.
rows
;
pBlock
->
info
.
rows
=
rows
;
pBlock
->
info
.
rows
=
rows
;
SMetaReader
mr
=
{
0
};
STableCachedVal
val
=
{
0
};
metaReaderInit
(
&
mr
,
pHandle
->
meta
,
0
);
bool
needFreeReader
=
true
;
int32_t
code
=
metaGetTableEntryByUid
(
&
mr
,
pBlock
->
info
.
uid
);
metaReaderReleaseLock
(
&
mr
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// 1. check if it is existed in meta cache
qError
(
"failed to get table meta, uid:0x%"
PRIx64
", code:%s, %s"
,
pBlock
->
info
.
uid
,
tstrerror
(
terrno
),
idStr
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
&
pBlock
->
info
.
uid
,
sizeof
(
pBlock
->
info
.
uid
));
metaReaderClear
(
&
mr
);
if
(
h
==
NULL
)
{
return
terrno
;
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pHandle
->
meta
,
0
);
code
=
metaGetTableEntryByUid
(
&
mr
,
pBlock
->
info
.
uid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get table meta, uid:0x%"
PRIx64
", code:%s, %s"
,
pBlock
->
info
.
uid
,
tstrerror
(
terrno
),
idStr
);
metaReaderClear
(
&
mr
);
return
terrno
;
}
metaReaderReleaseLock
(
&
mr
);
val
.
pName
=
mr
.
me
.
name
;
val
.
pTags
=
(
STag
*
)
mr
.
me
.
ctbEntry
.
pTags
;
}
else
{
STableCachedVal
*
pVal
=
taosLRUCacheValue
(
pCache
,
h
);
val
=
*
pVal
;
}
}
for
(
int32_t
j
=
0
;
j
<
numOf
Pseudo
Expr
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfExpr
;
++
j
)
{
SExprInfo
*
pExpr
=
&
pPseudo
Expr
[
j
];
const
SExprInfo
*
pExpr1
=
&
p
Expr
[
j
];
int32_t
dstSlotId
=
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
dstSlotId
=
pExpr
1
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlotId
);
colInfoDataCleanup
(
pColInfoData
,
pBlock
->
info
.
rows
);
colInfoDataCleanup
(
pColInfoData
,
pBlock
->
info
.
rows
);
int32_t
functionId
=
pExpr
->
pExpr
->
_function
.
functionId
;
int32_t
functionId
=
pExpr
1
->
pExpr
->
_function
.
functionId
;
// this is to handle the tbname
// this is to handle the tbname
if
(
fmIsScanPseudoColumnFunc
(
functionId
))
{
if
(
fmIsScanPseudoColumnFunc
(
functionId
))
{
setTbNameColData
(
pBlock
,
pColInfoData
,
functionId
,
mr
.
me
.
n
ame
);
setTbNameColData
(
pBlock
,
pColInfoData
,
functionId
,
val
.
pN
ame
);
}
else
{
// these are tags
}
else
{
// these are tags
STagVal
tagVal
=
{
0
};
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pExpr
->
base
.
pParam
[
0
].
pCol
->
colId
;
tagVal
.
cid
=
pExpr
1
->
base
.
pParam
[
0
].
pCol
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
mr
.
me
.
ctbEntry
.
pTags
,
pColInfoData
->
info
.
type
,
&
tagVal
);
const
char
*
p
=
metaGetTableTagVal
(
val
.
pTags
,
pColInfoData
->
info
.
type
,
&
tagVal
);
char
*
data
=
NULL
;
char
*
data
=
NULL
;
if
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
&&
p
!=
NULL
)
{
if
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
&&
p
!=
NULL
)
{
...
@@ -881,6 +898,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
...
@@ -881,6 +898,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pInfo
->
pTableMetaEntryCache
=
taosLRUCacheInit
(
100
,
-
1
,
.
5
);
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doTableScan
,
NULL
,
NULL
,
destroyTableScanOperatorInfo
,
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doTableScan
,
NULL
,
NULL
,
destroyTableScanOperatorInfo
,
getTableScannerExecInfo
);
getTableScannerExecInfo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录