Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
2589fc9e
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2589fc9e
编写于
4月 13, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-98] fix time range query bug when data kept in buffer
上级
f5a1ac4b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
14 deletion
+44
-14
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+1
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+7
-2
src/vnode/tsdb/src/tsdbRead.c
src/vnode/tsdb/src/tsdbRead.c
+36
-11
未找到文件。
src/query/inc/queryExecutor.h
浏览文件 @
2589fc9e
...
...
@@ -160,7 +160,7 @@ typedef struct SQueryRuntimeEnv {
SQueryCostSummary
summary
;
bool
stableQuery
;
// super table query or not
void
*
pQueryHandle
;
void
*
pS
ub
QueryHandle
;
// another thread for
void
*
pS
ec
QueryHandle
;
// another thread for
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
}
SQueryRuntimeEnv
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
2589fc9e
...
...
@@ -1552,6 +1552,8 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
destroyResultBuf
(
pRuntimeEnv
->
pResultBuf
);
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pQueryHandle
);
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pSecQueryHandle
);
pRuntimeEnv
->
pTSBuf
=
tsBufDestory
(
pRuntimeEnv
->
pTSBuf
);
}
...
...
@@ -2565,7 +2567,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
dTrace
(
"QInfo:%p query start, qrange:%"
PRId64
"-%"
PRId64
", lastkey:%"
PRId64
", order:%d"
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
pQuery
->
lastKey
,
pQuery
->
order
.
order
);
tsdb_query_handle_t
pQueryHandle
=
pRuntimeEnv
->
scanFlag
==
MASTER_SCAN
?
pRuntimeEnv
->
pQueryHandle
:
pRuntimeEnv
->
pS
ub
QueryHandle
;
tsdb_query_handle_t
pQueryHandle
=
pRuntimeEnv
->
scanFlag
==
MASTER_SCAN
?
pRuntimeEnv
->
pQueryHandle
:
pRuntimeEnv
->
pS
ec
QueryHandle
;
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
if
(
isQueryKilled
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
...
...
@@ -3557,7 +3559,10 @@ void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
taosArrayPush
(
cols
,
&
pQuery
->
colList
[
i
]);
}
pRuntimeEnv
->
pSubQueryHandle
=
tsdbQueryByTableId
(
pQInfo
->
tsdb
,
&
cond
,
pQInfo
->
pTableIdList
,
cols
);
if
(
pRuntimeEnv
->
pSecQueryHandle
!=
NULL
)
{
pRuntimeEnv
->
pSecQueryHandle
=
tsdbQueryByTableId
(
pQInfo
->
tsdb
,
&
cond
,
pQInfo
->
pTableIdList
,
cols
);
}
taosArrayDestroy
(
cols
);
status
=
pQuery
->
status
;
...
...
src/vnode/tsdb/src/tsdbRead.c
浏览文件 @
2589fc9e
...
...
@@ -218,9 +218,31 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
if
(
pTable
->
mem
==
NULL
&&
pTable
->
imem
==
NULL
)
{
return
false
;
}
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pHandle
->
pTableCheckInfo
,
pHandle
->
activeIndex
);
pTable
=
pCheckInfo
->
pTableObj
;
if
(
pCheckInfo
->
iter
==
NULL
)
{
pCheckInfo
->
iter
=
tSkipListCreateIter
(
pTable
->
mem
->
pData
);
if
(
pCheckInfo
->
iter
==
NULL
)
{
return
false
;
}
}
if
(
!
tSkipListIterNext
(
pCheckInfo
->
iter
))
{
// buffer is empty
return
false
;
}
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
if
(
node
==
NULL
)
{
return
false
;
}
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
pCheckInfo
->
lastKey
=
dataRowKey
(
row
);
// first timestamp in buffer
// all data in mem are checked already.
if
(
pTableCheckInfo
->
lastKey
>
p
Table
->
mem
->
keyLast
)
{
if
(
pTableCheckInfo
->
lastKey
>
p
Handle
->
window
.
ekey
)
{
return
false
;
}
...
...
@@ -522,13 +544,15 @@ static int vnodeBinarySearchKey(char* pValue, int num, TSKEY key, int order) {
int
numOfPoints
;
TSKEY
*
keyList
;
assert
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
if
(
num
<=
0
)
return
-
1
;
keyList
=
(
TSKEY
*
)
pValue
;
firstPos
=
0
;
lastPos
=
num
-
1
;
if
(
order
==
0
)
{
if
(
order
==
TSDB_ORDER_DESC
)
{
// find the first position which is smaller than the key
while
(
1
)
{
if
(
key
>=
keyList
[
lastPos
])
return
lastPos
;
...
...
@@ -596,8 +620,8 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
pQueryHandle
->
realNumOfRows
=
cur
->
pos
+
1
;
pCheckInfo
->
lastKey
=
blockInfo
.
window
.
ekey
-
1
;
}
else
{
endPos
=
vnodeBinarySearchKey
(
pCols
->
cols
[
0
].
pData
,
pCols
->
numOfPoints
,
pQueryHandle
->
window
.
ekey
,
pQueryHandle
->
order
);
int32_t
order
=
(
pQueryHandle
->
order
==
TSDB_ORDER_ASC
)
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
endPos
=
vnodeBinarySearchKey
(
pCols
->
cols
[
0
].
pData
,
pCols
->
numOfPoints
,
pQueryHandle
->
window
.
ekey
,
order
);
if
(
QUERY_IS_ASC_QUERY
(
pQueryHandle
->
order
))
{
if
(
endPos
<
cur
->
pos
)
{
...
...
@@ -1042,7 +1066,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, TSKEY maxKey, int max
int32_t
numOfCols
=
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
*
skey
=
INT64_MIN
;
while
(
tSkipListIterNext
(
pIter
))
{
do
/* (1) */
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
if
(
node
==
NULL
)
break
;
...
...
@@ -1063,8 +1087,11 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, TSKEY maxKey, int max
}
numOfRows
++
;
if
(
numOfRows
>=
maxRowsToRead
)
break
;
};
if
(
numOfRows
>=
maxRowsToRead
)
{
break
;
}
}
while
(
tSkipListIterNext
(
pIter
));
return
numOfRows
;
}
...
...
@@ -1107,10 +1134,8 @@ SDataBlockInfo tsdbRetrieveDataBlockInfo(tsdb_query_handle_t* pQueryHandle) {
if
(
pTable
->
mem
!=
NULL
)
{
// create mem table iterator if it is not created yet
if
(
pCheckInfo
->
iter
==
NULL
)
{
pCheckInfo
->
iter
=
tSkipListCreateIter
(
pTable
->
mem
->
pData
);
}
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
->
iter
,
INT64_MAX
,
2
,
&
skey
,
&
ekey
,
pHandle
);
assert
(
pCheckInfo
->
iter
!=
NULL
);
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
->
iter
,
pHandle
->
window
.
ekey
,
2
,
&
skey
,
&
ekey
,
pHandle
);
// update the last key value
pCheckInfo
->
lastKey
=
ekey
+
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录