Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3398006
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c3398006
编写于
7月 08, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): handle delete duration generating data block.
上级
5c2e9854
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
25 deletion
+90
-25
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+90
-25
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
c3398006
...
...
@@ -137,7 +137,7 @@ static int32_t doMergeRowsInBuf(SIterInfo* pIter, int64_t ts, SArray* pDelList,
static
int32_t
doAppendOneRow
(
SSDataBlock
*
pBlock
,
STsdbReader
*
pReader
,
STSRow
*
pTSRow
);
static
void
setComposedBlockFlag
(
STsdbReader
*
pReader
,
bool
composed
);
static
void
updateSchema
(
TSDBROW
*
pRow
,
uint64_t
uid
,
STsdbReader
*
pReader
);
static
bool
hasBeenDropped
(
const
SArray
*
pDelList
,
int32_t
*
index
,
TSDBKEY
*
pKey
);
static
bool
hasBeenDropped
(
const
SArray
*
pDelList
,
int32_t
*
index
,
TSDBKEY
*
pKey
,
int32_t
order
);
static
void
doMergeMultiRows
(
TSDBROW
*
pRow
,
uint64_t
uid
,
SIterInfo
*
pIter
,
SArray
*
pDelList
,
STSRow
**
pTSRow
,
STsdbReader
*
pReader
);
...
...
@@ -1416,7 +1416,7 @@ static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVer
(
pBlock
->
minVersion
<=
pVerRange
->
maxVer
);
}
static
bool
overlapWithDelSkyline
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
SBlock
*
pBlock
)
{
static
bool
overlapWithDelSkyline
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
SBlock
*
pBlock
,
int32_t
order
)
{
if
(
pBlockScanInfo
->
delSkyline
==
NULL
)
{
return
false
;
}
...
...
@@ -1429,9 +1429,11 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBl
return
false
;
}
int32_t
step
=
ASCENDING_TRAVERSE
(
order
)
?
1
:-
1
;
// version is not overlap
size_t
num
=
taosArrayGetSize
(
pBlockScanInfo
->
delSkyline
);
for
(
int32_t
i
=
pBlockScanInfo
->
fileDelIndex
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
pBlockScanInfo
->
fileDelIndex
;
i
<
num
;
i
+=
step
)
{
TSDBKEY
*
p
=
taosArrayGet
(
pBlockScanInfo
->
delSkyline
,
i
);
if
(
p
->
ts
>=
pBlock
->
minKey
.
ts
&&
p
->
ts
<=
pBlock
->
maxKey
.
ts
)
{
if
(
p
->
version
>=
pBlock
->
minVersion
)
{
...
...
@@ -1464,7 +1466,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBloc
// has duplicated ts of different version in this block
bool
hasDup
=
(
pBlock
->
nSubBlock
==
1
)
?
pBlock
->
hasDup
:
true
;
bool
overlapWithDel
=
overlapWithDelSkyline
(
pScanInfo
,
pBlock
);
bool
overlapWithDel
=
overlapWithDelSkyline
(
pScanInfo
,
pBlock
,
pReader
->
order
);
return
(
overlapWithNeighbor
||
hasDup
||
dataBlockPartiallyRequired
(
&
pReader
->
window
,
&
pReader
->
verRange
,
pBlock
)
||
keyOverlapFileBlock
(
key
,
pBlock
,
&
pReader
->
verRange
)
||
(
pBlock
->
nRow
>
pReader
->
capacity
)
||
overlapWithDel
);
...
...
@@ -1691,7 +1693,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
}
TSDBKEY
k
=
{.
ts
=
ts
,
.
version
=
ver
};
if
(
hasBeenDropped
(
pBlockScanInfo
->
delSkyline
,
&
pBlockScanInfo
->
fileDelIndex
,
&
k
))
{
if
(
hasBeenDropped
(
pBlockScanInfo
->
delSkyline
,
&
pBlockScanInfo
->
fileDelIndex
,
&
k
,
pReader
->
order
))
{
return
false
;
}
...
...
@@ -2220,41 +2222,104 @@ static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond
// taosArrayPush(pTsdbReadHandle->pTableCheckInfo, &info);
// }
bool
hasBeenDropped
(
const
SArray
*
pDelList
,
int32_t
*
index
,
TSDBKEY
*
pKey
)
{
bool
hasBeenDropped
(
const
SArray
*
pDelList
,
int32_t
*
index
,
TSDBKEY
*
pKey
,
int32_t
order
)
{
ASSERT
(
pKey
!=
NULL
);
if
(
pDelList
==
NULL
)
{
return
false
;
}
size_t
num
=
taosArrayGetSize
(
pDelList
);
bool
asc
=
ASCENDING_TRAVERSE
(
order
);
int32_t
step
=
asc
?
1
:-
1
;
if
(
*
index
>=
taosArrayGetSize
(
pDelList
)
-
1
)
{
TSDBKEY
*
last
=
taosArrayGetLast
(
pDelList
);
if
(
pKey
->
ts
>
last
->
ts
)
{
return
false
;
}
else
if
(
pKey
->
ts
==
last
->
ts
)
{
size_t
size
=
taosArrayGetSize
(
pDelList
);
TSDBKEY
*
prev
=
taosArrayGet
(
pDelList
,
size
-
2
);
if
(
prev
->
version
>=
pKey
->
version
)
{
return
true
;
}
else
{
if
(
asc
)
{
if
(
*
index
>=
num
-
1
)
{
TSDBKEY
*
last
=
taosArrayGetLast
(
pDelList
);
ASSERT
(
pKey
->
ts
>=
last
->
ts
);
if
(
pKey
->
ts
>
last
->
ts
)
{
return
false
;
}
else
if
(
pKey
->
ts
==
last
->
ts
)
{
TSDBKEY
*
prev
=
taosArrayGet
(
pDelList
,
num
-
2
);
return
(
prev
->
version
>=
pKey
->
version
);
}
}
else
{
ASSERT
(
0
);
TSDBKEY
*
pCurrent
=
taosArrayGet
(
pDelList
,
*
index
);
TSDBKEY
*
pNext
=
taosArrayGet
(
pDelList
,
(
*
index
)
+
1
);
if
(
pKey
->
ts
<
pCurrent
->
ts
)
{
return
false
;
}
if
(
pCurrent
->
ts
<=
pKey
->
ts
&&
pNext
->
ts
>=
pKey
->
ts
&&
pCurrent
->
version
>=
pKey
->
version
)
{
return
true
;
}
while
(
pNext
->
ts
<=
pKey
->
ts
&&
(
*
index
)
<
num
-
1
)
{
(
*
index
)
+=
1
;
if
((
*
index
)
<
num
-
1
)
{
pCurrent
=
taosArrayGet
(
pDelList
,
*
index
);
pNext
=
taosArrayGet
(
pDelList
,
(
*
index
)
+
1
);
// it is not a consecutive deletion range, ignore it
if
(
pCurrent
->
version
==
0
&&
pNext
->
version
>
0
)
{
continue
;
}
if
(
pCurrent
->
ts
<=
pKey
->
ts
&&
pNext
->
ts
>=
pKey
->
ts
&&
pCurrent
->
version
>=
pKey
->
version
)
{
return
true
;
}
}
}
return
false
;
}
}
else
{
TSDBKEY
*
pCurrent
=
taosArrayGet
(
pDelList
,
*
index
);
TSDBKEY
*
pNext
=
taosArrayGet
(
pDelList
,
(
*
index
)
+
1
);
if
(
*
index
<=
0
)
{
TSDBKEY
*
pFirst
=
taosArrayGet
(
pDelList
,
0
);
if
(
pCurrent
->
ts
<=
pKey
->
ts
&&
pNext
->
ts
>=
pKey
->
ts
&&
pCurrent
->
version
>=
pKey
->
version
)
{
return
true
;
if
(
pKey
->
ts
<
pFirst
->
ts
)
{
return
false
;
}
else
if
(
pKey
->
ts
==
pFirst
->
ts
)
{
return
pFirst
->
version
>=
pKey
->
version
;
}
else
{
ASSERT
(
0
);
}
}
else
{
while
(
pNext
->
ts
<
pKey
->
ts
&&
(
*
index
)
<
taosArrayGetSize
(
pDelList
)
-
1
)
{
(
*
index
)
+=
1
;
TSDBKEY
*
pCurrent
=
taosArrayGet
(
pDelList
,
*
index
);
TSDBKEY
*
pPrev
=
taosArrayGet
(
pDelList
,
(
*
index
)
-
1
);
if
(
pKey
->
ts
>
pCurrent
->
ts
)
{
return
false
;
}
if
(
pPrev
->
ts
<=
pKey
->
ts
&&
pCurrent
->
ts
>=
pKey
->
ts
&&
pPrev
->
version
>=
pKey
->
version
)
{
return
true
;
}
while
(
pPrev
->
ts
>=
pKey
->
ts
&&
(
*
index
)
>
1
)
{
(
*
index
)
+=
step
;
if
((
*
index
)
>=
1
)
{
pCurrent
=
taosArrayGet
(
pDelList
,
*
index
);
pPrev
=
taosArrayGet
(
pDelList
,
(
*
index
)
-
1
);
// it is not a consecutive deletion range, ignore it
if
(
pCurrent
->
version
>
0
&&
pPrev
->
version
==
0
)
{
continue
;
}
if
(
pPrev
->
ts
<=
pKey
->
ts
&&
pCurrent
->
ts
>=
pKey
->
ts
&&
pPrev
->
version
>=
pKey
->
version
)
{
return
true
;
}
}
}
return
false
;
}
}
return
false
;
}
TSDBROW
*
getValidRow
(
SIterInfo
*
pIter
,
const
SArray
*
pDelList
,
STsdbReader
*
pReader
)
{
...
...
@@ -2271,7 +2336,7 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea
// it is a valid data version
if
((
key
.
version
<=
pReader
->
verRange
.
maxVer
&&
key
.
version
>=
pReader
->
verRange
.
minVer
)
&&
(
!
hasBeenDropped
(
pDelList
,
&
pIter
->
index
,
&
key
)))
{
(
!
hasBeenDropped
(
pDelList
,
&
pIter
->
index
,
&
key
,
pReader
->
order
)))
{
return
pRow
;
}
...
...
@@ -2290,7 +2355,7 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea
}
if
(
key
.
version
<=
pReader
->
verRange
.
maxVer
&&
key
.
version
>=
pReader
->
verRange
.
minVer
&&
(
!
hasBeenDropped
(
pDelList
,
&
pIter
->
index
,
&
key
)))
{
(
!
hasBeenDropped
(
pDelList
,
&
pIter
->
index
,
&
key
,
pReader
->
order
)))
{
return
pRow
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录