Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1c89972f
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看板
提交
1c89972f
编写于
9月 03, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): add multiple blockdata structure.
上级
957550c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
21 deletion
+42
-21
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+42
-21
未找到文件。
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
1c89972f
...
...
@@ -24,7 +24,8 @@ typedef struct SLDataIter {
int8_t
backward
;
SArray
*
aSstBlk
;
int32_t
iSstBlk
;
SBlockData
bData
;
SBlockData
bData
[
2
];
int32_t
loadIndex
;
int32_t
iRow
;
SRowInfo
rInfo
;
uint64_t
uid
;
...
...
@@ -32,6 +33,15 @@ typedef struct SLDataIter {
SVersionRange
verRange
;
}
SLDataIter
;
static
SBlockData
*
getCurrentBlock
(
SLDataIter
*
pIter
)
{
return
&
pIter
->
bData
[
pIter
->
loadIndex
];
}
static
SBlockData
*
getNextBlock
(
SLDataIter
*
pIter
)
{
pIter
->
loadIndex
^=
1
;
return
getCurrentBlock
(
pIter
);
}
int32_t
tLDataIterOpen
(
struct
SLDataIter
**
pIter
,
SDataFReader
*
pReader
,
int32_t
iSst
,
int8_t
backward
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
)
{
int32_t
code
=
0
;
...
...
@@ -53,7 +63,12 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
goto
_exit
;
}
code
=
tBlockDataCreate
(
&
(
*
pIter
)
->
bData
);
code
=
tBlockDataCreate
(
&
(
*
pIter
)
->
bData
[
0
]);
if
(
code
)
{
goto
_exit
;
}
code
=
tBlockDataCreate
(
&
(
*
pIter
)
->
bData
[
1
]);
if
(
code
)
{
goto
_exit
;
}
...
...
@@ -95,7 +110,8 @@ _exit:
}
void
tLDataIterClose
(
SLDataIter
*
pIter
)
{
tBlockDataDestroy
(
&
pIter
->
bData
,
1
);
tBlockDataDestroy
(
&
pIter
->
bData
[
0
],
1
);
tBlockDataDestroy
(
&
pIter
->
bData
[
1
],
1
);
taosArrayDestroy
(
pIter
->
aSstBlk
);
taosMemoryFree
(
pIter
);
}
...
...
@@ -136,24 +152,26 @@ static void findNextValidRow(SLDataIter *pIter) {
bool
hasVal
=
false
;
int32_t
i
=
pIter
->
iRow
;
for
(;
i
<
pIter
->
bData
.
nRow
&&
i
>=
0
;
i
+=
step
)
{
if
(
pIter
->
bData
.
aUid
!=
NULL
)
{
SBlockData
*
pBlockData
=
getCurrentBlock
(
pIter
);
for
(;
i
<
pBlockData
->
nRow
&&
i
>=
0
;
i
+=
step
)
{
if
(
pBlockData
->
aUid
!=
NULL
)
{
if
(
!
pIter
->
backward
)
{
if
(
p
Iter
->
bData
.
aUid
[
i
]
<
pIter
->
uid
)
{
if
(
p
BlockData
->
aUid
[
i
]
<
pIter
->
uid
)
{
continue
;
}
else
if
(
p
Iter
->
bData
.
aUid
[
i
]
>
pIter
->
uid
)
{
}
else
if
(
p
BlockData
->
aUid
[
i
]
>
pIter
->
uid
)
{
break
;
}
}
else
{
if
(
p
Iter
->
bData
.
aUid
[
i
]
>
pIter
->
uid
)
{
if
(
p
BlockData
->
aUid
[
i
]
>
pIter
->
uid
)
{
continue
;
}
else
if
(
p
Iter
->
bData
.
aUid
[
i
]
<
pIter
->
uid
)
{
}
else
if
(
p
BlockData
->
aUid
[
i
]
<
pIter
->
uid
)
{
break
;
}
}
}
int64_t
ts
=
p
Iter
->
bData
.
aTSKEY
[
i
];
int64_t
ts
=
p
BlockData
->
aTSKEY
[
i
];
if
(
!
pIter
->
backward
)
{
// asc
if
(
ts
>
pIter
->
timeWindow
.
ekey
)
{
// no more data
break
;
...
...
@@ -168,7 +186,7 @@ static void findNextValidRow(SLDataIter *pIter) {
}
}
int64_t
ver
=
p
Iter
->
bData
.
aVersion
[
i
];
int64_t
ver
=
p
BlockData
->
aVersion
[
i
];
if
(
ver
<
pIter
->
verRange
.
minVer
)
{
continue
;
}
...
...
@@ -203,14 +221,16 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
}
int32_t
iBlockL
=
pIter
->
iSstBlk
;
SBlockData
*
pBlockData
=
getCurrentBlock
(
pIter
);
if
(
pIter
->
bData
.
nRow
==
0
&&
pIter
->
pSstBlk
!=
NULL
)
{
// current block not loaded yet
code
=
tsdbReadSstBlockEx
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSstBlk
,
&
pIter
->
bData
);
if
(
pBlockData
->
nRow
==
0
&&
pIter
->
pSstBlk
!=
NULL
)
{
// current block not loaded yet
pBlockData
=
getNextBlock
(
pIter
);
code
=
tsdbReadSstBlockEx
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSstBlk
,
pBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_exit
;
}
pIter
->
iRow
=
(
pIter
->
backward
)
?
p
Iter
->
bData
.
nRow
:
-
1
;
pIter
->
iRow
=
(
pIter
->
backward
)
?
p
BlockData
->
nRow
:
-
1
;
}
pIter
->
iRow
+=
step
;
...
...
@@ -218,7 +238,7 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
while
(
1
)
{
findNextValidRow
(
pIter
);
if
(
pIter
->
iRow
>=
p
Iter
->
bData
.
nRow
||
pIter
->
iRow
<
0
)
{
if
(
pIter
->
iRow
>=
p
BlockData
->
nRow
||
pIter
->
iRow
<
0
)
{
tLDataIterNextBlock
(
pIter
);
if
(
pIter
->
pSstBlk
==
NULL
)
{
// no more data
goto
_exit
;
...
...
@@ -228,17 +248,18 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
}
if
(
iBlockL
!=
pIter
->
iSstBlk
)
{
code
=
tsdbReadSstBlockEx
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSstBlk
,
&
pIter
->
bData
);
pBlockData
=
getNextBlock
(
pIter
);
code
=
tsdbReadSstBlockEx
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSstBlk
,
pBlockData
);
if
(
code
)
{
goto
_exit
;
}
pIter
->
iRow
=
pIter
->
backward
?
(
p
Iter
->
bData
.
nRow
-
1
)
:
0
;
pIter
->
iRow
=
pIter
->
backward
?
(
p
BlockData
->
nRow
-
1
)
:
0
;
}
}
pIter
->
rInfo
.
suid
=
p
Iter
->
bData
.
suid
;
pIter
->
rInfo
.
uid
=
p
Iter
->
bData
.
uid
;
pIter
->
rInfo
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
b
Data
,
pIter
->
iRow
);
pIter
->
rInfo
.
suid
=
p
BlockData
->
suid
;
pIter
->
rInfo
.
uid
=
p
BlockData
->
uid
;
pIter
->
rInfo
.
row
=
tsdbRowFromBlockData
(
pBlock
Data
,
pIter
->
iRow
);
_exit:
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -322,7 +343,7 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
// compare with min in RB Tree
pIter
=
(
SLDataIter
*
)
tRBTreeMin
(
&
pMTree
->
rbt
);
if
(
pMTree
->
pIter
&&
pIter
)
{
int32_t
c
=
pMTree
->
rbt
.
cmprFn
(
pMTree
->
pIter
->
node
.
payload
,
&
pIter
->
node
.
payload
);
int32_t
c
=
pMTree
->
rbt
.
cmprFn
(
pMTree
->
pIter
->
node
.
payload
,
pIter
->
node
.
payload
);
if
(
c
>
0
)
{
tRBTreePut
(
&
pMTree
->
rbt
,
(
SRBTreeNode
*
)
pMTree
->
pIter
);
pMTree
->
pIter
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录