Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
203a8073
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看板
提交
203a8073
编写于
8月 11, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: use mem schema if pReader->pSchema is null
上级
a288d08a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
25 deletion
+28
-25
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+28
-25
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
203a8073
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdb.h"
#include "osDef.h"
#include "tsdb.h"
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
typedef
enum
{
...
...
@@ -130,8 +130,8 @@ struct STsdbReader {
SBlockLoadSuppInfo
suppInfo
;
STsdbReadSnap
*
pReadSnap
;
SIOCostSummary
cost
;
STSchema
*
pSchema
;
// the newest version schema
STSchema
*
pMemSchema
;
// the previous schema for in-memory data, to avoid load schema too many times
STSchema
*
pSchema
;
// the newest version schema
STSchema
*
pMemSchema
;
// the previous schema for in-memory data, to avoid load schema too many times
SDataFReader
*
pFileReader
;
SVersionRange
verRange
;
...
...
@@ -1213,17 +1213,17 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo*
return
code
;
}
static
bool
tryCopyDistinctRowFromFileBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
int64_t
key
,
SFileBlockDumpInfo
*
pDumpInfo
)
{
static
bool
tryCopyDistinctRowFromFileBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
int64_t
key
,
SFileBlockDumpInfo
*
pDumpInfo
)
{
// opt version
// 1. it is not a border point
// 2. the direct next point is not an duplicated timestamp
if
((
pDumpInfo
->
rowIndex
<
pDumpInfo
->
totalRows
-
1
&&
pReader
->
order
==
TSDB_ORDER_ASC
)
||
(
pDumpInfo
->
rowIndex
>
0
&&
pReader
->
order
==
TSDB_ORDER_DESC
))
{
int32_t
step
=
pReader
->
order
==
TSDB_ORDER_ASC
?
1
:
-
1
;
int32_t
step
=
pReader
->
order
==
TSDB_ORDER_ASC
?
1
:
-
1
;
int64_t
nextKey
=
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
+
step
];
if
(
nextKey
!=
key
)
{
// merge is not needed
if
(
nextKey
!=
key
)
{
// merge is not needed
doAppendRowFromBlock
(
pReader
->
pResBlock
,
pReader
,
pBlockData
,
pDumpInfo
->
rowIndex
);
pDumpInfo
->
rowIndex
+=
step
;
return
true
;
...
...
@@ -1239,7 +1239,7 @@ static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader*
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
}
if
(
sversion
==
pReader
->
pSchema
->
version
)
{
if
(
pReader
->
pSchema
&&
sversion
==
pReader
->
pSchema
->
version
)
{
return
pReader
->
pSchema
;
}
...
...
@@ -1265,10 +1265,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
SArray
*
pDelList
=
pBlockScanInfo
->
delSkyline
;
bool
freeTSRow
=
false
;
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
SArray
*
pDelList
=
pBlockScanInfo
->
delSkyline
;
bool
freeTSRow
=
false
;
uint64_t
uid
=
pBlockScanInfo
->
uid
;
// ascending order traverse
...
...
@@ -2149,7 +2149,7 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea
}
TSDBROW
*
pRow
=
tsdbTbDataIterGet
(
pIter
->
iter
);
TSDBKEY
key
=
{.
ts
=
pRow
->
pTSRow
->
ts
,
.
version
=
pRow
->
version
};
TSDBKEY
key
=
{.
ts
=
pRow
->
pTSRow
->
ts
,
.
version
=
pRow
->
version
};
if
(
outOfTimeWindow
(
key
.
ts
,
&
pReader
->
window
))
{
pIter
->
hasVal
=
false
;
return
NULL
;
...
...
@@ -2182,7 +2182,6 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea
}
}
int32_t
doMergeRowsInBuf
(
SIterInfo
*
pIter
,
uint64_t
uid
,
int64_t
ts
,
SArray
*
pDelList
,
SRowMerger
*
pMerger
,
STsdbReader
*
pReader
)
{
while
(
1
)
{
...
...
@@ -2314,9 +2313,8 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
void
doMergeMultiRows
(
TSDBROW
*
pRow
,
uint64_t
uid
,
SIterInfo
*
pIter
,
SArray
*
pDelList
,
STSRow
**
pTSRow
,
STsdbReader
*
pReader
,
bool
*
freeTSRow
)
{
TSDBROW
*
pNextRow
=
NULL
;
TSDBROW
current
=
*
pRow
;
TSDBROW
current
=
*
pRow
;
{
// if the timestamp of the next valid row has a different ts, return current row directly
pIter
->
hasVal
=
tsdbTbDataIterNext
(
pIter
->
iter
);
...
...
@@ -2346,6 +2344,10 @@ void doMergeMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDe
// get the correct schema for data in memory
STSchema
*
pTSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
&
current
),
pReader
,
uid
);
if
(
pReader
->
pSchema
==
NULL
)
{
pReader
->
pSchema
=
pTSchema
;
}
tRowMergerInit2
(
&
merge
,
pReader
->
pSchema
,
&
current
,
pTSchema
);
STSchema
*
pTSchema1
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pNextRow
),
pReader
,
uid
);
...
...
@@ -2386,8 +2388,8 @@ void doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlo
tRowMergerGetRow
(
&
merge
,
pTSRow
);
}
int32_t
tsdbGetNextRowInMem
(
STableBlockScanInfo
*
pBlockScanInfo
,
STsdbReader
*
pReader
,
STSRow
**
pTSRow
,
int64_t
endKey
,
bool
*
freeTSRow
)
{
int32_t
tsdbGetNextRowInMem
(
STableBlockScanInfo
*
pBlockScanInfo
,
STsdbReader
*
pReader
,
STSRow
**
pTSRow
,
int64_t
endKey
,
bool
*
freeTSRow
)
{
TSDBROW
*
pRow
=
getValidRow
(
&
pBlockScanInfo
->
iter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
TSDBROW
*
piRow
=
getValidRow
(
&
pBlockScanInfo
->
iiter
,
pBlockScanInfo
->
delSkyline
,
pReader
);
SArray
*
pDelList
=
pBlockScanInfo
->
delSkyline
;
...
...
@@ -2442,7 +2444,7 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
);
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
pTSRow
->
sver
,
pReader
,
uid
);
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
pTSRow
->
sver
,
pReader
,
uid
);
SColVal
colVal
=
{
0
};
int32_t
i
=
0
,
j
=
0
;
...
...
@@ -2528,7 +2530,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
do
{
STSRow
*
pTSRow
=
NULL
;
bool
freeTSRow
=
false
;
bool
freeTSRow
=
false
;
tsdbGetNextRowInMem
(
pBlockScanInfo
,
pReader
,
&
pTSRow
,
endKey
,
&
freeTSRow
);
if
(
pTSRow
==
NULL
)
{
break
;
...
...
@@ -2577,9 +2579,7 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
return
metaGetIvtIdx
(
pMeta
);
}
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
/**
* @brief Get all suids since suid
...
...
@@ -2757,7 +2757,8 @@ void tsdbReaderClose(STsdbReader* pReader) {
SIOCostSummary
*
pCost
=
&
pReader
->
cost
;
tsdbDebug
(
"%p :io-cost summary: head-file:%"
PRIu64
", head-file time:%.2f ms, SMA:%"
PRId64
" SMA-time:%.2f ms, fileBlocks:%"
PRId64
", fileBlocks-time:%.2f ms, "
" SMA-time:%.2f ms, fileBlocks:%"
PRId64
", fileBlocks-time:%.2f ms, "
"build in-memory-block-time:%.2f ms, STableBlockScanInfo size:%.2f Kb %s"
,
pReader
,
pCost
->
headFileLoad
,
pCost
->
headFileLoadTime
,
pCost
->
smaData
,
pCost
->
smaLoadTime
,
pCost
->
numOfBlocks
,
pCost
->
blockLoadTime
,
pCost
->
buildmemBlock
,
...
...
@@ -2765,7 +2766,9 @@ void tsdbReaderClose(STsdbReader* pReader) {
taosMemoryFree
(
pReader
->
idStr
);
taosMemoryFree
(
pReader
->
pSchema
);
taosMemoryFree
(
pReader
->
pMemSchema
);
if
(
pReader
->
pMemSchema
!=
pReader
->
pSchema
)
{
taosMemoryFree
(
pReader
->
pMemSchema
);
}
taosMemoryFreeClear
(
pReader
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录