Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c70c9546
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看板
未验证
提交
c70c9546
编写于
3月 10, 2023
作者:
S
Shengliang Guan
提交者:
GitHub
3月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20372 from taosdata/fix/main_bugfix_wxy
enh: optimize last/last_row cost when the cache was first loaded
上级
522b9ec2
47417e00
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
6 deletion
+24
-6
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+8
-6
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+15
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
c70c9546
...
...
@@ -780,6 +780,7 @@ typedef struct SCacheRowsReader {
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReaderLast
;
const
char
*
idstr
;
int64_t
lastTs
;
}
SCacheRowsReader
;
typedef
struct
{
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
c70c9546
...
...
@@ -722,6 +722,7 @@ typedef struct SFSNextRowIter {
int32_t
iRow
;
TSDBROW
row
;
SSttBlockLoadInfo
*
pLoadInfo
;
int64_t
lastTs
;
}
SFSNextRowIter
;
static
int32_t
getNextRowFromFS
(
void
*
iter
,
TSDBROW
**
ppRow
)
{
...
...
@@ -816,12 +817,12 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
SDataBlk
block
=
{
0
};
tDataBlkReset
(
&
block
);
// tBlockDataReset(&state->blockData);
tBlockDataReset
(
state
->
pBlockData
);
tMapDataGetItemByIdx
(
&
state
->
blockMap
,
state
->
iBlock
,
&
block
,
tGetDataBlk
);
/* code = tsdbReadBlockData(state->pDataFReader, &state->blockIdx, &block, &state->blockData, NULL, NULL);
*/
if
(
block
.
maxKey
.
ts
<=
state
->
lastTs
)
{
goto
_next_fileset
;
}
tBlockDataReset
(
state
->
pBlockData
);
TABLEID
tid
=
{.
suid
=
state
->
suid
,
.
uid
=
state
->
uid
};
code
=
tBlockDataInit
(
state
->
pBlockData
,
&
tid
,
state
->
pTSchema
,
NULL
,
0
);
...
...
@@ -1070,7 +1071,7 @@ typedef struct {
static
int32_t
nextRowIterOpen
(
CacheNextRowIter
*
pIter
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
STSchema
*
pTSchema
,
tb_uid_t
suid
,
SSttBlockLoadInfo
*
pLoadInfo
,
STsdbReadSnap
*
pReadSnap
,
SDataFReader
**
pDataFReader
,
SDataFReader
**
pDataFReaderLast
)
{
SDataFReader
**
pDataFReaderLast
,
int64_t
lastTs
)
{
int
code
=
0
;
STbData
*
pMem
=
NULL
;
...
...
@@ -1141,6 +1142,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
pIter
->
fsState
.
uid
=
uid
;
pIter
->
fsState
.
pLoadInfo
=
pLoadInfo
;
pIter
->
fsState
.
pDataFReader
=
pDataFReader
;
pIter
->
fsState
.
lastTs
=
lastTs
;
pIter
->
input
[
0
]
=
(
TsdbNextRowState
){
&
pIter
->
memRow
,
true
,
false
,
&
pIter
->
memState
,
getNextRowFromMem
,
NULL
};
pIter
->
input
[
1
]
=
(
TsdbNextRowState
){
&
pIter
->
imemRow
,
true
,
false
,
&
pIter
->
imemState
,
getNextRowFromMem
,
NULL
};
...
...
@@ -1315,7 +1317,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
pReadSnap
,
&
pr
->
pDataFReader
,
&
pr
->
pDataFReaderLast
);
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
do
{
TSDBROW
*
pRow
=
NULL
;
...
...
@@ -1453,7 +1455,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
,
pTSchema
,
pr
->
suid
,
pr
->
pLoadInfo
,
pr
->
pReadSnap
,
&
pr
->
pDataFReader
,
&
pr
->
pDataFReaderLast
);
&
pr
->
pDataFReaderLast
,
pr
->
lastTs
);
do
{
TSDBROW
*
pRow
=
NULL
;
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
c70c9546
...
...
@@ -199,6 +199,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
p
->
idstr
=
taosStrdup
(
idstr
);
taosThreadMutexInit
(
&
p
->
readerMutex
,
NULL
);
p
->
lastTs
=
INT64_MIN
;
*
pReader
=
p
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -347,6 +349,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
{
bool
hasNotNullRow
=
true
;
int64_t
minTs
=
INT64_MAX
;
for
(
int32_t
k
=
0
;
k
<
pr
->
numOfCols
;
++
k
)
{
int32_t
slotId
=
slotIds
[
k
];
...
...
@@ -357,6 +361,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
hasRes
=
true
;
p
->
ts
=
pCol
->
ts
;
p
->
colVal
=
pCol
->
colVal
;
minTs
=
pCol
->
ts
;
// only set value for last row query
if
(
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST_ROW
))
{
...
...
@@ -373,11 +378,17 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
if
(
pColVal
->
ts
>
p
->
ts
)
{
if
(
!
COL_VAL_IS_VALUE
(
&
pColVal
->
colVal
)
&&
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST
))
{
if
(
!
COL_VAL_IS_VALUE
(
&
p
->
colVal
))
{
hasNotNullRow
=
false
;
}
continue
;
}
hasRes
=
true
;
p
->
ts
=
pColVal
->
ts
;
if
(
pColVal
->
ts
<
minTs
&&
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST
))
{
minTs
=
pColVal
->
ts
;
}
if
(
!
IS_VAR_DATA_TYPE
(
pColVal
->
colVal
.
type
))
{
p
->
colVal
=
pColVal
->
colVal
;
...
...
@@ -394,6 +405,10 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
}
}
if
(
hasNotNullRow
)
{
pr
->
lastTs
=
minTs
;
}
}
tsdbCacheRelease
(
lruCache
,
h
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录