Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f6e3ad27
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6e3ad27
编写于
6月 21, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(tsdb): fix memory leak.
上级
a92d16a5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
114 addition
and
93 deletion
+114
-93
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-1
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+56
-41
source/dnode/vnode/src/tsdb/tsdbRead2.c
source/dnode/vnode/src/tsdb/tsdbRead2.c
+56
-51
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
f6e3ad27
...
...
@@ -800,7 +800,7 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, int8_t backward, STsdb* pTsdb, uint6
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
,
void
*
pCurrentFileSet
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeIgnoreEarlierTs
(
SMergeTree
*
pMTree
);
void
tMergeTreeClose
(
SMergeTree
*
pMTree
);
...
...
@@ -809,6 +809,7 @@ SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList,
void
resetLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
);
void
getLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
,
int64_t
*
blocks
,
double
*
el
);
void
*
destroyLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
);
void
destroySttBlockReader
(
SLDataIter
*
pLDataIter
,
int32_t
numOfIter
);
// tsdbCache ==============================================================================================
typedef
struct
SCacheRowsReader
{
...
...
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
f6e3ad27
...
...
@@ -17,6 +17,8 @@
#include "tsdbFSet2.h"
#include "tsdbSttFileRW.h"
static
void
tLDataIterClose2
(
SLDataIter
*
pIter
);
// SLDataIter =================================================
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
int32_t
numOfSttTrigger
)
{
...
...
@@ -93,6 +95,12 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
return
NULL
;
}
void
destroySttBlockReader
(
SLDataIter
*
pLDataIter
,
int32_t
numOfIter
)
{
for
(
int32_t
i
=
0
;
i
<
numOfIter
;
++
i
)
{
tLDataIterClose2
(
&
pLDataIter
[
i
]);
}
}
static
SBlockData
*
loadLastBlock
(
SLDataIter
*
pIter
,
const
char
*
idStr
)
{
int32_t
code
=
0
;
...
...
@@ -357,6 +365,7 @@ int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pReader, int32
void
tLDataIterClose2
(
SLDataIter
*
pIter
)
{
tsdbSttFileReaderClose
(
&
pIter
->
pReader
);
pIter
->
pReader
=
NULL
;
}
void
tLDataIterNextBlock
(
SLDataIter
*
pIter
,
const
char
*
idStr
)
{
...
...
@@ -623,64 +632,70 @@ _end:
return
code
;
}
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
int8_t
backward
,
STsdb
*
pTsdb
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
,
void
*
pCurrentFileSet
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
int8_t
backward
,
STsdb
*
pTsdb
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
,
void
*
pCurrentFileSet
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pMTree
->
backward
=
backward
;
pMTree
->
pIter
=
NULL
;
pMTree
->
idStr
=
idStr
;
pMTree
->
backward
=
backward
;
pMTree
->
pIter
=
NULL
;
pMTree
->
idStr
=
idStr
;
if
(
!
pMTree
->
backward
)
{
// asc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
}
else
{
// desc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterDescCmprFn
);
}
if
(
!
pMTree
->
backward
)
{
// asc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
}
else
{
// desc
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterDescCmprFn
);
}
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
pMTree
->
ignoreEarlierTs
=
false
;
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
pMTree
->
ignoreEarlierTs
=
false
;
// todo handle other level of stt files, here only deal with the first level stt
int32_t
size
=
((
STFileSet
*
)
pCurrentFileSet
)
->
lvlArr
[
0
].
size
;
if
(
size
==
0
)
{
goto
_end
;
}
// todo handle other level of stt files, here only deal with the first level stt
int32_t
size
=
((
STFileSet
*
)
pCurrentFileSet
)
->
lvlArr
[
0
].
size
;
if
(
size
==
0
)
{
goto
_end
;
}
SSttLvl
*
pSttLevel
=
((
STFileSet
*
)
pCurrentFileSet
)
->
lvlArr
[
0
].
data
[
0
];
ASSERT
(
pSttLevel
->
level
==
0
);
SSttLvl
*
pSttLevel
=
((
STFileSet
*
)
pCurrentFileSet
)
->
lvlArr
[
0
].
data
[
0
];
ASSERT
(
pSttLevel
->
level
==
0
);
for
(
int32_t
i
=
0
;
i
<
pSttLevel
->
fobjArr
[
0
].
size
;
++
i
)
{
// open all last file
memset
(
&
pLDataIter
[
i
],
0
,
sizeof
(
SLDataIter
));
for
(
int32_t
i
=
0
;
i
<
pSttLevel
->
fobjArr
[
0
].
size
;
++
i
)
{
// open all last file
SSttFileReader
*
pSttFileReader
=
pLDataIter
[
i
].
pReader
;
memset
(
&
pLDataIter
[
i
],
0
,
sizeof
(
SLDataIter
));
if
(
pSttFileReader
==
NULL
)
{
SSttFileReaderConfig
conf
=
{.
tsdb
=
pTsdb
,
.
szPage
=
pTsdb
->
pVnode
->
config
.
szPage
};
conf
.
file
[
0
]
=
*
pSttLevel
->
fobjArr
[
0
].
data
[
i
]
->
f
;
SSttFileReader
*
pReader
=
NULL
;
code
=
tsdbSttFileReaderOpen
(
pSttLevel
->
fobjArr
[
0
].
data
[
i
]
->
fname
,
&
conf
,
&
pReader
);
code
=
tLDataIterOpen2
(
&
pLDataIter
[
i
],
pReader
,
i
,
pMTree
->
backward
,
suid
,
uid
,
pTimeWindow
,
pVerRange
,
&
pMTree
->
pLoadInfo
[
i
],
pMTree
->
idStr
,
strictTimeRange
);
code
=
tsdbSttFileReaderOpen
(
pSttLevel
->
fobjArr
[
0
].
data
[
i
]
->
fname
,
&
conf
,
&
pSttFileReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
return
code
;
}
}
bool
hasVal
=
tLDataIterNextRow
(
&
pLDataIter
[
i
],
pMTree
->
idStr
);
if
(
hasVal
)
{
tMergeTreeAddIter
(
pMTree
,
&
pLDataIter
[
i
]);
}
else
{
if
(
!
pMTree
->
ignoreEarlierTs
)
{
pMTree
->
ignoreEarlierTs
=
pLDataIter
[
i
].
ignoreEarlierTs
;
}
code
=
tLDataIterOpen2
(
&
pLDataIter
[
i
],
pSttFileReader
,
i
,
pMTree
->
backward
,
suid
,
uid
,
pTimeWindow
,
pVerRange
,
&
pMTree
->
pLoadInfo
[
i
],
pMTree
->
idStr
,
strictTimeRange
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
bool
hasVal
=
tLDataIterNextRow
(
&
pLDataIter
[
i
],
pMTree
->
idStr
);
if
(
hasVal
)
{
tMergeTreeAddIter
(
pMTree
,
&
pLDataIter
[
i
]);
}
else
{
if
(
!
pMTree
->
ignoreEarlierTs
)
{
pMTree
->
ignoreEarlierTs
=
pLDataIter
[
i
].
ignoreEarlierTs
;
}
}
}
return
code
;
return
code
;
_end:
tMergeTreeClose
(
pMTree
);
return
code
;
_end:
tMergeTreeClose
(
pMTree
);
return
code
;
}
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
)
{
tRBTreePut
(
&
pMTree
->
rbt
,
(
SRBTreeNode
*
)
pIter
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead2.c
浏览文件 @
f6e3ad27
...
...
@@ -910,20 +910,13 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead
ASSERT
(
pBrinBlk
->
minTbid
.
suid
<=
pReader
->
suid
&&
pBrinBlk
->
maxTbid
.
suid
>=
pReader
->
suid
);
if
(
pBrinBlk
->
m
in
Tbid
.
uid
<
pList
->
tableUidList
[
j
])
{
if
(
pBrinBlk
->
m
ax
Tbid
.
uid
<
pList
->
tableUidList
[
j
])
{
i
+=
1
;
continue
;
}
if
(
pBrinBlk
->
minTbid
.
uid
>
pList
->
tableUidList
[
j
])
{
j
+=
1
;
continue
;
}
// todo maxTbid.uid == xxx?
if
(
pBrinBlk
->
minTbid
.
uid
==
pList
->
tableUidList
[
j
])
{
// this block belongs to a table that is not queried.
STableBlockScanInfo
*
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
p
BrinBlk
->
minTbid
.
uid
,
pReader
->
idStr
);
STableBlockScanInfo
*
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
p
List
->
tableUidList
[
j
]
,
pReader
->
idStr
);
if
(
pScanInfo
==
NULL
)
{
// tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle);
return
terrno
;
...
...
@@ -934,11 +927,8 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead
}
taosArrayPush
(
pIndexList
,
pBrinBlk
);
i
+=
1
;
j
+=
1
;
}
}
int64_t
et2
=
taosGetTimestampUs
();
tsdbDebug
(
"load block index for %d/%d tables completed, elapsed time:%.2f ms, set BrinBlk:%.2f ms, size:%.2f Kb %s"
,
...
...
@@ -1020,6 +1010,14 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
SBrinRecord
record
=
{
0
};
for
(
int32_t
j
=
0
;
j
<
TARRAY2_SIZE
(
block
.
numRow
);
++
j
)
{
tBrinBlockGet
(
&
block
,
j
,
&
record
);
if
(
record
.
suid
<
pReader
->
suid
)
{
continue
;
}
if
(
record
.
suid
>
pReader
->
suid
)
{
break
;
}
{
while
(
record
.
uid
>
uid
)
{
k
+=
1
;
...
...
@@ -1539,9 +1537,9 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SBrinRecord
*
pRecord
=
&
pBlockInfo
->
record
;
// SDataBlk* pBlock = getCurrentBlock(pBlockIter);
code
=
tsdbDataFileReadBlockData
(
pReader
->
pFileReader
,
&
pBlockInfo
->
record
,
pBlockData
);
code
=
tsdbDataFileReadBlockData
(
pReader
->
pFileReader
,
pRecord
,
pBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbError
(
"%p error occurs in loading file block, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
", rows:%d, code:%s %s"
,
...
...
@@ -1552,7 +1550,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
double
elapsedTime
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
SBrinRecord
*
pRecord
=
&
pBlockInfo
->
record
;
tsdbDebug
(
"%p load file block into buffer, global index:%d, index in table block list:%d, brange:%"
PRId64
"-%"
PRId64
", rows:%d, minVer:%"
PRId64
", maxVer:%"
PRId64
", elapsed time:%.2f ms, %s"
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pRecord
->
firstKey
,
pRecord
->
lastKey
,
pRecord
->
numRow
,
...
...
@@ -1983,7 +1980,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pBlock
return
loadDataBlock
;
}
static
bool
isCleanFileDataBlock
(
STsdbReader
*
pReader
,
SFileDataBlockInfo
*
pBlockInfo
,
SDataBlk
*
pBlock
,
static
bool
isCleanFileDataBlock
(
STsdbReader
*
pReader
,
SFileDataBlockInfo
*
pBlockInfo
,
STableBlockScanInfo
*
pScanInfo
,
TSDBKEY
keyInBuf
,
SLastBlockReader
*
pLastBlockReader
)
{
SDataBlockToLoadInfo
info
=
{
0
};
getBlockToLoadInfo
(
&
info
,
pBlockInfo
,
pScanInfo
,
keyInBuf
,
pLastBlockReader
,
pReader
);
...
...
@@ -2870,7 +2867,6 @@ static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlock
// SBlockIndex nxtBIndex = {0};
*
loadNeighbor
=
false
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
SBrinRecord
rec
=
{
0
};
bool
hasNeighbor
=
getNeighborBlockOfSameTable
(
pBlockInfo
,
pBlockScanInfo
,
&
nextIndex
,
pReader
->
order
,
&
rec
);
...
...
@@ -2928,13 +2924,14 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
int64_t
st
=
taosGetTimestampUs
();
int32_t
step
=
asc
?
1
:
-
1
;
double
el
=
0
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
SBrinRecord
*
pRecord
=
&
pBlockInfo
->
record
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
STableBlockScanInfo
*
pBlockScanInfo
=
NULL
;
if
(
pBlockInfo
!=
NULL
)
{
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
)))
{
setBlockAllDumped
(
pDumpInfo
,
p
Block
->
maxKey
.
ts
,
pReader
->
order
);
setBlockAllDumped
(
pDumpInfo
,
p
Record
->
lastKey
,
pReader
->
order
);
return
code
;
}
...
...
@@ -2943,11 +2940,12 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
goto
_end
;
}
pRecord
=
&
pBlockInfo
->
record
;
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pBlockScanInfo
,
pReader
);
// it is a clean block, load it directly
if
(
isCleanFileDataBlock
(
pReader
,
pBlockInfo
,
pBlock
,
pBlock
ScanInfo
,
keyInBuf
,
pLastBlockReader
)
&&
pBlock
->
nRow
<=
pReader
->
resBlockInfo
.
capacity
)
{
if
(
isCleanFileDataBlock
(
pReader
,
pBlockInfo
,
pBlockScanInfo
,
keyInBuf
,
pLastBlockReader
)
&&
(
pRecord
->
numRow
<=
pReader
->
resBlockInfo
.
capacity
)
)
{
if
(
asc
||
(
!
hasDataInLastBlock
(
pLastBlockReader
)))
{
code
=
copyBlockDataToSDataBlock
(
pReader
);
if
(
code
)
{
...
...
@@ -2955,14 +2953,15 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
}
// record the last key value
pBlockScanInfo
->
lastKey
=
asc
?
p
Block
->
maxKey
.
ts
:
pBlock
->
minKey
.
ts
;
pBlockScanInfo
->
lastKey
=
asc
?
p
Record
->
lastKey
:
pRecord
->
firstKey
;
goto
_end
;
}
}
}
else
{
// file blocks not exist
ASSERT
(
0
);
pBlockScanInfo
=
*
pReader
->
status
.
pTableIter
;
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pBlockScanInfo
->
uid
,
sizeof
(
pBlockScanInfo
->
uid
)))
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
//
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
return
code
;
}
}
...
...
@@ -2972,8 +2971,8 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
while
(
1
)
{
bool
hasBlockData
=
false
;
{
while
(
pBlockData
->
nRow
>
0
&&
pBlockData
->
uid
==
pBlockScanInfo
->
uid
)
{
// find the first qualified row in data block
while
(
pBlockData
->
nRow
>
0
&&
pBlockData
->
uid
==
pBlockScanInfo
->
uid
)
{
// find the first qualified row in data block
if
(
isValidFileBlockRow
(
pBlockData
,
pDumpInfo
,
pBlockScanInfo
,
pReader
))
{
hasBlockData
=
true
;
break
;
...
...
@@ -2981,8 +2980,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
pDumpInfo
->
rowIndex
+=
step
;
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
if
(
pDumpInfo
->
rowIndex
>=
pBlock
->
nRow
||
pDumpInfo
->
rowIndex
<
0
)
{
if
(
pDumpInfo
->
rowIndex
>=
pBlockData
->
nRow
||
pDumpInfo
->
rowIndex
<
0
)
{
pBlockInfo
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
// NOTE: get the new block info
// continue check for the next file block if the last ts in the current block
...
...
@@ -2990,7 +2988,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
bool
loadNeighbor
=
false
;
code
=
loadNeighborIfOverlap
(
pBlockInfo
,
pBlockScanInfo
,
pReader
,
&
loadNeighbor
);
if
((
!
loadNeighbor
)
||
(
code
!=
0
))
{
setBlockAllDumped
(
pDumpInfo
,
p
Block
->
maxKey
.
ts
,
pReader
->
order
);
setBlockAllDumped
(
pDumpInfo
,
p
Record
->
lastKey
,
pReader
->
order
);
break
;
}
}
...
...
@@ -3009,8 +3007,8 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
// currently loaded file data block is consumed
if
((
pBlockData
->
nRow
>
0
)
&&
(
pDumpInfo
->
rowIndex
>=
pBlockData
->
nRow
||
pDumpInfo
->
rowIndex
<
0
))
{
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
setBlockAllDumped
(
pDumpInfo
,
p
Block
->
maxKey
.
ts
,
pReader
->
order
);
//
pBlock = getCurrentBlock(&pReader->status.blockIter);
setBlockAllDumped
(
pDumpInfo
,
p
Record
->
lastKey
,
pReader
->
order
);
break
;
}
...
...
@@ -3290,7 +3288,6 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
// reset the index in last block when handing a new file
doCleanupTableScanInfo
(
pScanInfo
);
// pStatus->mapDataCleaned = true;
bool
hasDataInLastFile
=
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
if
(
!
hasDataInLastFile
)
{
...
...
@@ -3625,21 +3622,24 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
// set the correct start position in case of the first/last file block, according to the query time window
static
void
initBlockDumpInfo
(
STsdbReader
*
pReader
,
SDataBlockIter
*
pBlockIter
)
{
int64_t
lastKey
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
INT64_MIN
:
INT64_MAX
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pStatus
->
fBlockDumpInfo
;
if
(
pBlockInfo
)
{
STableBlockScanInfo
*
pScanInfo
=
tSimpleHashGet
(
pBlockIter
->
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
if
(
pScanInfo
)
{
lastKey
=
pScanInfo
->
lastKey
;
}
}
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pStatus
->
fBlockDumpInfo
;
pDumpInfo
->
totalRows
=
pBlockInfo
->
record
.
numRow
;
pDumpInfo
->
rowIndex
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
0
:
pBlockInfo
->
record
.
numRow
-
1
;
}
else
{
pDumpInfo
->
totalRows
=
0
;
pDumpInfo
->
rowIndex
=
0
;
}
pDumpInfo
->
totalRows
=
pBlock
->
nRow
;
pDumpInfo
->
allDumped
=
false
;
pDumpInfo
->
rowIndex
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
0
:
pBlock
->
nRow
-
1
;
pDumpInfo
->
lastKey
=
lastKey
;
}
...
...
@@ -4041,7 +4041,7 @@ typedef enum {
CHECK_FILEBLOCK_QUIT
=
0x2
,
}
CHECK_FILEBLOCK_STATE
;
static
int32_t
checkForNeighborFileBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pScanInfo
,
SDataBlk
*
pBlock
,
static
int32_t
checkForNeighborFileBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pScanInfo
,
SFileDataBlockInfo
*
pFBlock
,
SRowMerger
*
pMerger
,
int64_t
key
,
CHECK_FILEBLOCK_STATE
*
state
)
{
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
...
...
@@ -4085,13 +4085,13 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
CHECK_FILEBLOCK_STATE
st
;
SFileDataBlockInfo
*
pFileBlockInfo
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
SDataBlk
*
pCurrentBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
//
SDataBlk* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter);
if
(
pFileBlockInfo
==
NULL
)
{
st
=
CHECK_FILEBLOCK_QUIT
;
break
;
}
checkForNeighborFileBlock
(
pReader
,
pScanInfo
,
p
CurrentBlock
,
p
FileBlockInfo
,
pMerger
,
key
,
&
st
);
checkForNeighborFileBlock
(
pReader
,
pScanInfo
,
pFileBlockInfo
,
pMerger
,
key
,
&
st
);
if
(
st
==
CHECK_FILEBLOCK_QUIT
)
{
break
;
}
...
...
@@ -4767,14 +4767,10 @@ void tsdbReaderClose2(STsdbReader* pReader) {
pReader
->
pReadSnap
=
NULL
;
tsdbReleaseReader
(
pReader
);
tsdbUninitReaderLock
(
pReader
);
taosMemoryFreeClear
(
pReader
->
status
.
pLDataIter
);
taosMemoryFreeClear
(
pReader
->
status
.
uidList
.
tableUidList
);
SIOCostSummary
*
pCost
=
&
pReader
->
cost
;
SFilesetIter
*
pFilesetIter
=
&
pReader
->
status
.
fileIter
;
SFilesetIter
*
pFilesetIter
=
&
pReader
->
status
.
fileIter
;
if
(
pFilesetIter
->
pLastBlockReader
!=
NULL
)
{
SLastBlockReader
*
pLReader
=
pFilesetIter
->
pLastBlockReader
;
tMergeTreeClose
(
&
pLReader
->
mergeTree
);
...
...
@@ -4782,9 +4778,15 @@ void tsdbReaderClose2(STsdbReader* pReader) {
getLastBlockLoadInfo
(
pLReader
->
pInfo
,
&
pCost
->
lastBlockLoad
,
&
pCost
->
lastBlockLoadTime
);
pLReader
->
pInfo
=
destroyLastBlockLoadInfo
(
pLReader
->
pInfo
);
// todo dynamic allocate the number of stt data iter
destroySttBlockReader
(
pReader
->
status
.
pLDataIter
,
pReader
->
pTsdb
->
pVnode
->
config
.
sttTrigger
);
taosMemoryFree
(
pLReader
);
}
taosMemoryFreeClear
(
pReader
->
status
.
pLDataIter
);
taosMemoryFreeClear
(
pReader
->
status
.
uidList
.
tableUidList
);
tsdbDebug
(
"%p :io-cost summary: head-file:%"
PRIu64
", head-file time:%.2f ms, SMA:%"
PRId64
" SMA-time:%.2f ms, fileBlocks:%"
PRId64
...
...
@@ -5210,9 +5212,10 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock,
}
int64_t
st
=
taosGetTimestampUs
();
ASSERT
(
0
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
if
(
tDataBlkHasSma
(
pBlock
)
)
{
//
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
if
(
/*tDataBlkHasSma(pBlock)*/
1
)
{
// code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbDebug
(
"vgId:%d, failed to load block SMA for uid %"
PRIu64
", code:%s, %s"
,
0
,
pFBlock
->
uid
,
tstrerror
(
code
),
...
...
@@ -5250,7 +5253,7 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock,
}
// do fill all null column value SMA info
if
(
doFillNullColSMA
(
pSup
,
p
Block
->
n
Row
,
numOfCols
,
pTsAgg
))
{
if
(
doFillNullColSMA
(
pSup
,
p
FBlock
->
record
.
num
Row
,
numOfCols
,
pTsAgg
))
{
*
hasNullSMA
=
true
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -5470,11 +5473,13 @@ int32_t tsdbGetFileBlocksDistInfo2(STsdbReader* pReader, STableBlockDistInfo* pT
pTableBlockInfo
->
numOfTables
=
numOfTables
;
bool
hasNext
=
(
pBlockIter
->
numOfBlocks
>
0
);
ASSERT
(
0
);
while
(
true
)
{
if
(
hasNext
)
{
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
//
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
int32_t
numOfRows
=
pBlock
->
nRow
;
int32_t
numOfRows
=
0
;
//pFB
->nRow;
pTableBlockInfo
->
totalRows
+=
numOfRows
;
if
(
numOfRows
>
pTableBlockInfo
->
maxRows
)
{
...
...
@@ -5489,7 +5494,7 @@ int32_t tsdbGetFileBlocksDistInfo2(STsdbReader* pReader, STableBlockDistInfo* pT
pTableBlockInfo
->
numOfSmallBlocks
+=
1
;
}
pTableBlockInfo
->
totalSize
+=
pBlock
->
aSubBlock
[
0
].
szBlock
;
pTableBlockInfo
->
totalSize
+=
0
;
//
pBlock->aSubBlock[0].szBlock;
int32_t
bucketIndex
=
getBucketIndex
(
pTableBlockInfo
->
defMinRows
,
bucketRange
,
numOfRows
,
numOfBuckets
);
pTableBlockInfo
->
blockRowsHisto
[
bucketIndex
]
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录