Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e76ae4ff
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看板
提交
e76ae4ff
编写于
6月 21, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(tsdb) : fix memory leak.
上级
84bd2fb7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
93 addition
and
71 deletion
+93
-71
source/dnode/vnode/src/tsdb/tsdbRead2.c
source/dnode/vnode/src/tsdb/tsdbRead2.c
+93
-71
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead2.c
浏览文件 @
e76ae4ff
...
...
@@ -967,14 +967,53 @@ static void cleanupTableScanInfo(SReaderStatus* pStatus) {
doCleanupTableScanInfo
(
*
px
);
}
}
typedef
struct
SBrinRecordIter
{
SArray
*
pBrinBlockList
;
SBrinBlk
*
pCurrentBlk
;
int32_t
blockIndex
;
int32_t
recordIndex
;
SDataFileReader
*
pReader
;
SBrinBlock
block
;
SBrinRecord
record
;
}
SBrinRecordIter
;
void
initBrinRecordIter
(
SBrinRecordIter
*
pIter
,
SDataFileReader
*
pReader
,
SArray
*
pList
)
{
memset
(
&
pIter
->
block
,
0
,
sizeof
(
SBrinBlock
));
memset
(
&
pIter
->
record
,
0
,
sizeof
(
SBrinRecord
));
pIter
->
blockIndex
=
-
1
;
pIter
->
recordIndex
=
-
1
;
pIter
->
pReader
=
pReader
;
pIter
->
pBrinBlockList
=
pList
;
}
SBrinRecord
*
getNextBrinRecord
(
SBrinRecordIter
*
pIter
)
{
if
(
pIter
->
blockIndex
==
-
1
||
(
pIter
->
recordIndex
+
1
)
>=
TARRAY2_SIZE
(
pIter
->
block
.
numRow
))
{
pIter
->
blockIndex
+=
1
;
if
(
pIter
->
blockIndex
>=
taosArrayGetSize
(
pIter
->
pBrinBlockList
))
{
return
NULL
;
}
pIter
->
pCurrentBlk
=
taosArrayGet
(
pIter
->
pBrinBlockList
,
pIter
->
blockIndex
);
tBrinBlockClear
(
&
pIter
->
block
);
tsdbDataFileReadBrinBlock
(
pIter
->
pReader
,
pIter
->
pCurrentBlk
,
&
pIter
->
block
);
pIter
->
recordIndex
=
-
1
;
}
// pStatus->mapDataCleaned = true;
pIter
->
recordIndex
+=
1
;
tBrinBlockGet
(
&
pIter
->
block
,
pIter
->
recordIndex
,
&
pIter
->
record
);
return
&
pIter
->
record
;
}
void
clearBrinBlockIter
(
SBrinRecordIter
*
pIter
)
{
tBrinBlockDestroy
(
&
pIter
->
block
);
}
static
int32_t
doLoadFileBlock
(
STsdbReader
*
pReader
,
SArray
*
pIndexList
,
SBlockNumber
*
pBlockNum
,
SArray
*
pTableScanInfoList
)
{
size_t
sizeInDisk
=
0
;
size_t
numOfBlocks
=
taosArrayGetSize
(
pIndexList
);
int64_t
st
=
taosGetTimestampUs
();
cleanupTableScanInfo
(
&
pReader
->
status
);
...
...
@@ -982,26 +1021,40 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
int32_t
i
=
0
,
k
=
0
;
int32_t
numOfTables
=
tSimpleHashGetSize
(
pReader
->
status
.
pTableMap
);
while
(
i
<
numOfBlocks
&&
k
<
numOfTables
)
{
SBrinBlk
*
pBlk
=
taosArrayGet
(
pIndexList
,
i
);
uint64_t
uid
=
pReader
->
status
.
uidList
.
tableUidList
[
k
];
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
STimeWindow
w
=
pReader
->
window
;
SBrinRecordIter
iter
=
{
0
};
initBrinRecordIter
(
&
iter
,
pReader
->
pFileReader
,
pIndexList
);
SBrinRecord
*
pRecord
=
NULL
;
SBrinBlock
block
=
{
0
};
tsdbDataFileReadBrinBlock
(
pReader
->
pFileReader
,
pBlk
,
&
block
);
while
(
k
<
numOfTables
)
{
pRecord
=
getNextBrinRecord
(
&
iter
);
// tMapDataReset(&pScanInfo->mapData);
// tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData);
// taosArrayEnsureCap(pScanInfo->pBlockList, pScanInfo->mapData.nItem);
uint64_t
uid
=
pReader
->
status
.
uidList
.
tableUidList
[
k
];
if
(
pRecord
==
NULL
||
pRecord
->
suid
>
pReader
->
suid
)
{
break
;
}
// todo set the correct size
sizeInDisk
+=
0
;
//pScanInfo->mapData.nData;
if
(
pRecord
->
suid
<
pReader
->
suid
)
{
continue
;
}
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
STimeWindow
w
=
pReader
->
window
;
if
(
isEmptyQueryTimeWindow
(
&
w
))
{
ASSERT
(
pRecord
->
suid
==
pReader
->
suid
);
if
(
pRecord
->
uid
<
uid
)
{
continue
;
}
while
(
pRecord
->
uid
>
uid
&&
k
<
numOfTables
)
{
k
+=
1
;
}
if
(
k
>=
numOfTables
)
{
break
;
}
ASSERT
(
pRecord
->
suid
==
pReader
->
suid
&&
uid
==
pRecord
->
uid
);
STableBlockScanInfo
*
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
uid
,
pReader
->
idStr
);
if
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
{
w
.
skey
=
pScanInfo
->
lastKey
+
step
;
...
...
@@ -1009,69 +1062,39 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
w
.
ekey
=
pScanInfo
->
lastKey
+
step
;
}
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
)
<
numOfTables
)
{
k
+=
1
;
uid
=
pReader
->
status
.
uidList
.
tableUidList
[
k
];
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
uid
,
pReader
->
idStr
);
if
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
{
w
.
skey
=
pScanInfo
->
lastKey
+
step
;
}
else
{
w
.
ekey
=
pScanInfo
->
lastKey
+
step
;
}
}
if
(
k
>=
numOfTables
)
{
break
;
}
if
(
record
.
uid
<
uid
)
{
continue
;
}
}
ASSERT
(
record
.
suid
==
pReader
->
suid
);
// 1. time range check
if
(
record
.
firstKey
>
w
.
ekey
||
record
.
lastKey
<
w
.
skey
)
{
continue
;
}
// 2. version range check
if
(
record
.
firstKeyVer
>
pReader
->
verRange
.
maxVer
||
record
.
lastKeyVer
<
pReader
->
verRange
.
minVer
)
{
continue
;
}
if
(
isEmptyQueryTimeWindow
(
&
w
))
{
k
+=
1
;
continue
;
}
// SBlockIndex bIndex = {.ordinalIndex = j, .inFileOffset = record.blockOffset};
// bIndex.window = (STimeWindow){.skey = record.firstKey, .ekey = record.lastKey};
void
*
p1
=
taosArrayPush
(
pScanInfo
->
pBlockList
,
&
record
);
if
(
p1
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
// 1. time range check
if
(
pRecord
->
firstKey
>
w
.
ekey
||
pRecord
->
lastKey
<
w
.
skey
)
{
continue
;
}
pBlockNum
->
numOfBlocks
+=
1
;
// 2. version range check
if
(
pRecord
->
firstKeyVer
>
pReader
->
verRange
.
maxVer
||
pRecord
->
lastKeyVer
<
pReader
->
verRange
.
minVer
)
{
continue
;
}
i
+=
1
;
void
*
p1
=
taosArrayPush
(
pScanInfo
->
pBlockList
,
pRecord
);
if
(
p1
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
STableBlockScanInfo
**
p
=
taosArrayGetLast
(
pTableScanInfoList
)
;
if
(
(
p
==
NULL
||
(
*
p
)
->
uid
!=
uid
)
&&
taosArrayGetSize
(
pScanInfo
->
pBlockList
)
>
0
)
{
pBlockNum
->
numOfBlocks
+=
1
;
if
(
taosArrayGetSize
(
pTableScanInfoList
)
==
0
)
{
taosArrayPush
(
pTableScanInfoList
,
&
pScanInfo
);
}
else
{
STableBlockScanInfo
**
p
=
taosArrayGetLast
(
pTableScanInfoList
);
if
((
*
p
)
->
uid
!=
uid
)
{
taosArrayPush
(
pTableScanInfoList
,
&
pScanInfo
);
}
}
}
clearBrinBlockIter
(
&
iter
);
pBlockNum
->
numOfLastFiles
=
pReader
->
status
.
pCurrentFileset
->
lvlArr
->
size
;
int32_t
total
=
pBlockNum
->
numOfLastFiles
+
pBlockNum
->
numOfBlocks
;
...
...
@@ -1336,7 +1359,6 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) {
SBlockData
*
pBlockData
=
&
pStatus
->
fileBlockData
;
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
// SDataBlk* pBlock = getCurrentBlock(pBlockIter);
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
int32_t
numOfOutputCols
=
pSupInfo
->
numOfCols
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录