Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
99ae7ab4
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
99ae7ab4
编写于
12月 24, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2512]<enhance>: support in memory cached last row query.
上级
25eb7af9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
10 deletion
+34
-10
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+34
-10
未找到文件。
src/tsdb/src/tsdbRead.c
浏览文件 @
99ae7ab4
...
...
@@ -110,6 +110,7 @@ typedef struct STsdbQueryHandle {
SArray
*
pTableCheckInfo
;
// SArray<STableCheckInfo>
int32_t
activeIndex
;
bool
checkFiles
;
// check file stage
bool
cachelastrow
;
// check if last row cached
void
*
qinfo
;
// query info handle, for debug purpose
int32_t
type
;
// query type: retrieve all data blocks, 2. retrieve only last row, 3. retrieve direct prev|next rows
SFileGroup
*
pFileGroup
;
...
...
@@ -133,7 +134,8 @@ typedef struct STableGroupSupporter {
STSchema
*
pTagSchema
;
}
STableGroupSupporter
;
static
STimeWindow
changeTableGroupByLastrow
(
STableGroupInfo
*
groupList
);
static
STimeWindow
updateLastrowForEachGroup
(
STableGroupInfo
*
groupList
);
static
void
checkCachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
);
static
void
changeQueryHandleForInterpQuery
(
TsdbQueryHandleT
pHandle
);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
);
...
...
@@ -370,7 +372,7 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
}
TsdbQueryHandleT
tsdbQueryLastRow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
,
SMemRef
*
pMemRef
)
{
pCond
->
twindow
=
changeTableGroupByLastrow
(
groupList
);
pCond
->
twindow
=
updateLastrowForEachGroup
(
groupList
);
// no qualified table
if
(
groupList
->
numOfTables
==
0
)
{
...
...
@@ -378,6 +380,7 @@ TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STab
}
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
,
qinfo
,
pMemRef
);
checkCachedLastRow
(
pQueryHandle
,
groupList
);
assert
(
pCond
->
order
==
TSDB_ORDER_ASC
&&
pCond
->
twindow
.
skey
<=
pCond
->
twindow
.
ekey
);
return
pQueryHandle
;
...
...
@@ -2104,6 +2107,10 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
// restore the pMemRef
pQueryHandle
->
pMemRef
=
pMemRef
;
return
ret
;
}
else
if
(
pQueryHandle
->
type
==
TSDB_QUERY_TYPE_LAST
&&
pQueryHandle
->
cachelastrow
)
{
// the last row is cached in buffer, return it directly.
// here note that the pQueryHandle->window may need to be updated.
assert
(
0
);
}
if
(
pQueryHandle
->
checkFiles
)
{
...
...
@@ -2136,7 +2143,24 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
return
ret
;
}
STimeWindow
changeTableGroupByLastrow
(
STableGroupInfo
*
groupList
)
{
int32_t
tsdbGetCachedLastRow
(
STable
*
pTable
,
void
**
pRes
)
{
return
0
;
}
void
checkCachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
)
{
assert
(
pQueryHandle
!=
NULL
&&
groupList
!=
NULL
);
void
*
pRes
=
NULL
;
SArray
*
group
=
taosArrayGet
(
groupList
->
pGroupList
,
0
);
assert
(
group
!=
NULL
);
STableKeyInfo
*
pInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
group
,
0
);
int32_t
ret
=
tsdbGetCachedLastRow
(
pInfo
->
pTable
,
&
pRes
);
pQueryHandle
->
cachelastrow
=
(
ret
==
TSDB_CODE_SUCCESS
);
}
STimeWindow
updateLastrowForEachGroup
(
STableGroupInfo
*
groupList
)
{
STimeWindow
window
=
{
INT64_MAX
,
INT64_MIN
};
int32_t
totalNumOfTable
=
0
;
...
...
@@ -2151,16 +2175,16 @@ STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) {
size_t
numOfTables
=
taosArrayGetSize
(
pGroup
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
p
Key
Info
=
(
STableKeyInfo
*
)
taosArrayGet
(
pGroup
,
i
);
STableKeyInfo
*
pInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pGroup
,
i
);
// if the lastKey equals to INT64_MIN, there is no data in this table
TSKEY
lastKey
=
((
STable
*
)(
p
Key
Info
->
pTable
))
->
lastKey
;
TSKEY
lastKey
=
((
STable
*
)(
pInfo
->
pTable
))
->
lastKey
;
if
(
key
<
lastKey
)
{
key
=
lastKey
;
keyInfo
.
pTable
=
p
Key
Info
->
pTable
;
keyInfo
.
pTable
=
pInfo
->
pTable
;
keyInfo
.
lastKey
=
key
;
p
KeyInfo
->
lastKey
=
key
;
p
Info
->
lastKey
=
key
;
if
(
key
<
window
.
skey
)
{
window
.
skey
=
key
;
...
...
@@ -2174,11 +2198,11 @@ STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) {
// clear current group, unref unused table
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
p
Key
Info
=
(
STableKeyInfo
*
)
taosArrayGet
(
pGroup
,
i
);
STableKeyInfo
*
pInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pGroup
,
i
);
// keyInfo.pTable may be NULL here.
if
(
p
Key
Info
->
pTable
!=
keyInfo
.
pTable
)
{
tsdbUnRefTable
(
p
Key
Info
->
pTable
);
if
(
pInfo
->
pTable
!=
keyInfo
.
pTable
)
{
tsdbUnRefTable
(
pInfo
->
pTable
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录