Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
73170760
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看板
提交
73170760
编写于
7月 20, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in descending traverse over in-men data
上级
3cf5b769
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
32 deletion
+47
-32
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+47
-32
未找到文件。
src/tsdb/src/tsdbRead.c
浏览文件 @
73170760
...
...
@@ -21,7 +21,7 @@
#include "tcompare.h"
#include "exception.h"
#include "../../
../query/inc/qa
st.h" // todo move to common module
#include "../../
query/inc/qA
st.h" // todo move to common module
#include "tlosertree.h"
#include "tsdb.h"
#include "tsdbMain.h"
...
...
@@ -331,7 +331,8 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d check data in mem from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
key
,
order
,
pHandle
->
qinfo
);
}
else
{
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d no data in mem"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
);
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d no data in mem, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
pHandle
->
qinfo
);
}
if
(
!
imemEmpty
)
{
...
...
@@ -343,7 +344,8 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d check data in imem from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
key
,
order
,
pHandle
->
qinfo
);
}
else
{
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d no data in imem"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
);
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d no data in imem, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
pHandle
->
qinfo
);
}
return
true
;
...
...
@@ -354,7 +356,7 @@ static void destroyTableMemIterator(STableCheckInfo* pCheckInfo) {
tSkipListDestroyIter
(
pCheckInfo
->
iiter
);
}
SDataRow
getSDataRowInTableMem
(
STableCheckInfo
*
pCheckInfo
)
{
SDataRow
getSDataRowInTableMem
(
STableCheckInfo
*
pCheckInfo
,
int32_t
order
)
{
SDataRow
rmem
=
NULL
,
rimem
=
NULL
;
if
(
pCheckInfo
->
iter
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
...
...
@@ -371,20 +373,35 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
}
if
(
rmem
!=
NULL
&&
rimem
!=
NULL
)
{
if
(
dataRowKey
(
rmem
)
<
dataRowKey
(
rimem
))
{
pCheckInfo
->
chosen
=
0
;
return
rmem
;
}
else
if
(
dataRowKey
(
rmem
)
==
dataRowKey
(
rimem
))
{
// data ts are duplicated, ignore the data in mem
TSKEY
r1
=
dataRowKey
(
rmem
);
TSKEY
r2
=
dataRowKey
(
rimem
);
if
(
r1
==
r2
)
{
// data ts are duplicated, ignore the data in mem
tSkipListIterNext
(
pCheckInfo
->
iter
);
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
else
{
pCheckInfo
->
chosen
=
1
;
return
rimem
;
if
(
ASCENDING_TRAVERSE
(
order
))
{
if
(
r1
<
r2
)
{
pCheckInfo
->
chosen
=
0
;
return
rmem
;
}
else
{
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
}
else
{
if
(
r1
<
r2
)
{
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
else
{
pCheckInfo
->
chosen
=
0
;
return
rmem
;
}
}
}
}
// at least one (rmem or rimem) is absent here
if
(
rmem
!=
NULL
)
{
pCheckInfo
->
chosen
=
0
;
return
rmem
;
...
...
@@ -398,7 +415,7 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
return
NULL
;
}
static
bool
moveToNextRow
(
STableCheckInfo
*
pCheckInfo
)
{
static
bool
moveToNextRow
InMem
(
STableCheckInfo
*
pCheckInfo
)
{
bool
hasNext
=
false
;
if
(
pCheckInfo
->
chosen
==
0
)
{
if
(
pCheckInfo
->
iter
!=
NULL
)
{
...
...
@@ -412,19 +429,17 @@ static bool moveToNextRow(STableCheckInfo* pCheckInfo) {
if
(
pCheckInfo
->
iiter
!=
NULL
)
{
return
tSkipListIterGet
(
pCheckInfo
->
iiter
)
!=
NULL
;
}
}
else
{
if
(
pCheckInfo
->
chosen
==
1
)
{
if
(
pCheckInfo
->
iiter
!=
NULL
)
{
hasNext
=
tSkipListIterNext
(
pCheckInfo
->
iiter
);
}
}
else
{
//pCheckInfo->chosen == 1
if
(
pCheckInfo
->
iiter
!=
NULL
)
{
hasNext
=
tSkipListIterNext
(
pCheckInfo
->
iiter
);
}
if
(
hasNext
)
{
return
hasNext
;
}
if
(
hasNext
)
{
return
hasNext
;
}
if
(
pCheckInfo
->
iter
!=
NULL
)
{
return
tSkipListIterGet
(
pCheckInfo
->
iter
)
!=
NULL
;
}
if
(
pCheckInfo
->
iter
!=
NULL
)
{
return
tSkipListIterGet
(
pCheckInfo
->
iter
)
!=
NULL
;
}
}
...
...
@@ -445,7 +460,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
initTableMemIterator
(
pHandle
,
pCheckInfo
);
}
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pHandle
->
order
);
if
(
row
==
NULL
)
{
return
false
;
}
...
...
@@ -650,7 +665,7 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
SDataBlockInfo
binfo
=
GET_FILE_DATA_BLOCK_INFO
(
pCheckInfo
,
pBlock
);
/*bool hasData = */
initTableMemIterator
(
pQueryHandle
,
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
TSKEY
key
=
(
row
!=
NULL
)
?
dataRowKey
(
row
)
:
TSKEY_INITIAL_VAL
;
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
binfo
.
rows
-
1
);
...
...
@@ -1033,7 +1048,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
}
else
if
(
pCheckInfo
->
iter
!=
NULL
||
pCheckInfo
->
iiter
!=
NULL
)
{
SSkipListNode
*
node
=
NULL
;
do
{
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
if
(
row
==
NULL
)
{
break
;
}
...
...
@@ -1061,9 +1076,9 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
cur
->
lastKey
=
key
+
step
;
cur
->
mixBlock
=
true
;
moveToNextRow
(
pCheckInfo
);
moveToNextRow
InMem
(
pCheckInfo
);
}
else
if
(
key
==
tsArray
[
pos
])
{
// data in buffer has the same timestamp of data in file block, ignore it
moveToNextRow
(
pCheckInfo
);
moveToNextRow
InMem
(
pCheckInfo
);
}
else
if
((
key
>
tsArray
[
pos
]
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
(
key
<
tsArray
[
pos
]
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
...
...
@@ -1072,7 +1087,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
int32_t
end
=
doBinarySearchKey
(
pCols
->
cols
[
0
].
pData
,
pCols
->
numOfRows
,
key
,
order
);
if
(
tsArray
[
end
]
==
key
)
{
// the value of key in cache equals to the end timestamp value, ignore it
moveToNextRow
(
pCheckInfo
);
moveToNextRow
InMem
(
pCheckInfo
);
}
int32_t
start
=
-
1
;
...
...
@@ -1754,7 +1769,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
STable
*
pTable
=
pCheckInfo
->
pTableObj
;
do
{
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
,
pQueryHandle
->
order
);
if
(
row
==
NULL
)
{
break
;
}
...
...
@@ -1775,11 +1790,11 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
copyOneRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
pMeta
,
numOfCols
,
pTable
);
if
(
++
numOfRows
>=
maxRowsToRead
)
{
moveToNextRow
(
pCheckInfo
);
moveToNextRow
InMem
(
pCheckInfo
);
break
;
}
}
while
(
moveToNextRow
(
pCheckInfo
));
}
while
(
moveToNextRow
InMem
(
pCheckInfo
));
assert
(
numOfRows
<=
maxRowsToRead
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录