Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c1c11d5e
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看板
提交
c1c11d5e
编写于
12月 25, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2512]
上级
96bcd5c2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
16 deletion
+59
-16
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+0
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+59
-15
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
c1c11d5e
...
...
@@ -4662,7 +4662,6 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
// update the query time window
pQuery
->
window
=
cond
.
twindow
;
if
(
pQInfo
->
tableGroupInfo
.
numOfTables
==
0
)
{
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
=
0
;
}
else
{
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
c1c11d5e
...
...
@@ -111,6 +111,7 @@ typedef struct STsdbQueryHandle {
int32_t
activeIndex
;
bool
checkFiles
;
// check file stage
bool
cachelastrow
;
// check if last row cached
SArray
*
cachedRows
;
// cached last rows
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
;
...
...
@@ -135,7 +136,8 @@ typedef struct STableGroupSupporter {
}
STableGroupSupporter
;
static
STimeWindow
updateLastrowForEachGroup
(
STableGroupInfo
*
groupList
);
static
void
checkCachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
);
static
int32_t
extractCachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
);
static
int32_t
tsdbGetCachedLastRow
(
STable
*
pTable
,
SDataRow
*
pRes
,
TSKEY
*
lastKey
);
static
void
changeQueryHandleForInterpQuery
(
TsdbQueryHandleT
pHandle
);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
);
...
...
@@ -380,7 +382,11 @@ TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STab
}
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
,
qinfo
,
pMemRef
);
checkCachedLastRow
(
pQueryHandle
,
groupList
);
int32_t
code
=
extractCachedLastRow
(
pQueryHandle
,
groupList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// set the numOfTables to be 0
terrno
=
code
;
return
NULL
;
}
assert
(
pCond
->
order
==
TSDB_ORDER_ASC
&&
pCond
->
twindow
.
skey
<=
pCond
->
twindow
.
ekey
);
return
pQueryHandle
;
...
...
@@ -2150,7 +2156,36 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
}
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
);
int32_t
numOfCols
=
(
int32_t
)(
QH_GET_NUM_OF_COLS
(
pQueryHandle
));
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
SDataRow
pRow
=
NULL
;
TSKEY
key
=
TSKEY_INITIAL_VAL
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:-
1
;
while
(
pQueryHandle
->
activeIndex
<
numOfTables
)
{
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
pQueryHandle
->
activeIndex
);
int32_t
ret
=
tsdbGetCachedLastRow
(
pCheckInfo
->
pTableObj
,
&
pRow
,
&
key
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
false
;
}
copyOneRowFromMem
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
0
,
pRow
,
numOfCols
,
pCheckInfo
->
pTableObj
);
tfree
(
pRow
);
// update the last key value
pCheckInfo
->
lastKey
=
key
+
step
;
cur
->
rows
=
1
;
// only one row
cur
->
lastKey
=
key
+
step
;
cur
->
mixBlock
=
true
;
pQueryHandle
->
activeIndex
+=
1
;
return
true
;
}
return
false
;
}
if
(
pQueryHandle
->
checkFiles
)
{
...
...
@@ -2188,33 +2223,42 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
* 2. has data but not loaded, just return lastKey but not set pRes
* 3. has data and loaded, return lastKey and set pRes
*/
TSKEY
tsdbGetCachedLastRow
(
STable
*
pTable
,
void
**
pRes
)
{
TSKEY
lastKey
;
int32_t
tsdbGetCachedLastRow
(
STable
*
pTable
,
SDataRow
*
pRes
,
TSKEY
*
lastKey
)
{
TSDB_RLOCK_TABLE
(
pTable
);
lastKey
=
pTable
->
lastKey
;
*
lastKey
=
pTable
->
lastKey
;
if
(
lastKey
!=
TSKEY_INITIAL_VAL
&&
pTable
->
lastRow
)
{
if
(
(
*
lastKey
)
!=
TSKEY_INITIAL_VAL
&&
pTable
->
lastRow
)
{
*
pRes
=
tdDataRowDup
(
pTable
->
lastRow
);
if
(
*
pRes
==
NULL
)
{
// TODO: handle error
TSDB_RUNLOCK_TABLE
(
pTable
);
return
TSDB_CODE_TDB_OUT_OF_MEMORY
;
}
}
TSDB_RUNLOCK_TABLE
(
pTable
);
return
lastKey
;
return
TSDB_CODE_SUCCESS
;
}
void
check
CachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
)
{
int32_t
extract
CachedLastRow
(
STsdbQueryHandle
*
pQueryHandle
,
STableGroupInfo
*
groupList
)
{
assert
(
pQueryHandle
!=
NULL
&&
groupList
!=
NULL
);
void
*
pRes
=
NULL
;
SArray
*
group
=
taosArrayGet
(
groupList
->
pGroupList
,
0
);
SDataRow
pRow
=
NULL
;
TSKEY
key
=
TSKEY_INITIAL_VAL
;
SArray
*
group
=
taosArrayGetP
(
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
);
int32_t
code
=
tsdbGetCachedLastRow
(
pInfo
->
pTable
,
&
pRow
,
&
key
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pQueryHandle
->
cachelastrow
=
false
;
}
else
{
pQueryHandle
->
cachelastrow
=
(
pRow
!=
NULL
);
}
tfree
(
pRow
);
return
code
;
}
STimeWindow
updateLastrowForEachGroup
(
STableGroupInfo
*
groupList
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录