Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8ae2ab1c
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看板
提交
8ae2ab1c
编写于
8月 08, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
33c3f34f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
78 addition
and
46 deletion
+78
-46
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+16
-15
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+5
-5
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+7
-6
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+44
-14
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
8ae2ab1c
...
...
@@ -138,22 +138,23 @@ int32_t tGetColData(uint8_t *p, SColData *pColData);
#define tBlockDataFirstKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataFirstRow(PBLOCKDATA))
#define tBlockDataLastKey(PBLOCKDATA) TSDBROW_KEY(&tBlockDataLastRow(PBLOCKDATA))
int32_t
tBlockDataCreate
(
SBlockData
*
pBlockData
);
void
tBlockDataDestroy
(
SBlockData
*
pBlockData
,
int8_t
deepClear
);
void
tBlockDataReset
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
,
int64_t
suid
,
int64_t
uid
);
int32_t
tBlockDataAddColData
(
SBlockData
*
pBlockData
,
int32_t
iColData
,
SColData
**
ppColData
);
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
);
void
tBlockDataClearData
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataCorrectSchema
(
SBlockData
*
pBlockData
,
SBlockData
*
pBlockDataFrom
);
int32_t
tBlockDataMerge
(
SBlockData
*
pBlockData1
,
SBlockData
*
pBlockData2
,
SBlockData
*
pBlockData
);
int32_t
tBlockDataCopy
(
SBlockData
*
pBlockDataSrc
,
SBlockData
*
pBlockDataDest
);
int32_t
tBlockDataCreate
(
SBlockData
*
pBlockData
);
void
tBlockDataDestroy
(
SBlockData
*
pBlockData
,
int8_t
deepClear
);
int32_t
tBlockDataInit
(
SBlockData
*
pBlockData
,
int64_t
suid
,
int64_t
uid
,
STSchema
*
pTSchema
);
int32_t
tBlockDataInitEx
(
SBlockData
*
pBlockData
,
int64_t
*
suid
,
int64_t
uid
,
SArray
*
aColId
);
void
tBlockDataReset
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int64_t
uid
);
void
tBlockDataClear
(
SBlockData
*
pBlockData
);
SColData
*
tBlockDataGetColDataByIdx
(
SBlockData
*
pBlockData
,
int32_t
idx
);
void
tBlockDataGetColData
(
SBlockData
*
pBlockData
,
int16_t
cid
,
SColData
**
ppColData
);
int32_t
tPutBlockData
(
uint8_t
*
p
,
SBlockData
*
pBlockData
);
int32_t
tGetBlockData
(
uint8_t
*
p
,
SBlockData
*
pBlockData
);
#if 1
int32_t
tBlockDataAddColData
(
SBlockData
*
pBlockData
,
int32_t
iColData
,
SColData
**
ppColData
);
int32_t
tBlockDataMerge
(
SBlockData
*
pBlockData1
,
SBlockData
*
pBlockData2
,
SBlockData
*
pBlockData
);
int32_t
tBlockDataCopy
(
SBlockData
*
pBlockDataSrc
,
SBlockData
*
pBlockDataDest
);
int32_t
tPutBlockData
(
uint8_t
*
p
,
SBlockData
*
pBlockData
);
int32_t
tGetBlockData
(
uint8_t
*
p
,
SBlockData
*
pBlockData
);
#endif
// SDiskDataHdr
int32_t
tPutDiskDataHdr
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetDiskDataHdr
(
uint8_t
*
p
,
void
*
ph
);
...
...
@@ -190,7 +191,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
uint8_t
**
ppBuf
);
int32_t
tsdbDecmprColData
(
uint8_t
*
pIn
,
SBlockCol
*
pBlockCol
,
int8_t
cmprAlg
,
int32_t
nVal
,
SColData
*
pColData
,
uint8_t
**
ppBuf
);
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
);
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
,
int8_t
toCheck
);
// tsdbMemTable ==============================================================================================
// SMemTable
int32_t
tsdbMemTableCreate
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTable
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
8ae2ab1c
...
...
@@ -539,7 +539,7 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter, SBlock *pBlock) {
if
(
code
)
goto
_err
;
// clear
tBlockDataClear
Data
(
pBlockData
);
tBlockDataClear
(
pBlockData
);
return
code
;
...
...
@@ -578,7 +578,7 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
}
// clear
tBlockDataClear
Data
(
pBlockData
);
tBlockDataClear
(
pBlockData
);
return
code
;
...
...
@@ -596,7 +596,7 @@ static int32_t tsdbMergeCommitData(SCommitter *pCommitter, STbDataIter *pIter, S
code
=
tsdbReadDataBlock
(
pCommitter
->
dReader
.
pReader
,
pBlock
,
pBlockDataR
,
NULL
,
0
);
if
(
code
)
goto
_err
;
tBlockDataClear
Data
(
pBlockDataW
);
tBlockDataClear
(
pBlockDataW
);
int32_t
iRow
=
0
;
TSDBROW
row
;
TSDBROW
*
pRow1
=
tsdbTbDataIterGet
(
pIter
);
...
...
@@ -672,7 +672,7 @@ static int32_t tsdbCommitTableMemData(SCommitter *pCommitter, STbDataIter *pIter
STbData
*
pTbData
=
pIter
->
pTbData
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bData
;
tBlockDataClear
Data
(
pBlockData
);
tBlockDataClear
(
pBlockData
);
TSDBROW
*
pRow
=
tsdbTbDataIterGet
(
pIter
);
while
(
true
)
{
if
(
pRow
==
NULL
)
{
...
...
@@ -741,7 +741,7 @@ static int32_t tsdbMergeAsSubBlock(SCommitter *pCommitter, STbDataIter *pIter, S
STbData
*
pTbData
=
pIter
->
pTbData
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bData
;
tBlockDataClear
Data
(
pBlockData
);
tBlockDataClear
(
pBlockData
);
TSDBROW
*
pRow
=
tsdbTbDataIterGet
(
pIter
);
while
(
true
)
{
if
(
pRow
==
NULL
)
break
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
8ae2ab1c
...
...
@@ -1748,7 +1748,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
TSDBKEY
key
=
getCurrentKeyInBuf
(
pBlockIter
,
pReader
);
if
(
fileBlockShouldLoad
(
pReader
,
pFBlock
,
pBlock
,
pScanInfo
,
key
))
{
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
Data
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
(
&
pStatus
->
fileBlockData
);
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -2208,7 +2208,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
// 3. load the neighbor block, and set it to be the currently accessed file data block
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
Data
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
(
&
pStatus
->
fileBlockData
);
int32_t
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
pScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -2871,7 +2871,7 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
STableBlockScanInfo
*
pBlockScanInfo
=
taosHashGet
(
pStatus
->
pTableMap
,
&
pFBlock
->
uid
,
sizeof
(
pFBlock
->
uid
));
tBlockDataReset
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
Data
(
&
pStatus
->
fileBlockData
);
tBlockDataClear
(
&
pStatus
->
fileBlockData
);
int32_t
code
=
doLoadFileBlockData
(
pReader
,
&
pStatus
->
blockIter
,
pBlockScanInfo
,
&
pStatus
->
fileBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tBlockDataDestroy
(
&
pStatus
->
fileBlockData
,
1
);
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
8ae2ab1c
...
...
@@ -731,13 +731,14 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
int32_t
nColId
,
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
// TODO
tBlockDataReset
(
pBlockData
);
ASSERT
(
pBlockData
->
suid
||
pBlockData
->
uid
);
tBlockDataClear
(
pBlockData
);
TdFilePtr
pFD
=
fromLast
?
pReader
->
pLastFD
:
pReader
->
pDataFD
;
// uid + version + tskey
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
,
&
pReader
->
pBuf1
,
pBlkInfo
->
szKey
);
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
,
&
pReader
->
pBuf1
,
pBlkInfo
->
szKey
,
1
);
if
(
code
)
goto
_err
;
SDiskDataHdr
hdr
;
uint8_t
*
p
=
pReader
->
pBuf1
+
tGetDiskDataHdr
(
pReader
->
pBuf1
,
&
hdr
);
...
...
@@ -776,8 +777,8 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
// read and decode columns
if
(
hdr
.
szBlkCol
>
0
)
{
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
+
pBlkInfo
->
szKey
,
&
pReader
->
pBuf1
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
)
);
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
+
pBlkInfo
->
szKey
,
&
pReader
->
pBuf1
,
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
),
1
);
if
(
code
)
goto
_err
;
int32_t
n
=
0
;
...
...
@@ -797,7 +798,7 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
}
else
{
code
=
tsdbReadAndCheckFile
(
pFD
,
pBlkInfo
->
offset
+
pBlkInfo
->
szKey
+
hdr
.
szBlkCol
+
sizeof
(
TSCKSUM
)
+
blockCol
.
offset
,
&
pReader
->
pBuf2
,
blockCol
.
szBitmap
+
blockCol
.
szOffset
+
blockCol
.
szValue
+
sizeof
(
TSCKSUM
));
blockCol
.
szBitmap
+
blockCol
.
szOffset
+
blockCol
.
szValue
+
sizeof
(
TSCKSUM
)
,
1
);
code
=
tsdbDecmprColData
(
pReader
->
pBuf2
,
&
blockCol
,
hdr
.
cmprAlg
,
hdr
.
nRow
,
pColData
,
&
pReader
->
pBuf3
);
if
(
code
)
goto
_err
;
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
8ae2ab1c
...
...
@@ -482,7 +482,7 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
if (code) goto _err;
tBlockReset(&pWriter->blockW);
tBlockDataClear
Data
(&pWriter->bDataW);
tBlockDataClear(&pWriter->bDataW);
}
pWriter->iRow++;
...
...
@@ -675,7 +675,7 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if (code) goto _err;
tBlockReset(&pWriter->blockW);
tBlockDataClear
Data
(&pWriter->bDataW);
tBlockDataClear(&pWriter->bDataW);
}
code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock);
...
...
@@ -725,7 +725,7 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if (code) goto _err;
tBlockReset(&pWriter->blockW);
tBlockDataClear
Data
(&pWriter->bDataW);
tBlockDataClear(&pWriter->bDataW);
}
return code;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
8ae2ab1c
...
...
@@ -1145,31 +1145,54 @@ void tBlockDataDestroy(SBlockData *pBlockData, int8_t deepClear) {
pBlockData
->
aColData
=
NULL
;
}
void
tBlockDataReset
(
SBlockData
*
pBlockData
)
{
pBlockData
->
suid
=
0
;
pBlockData
->
uid
=
0
;
int32_t
tBlockDataInit
(
SBlockData
*
pBlockData
,
int64_t
suid
,
int64_t
uid
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
ASSERT
(
suid
||
uid
);
pBlockData
->
suid
=
suid
;
pBlockData
->
uid
=
uid
;
pBlockData
->
nRow
=
0
;
taosArrayClear
(
pBlockData
->
aIdx
);
for
(
int32_t
iColumn
=
1
;
iColumn
<
pTSchema
->
numOfCols
;
iColumn
++
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
SColData
*
pColData
;
code
=
tBlockDataAddColData
(
pBlockData
,
iColumn
-
1
,
&
pColData
);
if
(
code
)
goto
_exit
;
tColDataInit
(
pColData
,
pTColumn
->
colId
,
pTColumn
->
type
,
(
pTColumn
->
flags
&
COL_SMA_ON
)
?
1
:
0
);
}
_exit:
return
code
;
}
int32_t
tBlockData
SetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
,
int64_t
suid
,
int64_t
ui
d
)
{
int32_t
tBlockData
InitEx
(
SBlockData
*
pBlockData
,
int64_t
*
suid
,
int64_t
uid
,
SArray
*
aColI
d
)
{
int32_t
code
=
0
;
ASSERT
(
suid
||
uid
);
tBlockDataReset
(
pBlockData
);
pBlockData
->
suid
=
suid
;
pBlockData
->
uid
=
uid
;
pBlockData
->
nRow
=
0
;
if
(
pTSchema
)
{
for
(
int32_t
iColumn
=
1
;
iColumn
<
pTSchema
->
numOfCols
;
iColumn
++
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
SColData
*
pColData
;
taosArrayClear
(
pBlockData
->
aIdx
);
if
(
aColId
)
{
int16_t
lcid
=
-
1
;
for
(
int32_t
iColId
=
0
;
iColId
<
taosArrayGetSize
(
aColId
);
iColId
++
)
{
int16_t
cid
=
*
(
int16_t
*
)
taosArrayGet
(
aColId
,
iColId
);
code
=
tBlockDataAddColData
(
pBlockData
,
iColumn
-
1
,
&
pColData
);
ASSERT
(
cid
!=
PRIMARYKEY_TIMESTAMP_COL_ID
);
ASSERT
(
cid
>
lcid
);
lcid
=
cid
;
SColData
*
pColData
;
code
=
tBlockDataAddColData
(
pBlockData
,
iColId
,
&
pColData
);
if
(
code
)
goto
_exit
;
tColDataInit
(
pColData
,
pTColumn
->
colId
,
pTColumn
->
type
,
(
pTColumn
->
flags
&
COL_SMA_ON
)
!=
0
);
tColDataInit
(
pColData
,
cid
,
TSDB_DATA_TYPE_NULL
,
-
1
);
}
}
...
...
@@ -1177,7 +1200,14 @@ _exit:
return
code
;
}
void
tBlockDataClearData
(
SBlockData
*
pBlockData
)
{
void
tBlockDataReset
(
SBlockData
*
pBlockData
)
{
pBlockData
->
suid
=
0
;
pBlockData
->
uid
=
0
;
pBlockData
->
nRow
=
0
;
taosArrayClear
(
pBlockData
->
aIdx
);
}
void
tBlockDataClear
(
SBlockData
*
pBlockData
)
{
pBlockData
->
nRow
=
0
;
for
(
int32_t
iColData
=
0
;
iColData
<
taosArrayGetSize
(
pBlockData
->
aIdx
);
iColData
++
)
{
SColData
*
pColData
=
tBlockDataGetColDataByIdx
(
pBlockData
,
iColData
);
...
...
@@ -1869,7 +1899,7 @@ _exit:
return
code
;
}
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
)
{
int32_t
tsdbReadAndCheckFile
(
TdFilePtr
pFD
,
int64_t
offset
,
uint8_t
**
ppOut
,
int32_t
size
,
int8_t
toCheck
)
{
int32_t
code
=
0
;
// alloc
...
...
@@ -1894,7 +1924,7 @@ int32_t tsdbReadAndCheckFile(TdFilePtr pFD, int64_t offset, uint8_t **ppOut, int
}
// check
if
(
!
taosCheckChecksumWhole
(
*
ppOut
,
size
))
{
if
(
toCheck
&&
!
taosCheckChecksumWhole
(
*
ppOut
,
size
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_exit
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录