Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
834c9eda
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
834c9eda
编写于
9月 11, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: revert the code change
上级
b8b91eb1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
26 deletion
+35
-26
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+35
-26
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
834c9eda
...
@@ -758,43 +758,51 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
...
@@ -758,43 +758,51 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
s
=
pos
;
s
=
pos
;
// check
// check
assert
(
pos
>=
0
&&
pos
<
num
);
assert
(
pos
>=
0
&&
pos
<
num
);
assert
(
num
>
0
);
assert
(
num
>
0
);
if
(
order
==
TSDB_ORDER_ASC
)
{
if
(
order
==
TSDB_ORDER_ASC
)
{
// find the first position which is smaller than the key
// find the first position which is smaller than the key
e
=
num
-
1
;
e
=
num
-
1
;
if
(
key
<
keyList
[
pos
])
return
-
1
;
if
(
key
<
keyList
[
pos
])
return
-
1
;
while
(
1
)
{
while
(
1
)
{
// check can return
// check can return
if
(
key
>=
keyList
[
e
])
return
e
;
if
(
key
>=
keyList
[
e
])
if
(
key
<=
keyList
[
s
])
return
s
;
return
e
;
if
(
e
-
s
<=
1
)
return
s
;
if
(
key
<=
keyList
[
s
])
return
s
;
if
(
e
-
s
<=
1
)
return
s
;
// change start or end position
// change start or end position
int
mid
=
s
+
(
e
-
s
+
1
)
/
2
;
int
mid
=
s
+
(
e
-
s
+
1
)
/
2
;
if
(
keyList
[
mid
]
>
key
)
if
(
keyList
[
mid
]
>
key
)
e
=
mid
;
e
=
mid
;
else
if
(
keyList
[
mid
]
<
key
)
else
if
(
keyList
[
mid
]
<
key
)
s
=
mid
;
s
=
mid
;
else
else
return
mid
;
return
mid
;
}
}
}
else
{
// DESC
}
else
{
// DESC
// find the first position which is bigger than the key
// find the first position which is bigger than the key
e
=
0
;
e
=
0
;
if
(
key
>
keyList
[
pos
])
return
-
1
;
if
(
key
>
keyList
[
pos
])
return
-
1
;
while
(
1
)
{
while
(
1
)
{
// check can return
// check can return
if
(
key
<=
keyList
[
e
])
return
e
;
if
(
key
<=
keyList
[
e
])
if
(
key
>=
keyList
[
s
])
return
s
;
return
e
;
if
(
s
-
e
<=
1
)
return
s
;
if
(
key
>=
keyList
[
s
])
return
s
;
if
(
s
-
e
<=
1
)
return
s
;
// change start or end position
// change start or end position
int
mid
=
s
-
(
s
-
e
+
1
)
/
2
;
int
mid
=
s
-
(
s
-
e
+
1
)
/
2
;
if
(
keyList
[
mid
]
<
key
)
if
(
keyList
[
mid
]
<
key
)
e
=
mid
;
e
=
mid
;
else
if
(
keyList
[
mid
]
>
key
)
else
if
(
keyList
[
mid
]
>
key
)
s
=
mid
;
s
=
mid
;
else
else
return
mid
;
return
mid
;
...
@@ -805,7 +813,7 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
...
@@ -805,7 +813,7 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
int32_t
getEndPosInDataBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
SDataBlk
*
pBlock
,
int32_t
pos
)
{
int32_t
getEndPosInDataBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
SDataBlk
*
pBlock
,
int32_t
pos
)
{
// NOTE: reverse the order to find the end position in data block
// NOTE: reverse the order to find the end position in data block
int32_t
endPos
=
-
1
;
int32_t
endPos
=
-
1
;
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
if
(
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
if
(
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
endPos
=
pBlock
->
nRow
-
1
;
endPos
=
pBlock
->
nRow
-
1
;
...
@@ -841,8 +849,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -841,8 +849,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
}
else
if
(
!
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
}
else
if
(
!
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
pDumpInfo
->
rowIndex
=
pBlock
->
nRow
-
1
;
pDumpInfo
->
rowIndex
=
pBlock
->
nRow
-
1
;
}
else
{
}
else
{
int32_t
pos
=
asc
?
pBlock
->
nRow
-
1
:
0
;
int32_t
pos
=
asc
?
pBlock
->
nRow
-
1
:
0
;
int32_t
order
=
(
pReader
->
order
==
TSDB_ORDER_ASC
)
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
int32_t
order
=
(
pReader
->
order
==
TSDB_ORDER_ASC
)
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
pDumpInfo
->
rowIndex
=
doBinarySearchKey
(
pBlockData
->
aTSKEY
,
pBlock
->
nRow
,
pos
,
pReader
->
window
.
skey
,
order
);
pDumpInfo
->
rowIndex
=
doBinarySearchKey
(
pBlockData
->
aTSKEY
,
pBlock
->
nRow
,
pos
,
pReader
->
window
.
skey
,
order
);
}
}
...
@@ -855,13 +863,13 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -855,13 +863,13 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
endIndex
+=
step
;
endIndex
+=
step
;
int32_t
remain
=
asc
?
(
endIndex
-
pDumpInfo
->
rowIndex
)
:
(
pDumpInfo
->
rowIndex
-
endIndex
);
int32_t
remain
=
asc
?
(
endIndex
-
pDumpInfo
->
rowIndex
)
:
(
pDumpInfo
->
rowIndex
-
endIndex
);
if
(
remain
>
pReader
->
capacity
)
{
// output buffer check
if
(
remain
>
pReader
->
capacity
)
{
// output buffer check
remain
=
pReader
->
capacity
;
remain
=
pReader
->
capacity
;
}
}
int32_t
rowIndex
=
0
;
int32_t
rowIndex
=
0
;
int32_t
i
=
0
;
int32_t
i
=
0
;
SColumnInfoData
*
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
if
(
pColData
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
pColData
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
asc
)
{
if
(
asc
)
{
...
@@ -930,7 +938,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -930,7 +938,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
int64_t
ts
=
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
];
int64_t
ts
=
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
];
setBlockAllDumped
(
pDumpInfo
,
ts
,
pReader
->
order
);
setBlockAllDumped
(
pDumpInfo
,
ts
,
pReader
->
order
);
}
else
{
}
else
{
int64_t
k
=
asc
?
pBlock
->
maxKey
.
ts
:
pBlock
->
minKey
.
ts
;
int64_t
k
=
asc
?
pBlock
->
maxKey
.
ts
:
pBlock
->
minKey
.
ts
;
setBlockAllDumped
(
pDumpInfo
,
k
,
pReader
->
order
);
setBlockAllDumped
(
pDumpInfo
,
k
,
pReader
->
order
);
}
}
...
@@ -940,8 +948,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -940,8 +948,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
int32_t
unDumpedRows
=
asc
?
pBlock
->
nRow
-
pDumpInfo
->
rowIndex
:
pDumpInfo
->
rowIndex
+
1
;
int32_t
unDumpedRows
=
asc
?
pBlock
->
nRow
-
pDumpInfo
->
rowIndex
:
pDumpInfo
->
rowIndex
+
1
;
tsdbDebug
(
"%p copy file block to sdatablock, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
tsdbDebug
(
"%p copy file block to sdatablock, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
", rows:%d, remain:%d, minVer:%"
PRId64
", maxVer:%"
PRId64
", elapsed time:%.2f ms, %s"
,
", rows:%d, remain:%d, minVer:%"
PRId64
", maxVer:%"
PRId64
", elapsed time:%.2f ms, %s"
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlock
->
minKey
.
ts
,
pBlock
->
maxKey
.
ts
,
remain
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlock
->
minKey
.
ts
,
pBlock
->
maxKey
.
ts
,
remain
,
unDumpedRows
,
unDumpedRows
,
pBlock
->
minVer
,
pBlock
->
maxVer
,
elapsedTime
,
pReader
->
idStr
);
pBlock
->
minVer
,
pBlock
->
maxVer
,
elapsedTime
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2234,7 +2242,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
...
@@ -2234,7 +2242,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
if
(
pBlockInfo
!=
NULL
)
{
if
(
pBlockInfo
!=
NULL
)
{
pBlockScanInfo
=
taosHashGet
(
pReader
->
status
.
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
pBlockScanInfo
=
taosHashGet
(
pReader
->
status
.
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pBlockScanInfo
,
pReader
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pBlockScanInfo
,
pReader
);
// it is a clean block, load it directly
// it is a clean block, load it directly
if
(
isCleanFileDataBlock
(
pReader
,
pBlockInfo
,
pBlock
,
pBlockScanInfo
,
keyInBuf
,
pLastBlockReader
))
{
if
(
isCleanFileDataBlock
(
pReader
,
pBlockInfo
,
pBlock
,
pBlockScanInfo
,
keyInBuf
,
pLastBlockReader
))
{
...
@@ -2249,6 +2257,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
...
@@ -2249,6 +2257,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
while
(
1
)
{
while
(
1
)
{
// todo check the validate of row in file block
// todo check the validate of row in file block
bool
hasBlockData
=
false
;
bool
hasBlockData
=
false
;
...
@@ -2290,7 +2299,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
...
@@ -2290,7 +2299,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
}
}
}
}
_end:
_end:
pResBlock
->
info
.
uid
=
pBlockScanInfo
->
uid
;
pResBlock
->
info
.
uid
=
pBlockScanInfo
->
uid
;
blockDataUpdateTsWindow
(
pResBlock
,
0
);
blockDataUpdateTsWindow
(
pResBlock
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录