Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aec4297e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
aec4297e
编写于
9月 02, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact code
上级
ff4fda84
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
166 addition
and
166 deletion
+166
-166
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+9
-9
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+27
-27
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+36
-36
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+16
-16
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+22
-22
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+53
-53
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
aec4297e
...
...
@@ -42,7 +42,7 @@ typedef struct SMemTable SMemTable;
typedef
struct
STbDataIter
STbDataIter
;
typedef
struct
SMapData
SMapData
;
typedef
struct
SBlockIdx
SBlockIdx
;
typedef
struct
S
Block
SBloc
k
;
typedef
struct
S
DataBlk
SDataBl
k
;
typedef
struct
SSstBlk
SSstBlk
;
typedef
struct
SColData
SColData
;
typedef
struct
SDiskDataHdr
SDiskDataHdr
;
...
...
@@ -114,12 +114,12 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
int32_t
tPutBlockCol
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetBlockCol
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tBlockColCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
// S
Bloc
k
void
tBlockReset
(
S
Bloc
k
*
pBlock
);
int32_t
tPut
Bloc
k
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGet
Bloc
k
(
uint8_t
*
p
,
void
*
ph
);
// S
DataBl
k
void
tBlockReset
(
S
DataBl
k
*
pBlock
);
int32_t
tPut
DataBl
k
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGet
DataBl
k
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tBlockCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
bool
tBlockHasSma
(
S
Bloc
k
*
pBlock
);
bool
tBlockHasSma
(
S
DataBl
k
*
pBlock
);
// SSstBlk
int32_t
tPutSstBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetSstBlk
(
uint8_t
*
p
,
void
*
ph
);
...
...
@@ -265,8 +265,8 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader);
int32_t
tsdbReadBlockIdx
(
SDataFReader
*
pReader
,
SArray
*
aBlockIdx
);
int32_t
tsdbReadBlock
(
SDataFReader
*
pReader
,
SBlockIdx
*
pBlockIdx
,
SMapData
*
pMapData
);
int32_t
tsdbReadSstBlk
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SArray
*
aSstBlk
);
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
S
Bloc
k
*
pBlock
,
SArray
*
aColumnDataAgg
);
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
S
Bloc
k
*
pBlock
,
SBlockData
*
pBlockData
);
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
S
DataBl
k
*
pBlock
,
SArray
*
aColumnDataAgg
);
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
S
DataBl
k
*
pBlock
,
SBlockData
*
pBlockData
);
int32_t
tsdbReadSstBlock
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SSstBlk
*
pSstBlk
,
SBlockData
*
pBlockData
);
// SDelFWriter
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
);
...
...
@@ -427,7 +427,7 @@ struct SSmaInfo {
int32_t
size
;
};
struct
S
Bloc
k
{
struct
S
DataBl
k
{
TSDBKEY
minKey
;
TSDBKEY
maxKey
;
int64_t
minVer
;
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
aec4297e
...
...
@@ -527,7 +527,7 @@ typedef struct SFSNextRowIter {
SMapData
blockMap
;
int32_t
nBlock
;
int32_t
iBlock
;
S
Block
block
;
S
DataBlk
block
;
SBlockData
blockData
;
SBlockData
*
pBlockData
;
int32_t
nRow
;
...
...
@@ -602,13 +602,13 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
}
case
SFSNEXTROW_BLOCKDATA
:
if
(
state
->
iBlock
>=
0
)
{
S
Bloc
k
block
=
{
0
};
S
DataBl
k
block
=
{
0
};
tBlockReset
(
&
block
);
// tBlockDataReset(&state->blockData);
tBlockDataReset
(
state
->
pBlockData
);
tMapDataGetItemByIdx
(
&
state
->
blockMap
,
state
->
iBlock
,
&
block
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
state
->
blockMap
,
state
->
iBlock
,
&
block
,
tGet
DataBl
k
);
/* code = tsdbReadBlockData(state->pDataFReader, &state->blockIdx, &block, &state->blockData, NULL, NULL); */
tBlockDataReset
(
state
->
pBlockData
);
code
=
tBlockDataInit
(
state
->
pBlockData
,
state
->
suid
,
state
->
uid
,
state
->
pTSchema
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
aec4297e
...
...
@@ -64,7 +64,7 @@ typedef struct {
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
int32_t
iBlockIdx
;
SBlockIdx
*
pBlockIdx
;
SMapData
mBlock
;
// SMapData<S
Bloc
k>
SMapData
mBlock
;
// SMapData<S
DataBl
k>
SBlockData
bData
;
}
dReader
;
struct
{
...
...
@@ -78,7 +78,7 @@ typedef struct {
SDataFWriter
*
pWriter
;
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
SArray
*
aSstBlk
;
// SArray<SSstBlk>
SMapData
mBlock
;
// SMapData<S
Bloc
k>
SMapData
mBlock
;
// SMapData<S
DataBl
k>
SBlockData
bData
;
SBlockData
bDatal
;
}
dWriter
;
...
...
@@ -562,7 +562,7 @@ _err:
static
int32_t
tsdbCommitDataBlock
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bData
;
S
Block
block
;
S
DataBlk
block
;
ASSERT
(
pBlockData
->
nRow
>
0
);
...
...
@@ -597,8 +597,8 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter) {
((
block
.
nSubBlock
==
1
)
&&
!
block
.
hasDup
)
?
&
block
.
smaInfo
:
NULL
,
pCommitter
->
cmprAlg
,
0
);
if
(
code
)
goto
_err
;
// put S
Bloc
k
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
&
block
,
tPut
Bloc
k
);
// put S
DataBl
k
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
&
block
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
// clear
...
...
@@ -1098,7 +1098,7 @@ _exit:
return
code
;
}
static
int32_t
tsdbCommitAheadBlock
(
SCommitter
*
pCommitter
,
S
Block
*
pBloc
k
)
{
static
int32_t
tsdbCommitAheadBlock
(
SCommitter
*
pCommitter
,
S
DataBlk
*
pDataBl
k
)
{
int32_t
code
=
0
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bData
;
SRowInfo
*
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
...
...
@@ -1122,7 +1122,7 @@ static int32_t tsdbCommitAheadBlock(SCommitter *pCommitter, SBlock *pBlock) {
pRowInfo
=
NULL
;
}
else
{
TSDBKEY
tKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
);
if
(
tsdbKeyCmprFn
(
&
tKey
,
&
p
Bloc
k
->
minKey
)
>=
0
)
pRowInfo
=
NULL
;
if
(
tsdbKeyCmprFn
(
&
tKey
,
&
p
DataBl
k
->
minKey
)
>=
0
)
pRowInfo
=
NULL
;
}
}
...
...
@@ -1144,14 +1144,14 @@ _err:
return
code
;
}
static
int32_t
tsdbCommitMergeBlock
(
SCommitter
*
pCommitter
,
S
Block
*
pBloc
k
)
{
static
int32_t
tsdbCommitMergeBlock
(
SCommitter
*
pCommitter
,
S
DataBlk
*
pDataBl
k
)
{
int32_t
code
=
0
;
SRowInfo
*
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
TABLEID
id
=
{.
suid
=
pRowInfo
->
suid
,
.
uid
=
pRowInfo
->
uid
};
SBlockData
*
pBDataR
=
&
pCommitter
->
dReader
.
bData
;
SBlockData
*
pBDataW
=
&
pCommitter
->
dWriter
.
bData
;
code
=
tsdbReadDataBlock
(
pCommitter
->
dReader
.
pReader
,
p
Bloc
k
,
pBDataR
);
code
=
tsdbReadDataBlock
(
pCommitter
->
dReader
.
pReader
,
p
DataBl
k
,
pBDataR
);
if
(
code
)
goto
_err
;
tBlockDataClear
(
pBDataW
);
...
...
@@ -1188,7 +1188,7 @@ static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SBlock *pBlock) {
pRowInfo
=
NULL
;
}
else
{
TSDBKEY
tKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
);
if
(
tsdbKeyCmprFn
(
&
tKey
,
&
p
Bloc
k
->
maxKey
)
>
0
)
pRowInfo
=
NULL
;
if
(
tsdbKeyCmprFn
(
&
tKey
,
&
p
DataBl
k
->
maxKey
)
>
0
)
pRowInfo
=
NULL
;
}
}
}
else
{
...
...
@@ -1237,57 +1237,57 @@ static int32_t tsdbMergeTableData(SCommitter *pCommitter, TABLEID id) {
ASSERT
(
pBlockIdx
==
NULL
||
tTABLEIDCmprFn
(
pBlockIdx
,
&
id
)
>=
0
);
if
(
pBlockIdx
&&
pBlockIdx
->
suid
==
id
.
suid
&&
pBlockIdx
->
uid
==
id
.
uid
)
{
int32_t
iBlock
=
0
;
S
Block
block
;
S
Block
*
pBloc
k
=
&
block
;
S
DataBlk
block
;
S
DataBlk
*
pDataBl
k
=
&
block
;
SRowInfo
*
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
ASSERT
(
pRowInfo
->
suid
==
id
.
suid
&&
pRowInfo
->
uid
==
id
.
uid
);
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
Block
,
tGetBloc
k
);
while
(
p
Bloc
k
&&
pRowInfo
)
{
S
Block
tBlock
=
{.
minKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
),
.
maxKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
)};
int32_t
c
=
tBlockCmprFn
(
pBloc
k
,
&
tBlock
);
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
DataBlk
,
tGetDataBl
k
);
while
(
p
DataBl
k
&&
pRowInfo
)
{
S
DataBlk
tBlock
=
{.
minKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
),
.
maxKey
=
TSDBROW_KEY
(
&
pRowInfo
->
row
)};
int32_t
c
=
tBlockCmprFn
(
pDataBl
k
,
&
tBlock
);
if
(
c
<
0
)
{
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
p
Block
,
tPutBloc
k
);
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
p
DataBlk
,
tPutDataBl
k
);
if
(
code
)
goto
_err
;
iBlock
++
;
if
(
iBlock
<
pCommitter
->
dReader
.
mBlock
.
nItem
)
{
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
Block
,
tGetBloc
k
);
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
DataBlk
,
tGetDataBl
k
);
}
else
{
p
Bloc
k
=
NULL
;
p
DataBl
k
=
NULL
;
}
}
else
if
(
c
>
0
)
{
code
=
tsdbCommitAheadBlock
(
pCommitter
,
p
Bloc
k
);
code
=
tsdbCommitAheadBlock
(
pCommitter
,
p
DataBl
k
);
if
(
code
)
goto
_err
;
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
if
(
pRowInfo
&&
(
pRowInfo
->
suid
!=
id
.
suid
||
pRowInfo
->
uid
!=
id
.
uid
))
pRowInfo
=
NULL
;
}
else
{
code
=
tsdbCommitMergeBlock
(
pCommitter
,
p
Bloc
k
);
code
=
tsdbCommitMergeBlock
(
pCommitter
,
p
DataBl
k
);
if
(
code
)
goto
_err
;
iBlock
++
;
if
(
iBlock
<
pCommitter
->
dReader
.
mBlock
.
nItem
)
{
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
Block
,
tGetBloc
k
);
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
DataBlk
,
tGetDataBl
k
);
}
else
{
p
Bloc
k
=
NULL
;
p
DataBl
k
=
NULL
;
}
pRowInfo
=
tsdbGetCommitRow
(
pCommitter
);
if
(
pRowInfo
&&
(
pRowInfo
->
suid
!=
id
.
suid
||
pRowInfo
->
uid
!=
id
.
uid
))
pRowInfo
=
NULL
;
}
}
while
(
p
Bloc
k
)
{
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
p
Block
,
tPutBloc
k
);
while
(
p
DataBl
k
)
{
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBlock
,
p
DataBlk
,
tPutDataBl
k
);
if
(
code
)
goto
_err
;
iBlock
++
;
if
(
iBlock
<
pCommitter
->
dReader
.
mBlock
.
nItem
)
{
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
Block
,
tGetBloc
k
);
tMapDataGetItemByIdx
(
&
pCommitter
->
dReader
.
mBlock
,
iBlock
,
p
DataBlk
,
tGetDataBl
k
);
}
else
{
p
Bloc
k
=
NULL
;
p
DataBl
k
=
NULL
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
aec4297e
...
...
@@ -109,7 +109,7 @@ typedef struct SDataBlockIter {
int32_t
index
;
SArray
*
blockList
;
// SArray<SFileDataBlockInfo>
int32_t
order
;
S
Block
block
;
// current SBloc
k data
S
DataBlk
block
;
// current SDataBl
k data
SHashObj
*
pTableMap
;
}
SDataBlockIter
;
...
...
@@ -590,8 +590,8 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
sizeInDisk
+=
pScanInfo
->
mapData
.
nData
;
for
(
int32_t
j
=
0
;
j
<
pScanInfo
->
mapData
.
nItem
;
++
j
)
{
S
Bloc
k
block
=
{
0
};
tMapDataGetItemByIdx
(
&
pScanInfo
->
mapData
,
j
,
&
block
,
tGet
Bloc
k
);
S
DataBl
k
block
=
{
0
};
tMapDataGetItemByIdx
(
&
pScanInfo
->
mapData
,
j
,
&
block
,
tGet
DataBl
k
);
// 1. time range check
if
(
block
.
minKey
.
ts
>
pReader
->
window
.
ekey
||
block
.
maxKey
.
ts
<
pReader
->
window
.
skey
)
{
...
...
@@ -665,7 +665,7 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
return
pBlockInfo
;
}
static
S
Bloc
k
*
getCurrentBlock
(
SDataBlockIter
*
pBlockIter
)
{
return
&
pBlockIter
->
block
;
}
static
S
DataBl
k
*
getCurrentBlock
(
SDataBlockIter
*
pBlockIter
)
{
return
&
pBlockIter
->
block
;
}
static
int32_t
copyBlockDataToSDataBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
...
...
@@ -673,7 +673,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
SBlockData
*
pBlockData
=
&
pStatus
->
fileBlockData
;
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
pBlockIter
);
S
Block
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
S
DataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SSDataBlock
*
pResBlock
=
pReader
->
pResBlock
;
int32_t
numOfOutputCols
=
blockDataGetNumOfCols
(
pResBlock
);
...
...
@@ -758,8 +758,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
ASSERT
(
pBlockInfo
!=
NULL
);
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
int32_t
code
=
tsdbReadDataBlock
(
pReader
->
pFileReader
,
pBlock
,
pBlockData
);
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
int32_t
code
=
tsdbReadDataBlock
(
pReader
->
pFileReader
,
pBlock
,
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"
,
...
...
@@ -836,7 +836,7 @@ static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) {
if
(
pBlockInfo
!=
NULL
)
{
STableBlockScanInfo
*
pScanInfo
=
taosHashGet
(
pBlockIter
->
pTableMap
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
));
int32_t
*
mapDataIndex
=
taosArrayGet
(
pScanInfo
->
pBlockList
,
pBlockInfo
->
tbBlockIdx
);
tMapDataGetItemByIdx
(
&
pScanInfo
->
mapData
,
*
mapDataIndex
,
&
pBlockIter
->
block
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
pScanInfo
->
mapData
,
*
mapDataIndex
,
&
pBlockIter
->
block
,
tGet
DataBl
k
);
}
#if 0
...
...
@@ -887,12 +887,12 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
}
sup
.
pDataBlockInfo
[
sup
.
numOfTables
]
=
(
SBlockOrderWrapper
*
)
buf
;
S
Bloc
k
block
=
{
0
};
S
DataBl
k
block
=
{
0
};
for
(
int32_t
k
=
0
;
k
<
num
;
++
k
)
{
SBlockOrderWrapper
wrapper
=
{
0
};
int32_t
*
mapDataIndex
=
taosArrayGet
(
pTableScanInfo
->
pBlockList
,
k
);
tMapDataGetItemByIdx
(
&
pTableScanInfo
->
mapData
,
*
mapDataIndex
,
&
block
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
pTableScanInfo
->
mapData
,
*
mapDataIndex
,
&
block
,
tGet
DataBl
k
);
wrapper
.
uid
=
pTableScanInfo
->
uid
;
wrapper
.
offset
=
block
.
aSubBlock
[
0
].
offset
;
...
...
@@ -981,15 +981,15 @@ static bool blockIteratorNext(SDataBlockIter* pBlockIter) {
/**
* This is an two rectangles overlap cases.
*/
static
int32_t
dataBlockPartiallyRequired
(
STimeWindow
*
pWindow
,
SVersionRange
*
pVerRange
,
S
Bloc
k
*
pBlock
)
{
static
int32_t
dataBlockPartiallyRequired
(
STimeWindow
*
pWindow
,
SVersionRange
*
pVerRange
,
S
DataBl
k
*
pBlock
)
{
return
(
pWindow
->
ekey
<
pBlock
->
maxKey
.
ts
&&
pWindow
->
ekey
>=
pBlock
->
minKey
.
ts
)
||
(
pWindow
->
skey
>
pBlock
->
minKey
.
ts
&&
pWindow
->
skey
<=
pBlock
->
maxKey
.
ts
)
||
(
pVerRange
->
minVer
>
pBlock
->
minVer
&&
pVerRange
->
minVer
<=
pBlock
->
maxVer
)
||
(
pVerRange
->
maxVer
<
pBlock
->
maxVer
&&
pVerRange
->
maxVer
>=
pBlock
->
minVer
);
}
static
S
Bloc
k
*
getNeighborBlockOfSameTable
(
SFileDataBlockInfo
*
pFBlockInfo
,
STableBlockScanInfo
*
pTableBlockScanInfo
,
int32_t
*
nextIndex
,
int32_t
order
)
{
static
S
DataBl
k
*
getNeighborBlockOfSameTable
(
SFileDataBlockInfo
*
pFBlockInfo
,
STableBlockScanInfo
*
pTableBlockScanInfo
,
int32_t
*
nextIndex
,
int32_t
order
)
{
bool
asc
=
ASCENDING_TRAVERSE
(
order
);
if
(
asc
&&
pFBlockInfo
->
tbBlockIdx
>=
taosArrayGetSize
(
pTableBlockScanInfo
->
pBlockList
)
-
1
)
{
return
NULL
;
...
...
@@ -1002,10 +1002,10 @@ static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STab
int32_t
step
=
asc
?
1
:
-
1
;
*
nextIndex
=
pFBlockInfo
->
tbBlockIdx
+
step
;
S
Block
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SBloc
k
));
int32_t
*
indexInMapdata
=
taosArrayGet
(
pTableBlockScanInfo
->
pBlockList
,
*
nextIndex
);
S
DataBlk
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SDataBl
k
));
int32_t
*
indexInMapdata
=
taosArrayGet
(
pTableBlockScanInfo
->
pBlockList
,
*
nextIndex
);
tMapDataGetItemByIdx
(
&
pTableBlockScanInfo
->
mapData
,
*
indexInMapdata
,
pBlock
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
pTableBlockScanInfo
->
mapData
,
*
indexInMapdata
,
pBlock
,
tGet
DataBl
k
);
return
pBlock
;
}
...
...
@@ -1048,7 +1048,7 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t
return
TSDB_CODE_SUCCESS
;
}
static
bool
overlapWithNeighborBlock
(
S
Block
*
pBlock
,
SBloc
k
*
pNeighbor
,
int32_t
order
)
{
static
bool
overlapWithNeighborBlock
(
S
DataBlk
*
pBlock
,
SDataBl
k
*
pNeighbor
,
int32_t
order
)
{
// it is the last block in current file, no chance to overlap with neighbor blocks.
if
(
ASCENDING_TRAVERSE
(
order
))
{
return
pBlock
->
maxKey
.
ts
==
pNeighbor
->
minKey
.
ts
;
...
...
@@ -1057,19 +1057,19 @@ static bool overlapWithNeighborBlock(SBlock* pBlock, SBlock* pNeighbor, int32_t
}
}
static
bool
bufferDataInFileBlockGap
(
int32_t
order
,
TSDBKEY
key
,
S
Bloc
k
*
pBlock
)
{
static
bool
bufferDataInFileBlockGap
(
int32_t
order
,
TSDBKEY
key
,
S
DataBl
k
*
pBlock
)
{
bool
ascScan
=
ASCENDING_TRAVERSE
(
order
);
return
(
ascScan
&&
(
key
.
ts
!=
TSKEY_INITIAL_VAL
&&
key
.
ts
<=
pBlock
->
minKey
.
ts
))
||
(
!
ascScan
&&
(
key
.
ts
!=
TSKEY_INITIAL_VAL
&&
key
.
ts
>=
pBlock
->
maxKey
.
ts
));
}
static
bool
keyOverlapFileBlock
(
TSDBKEY
key
,
S
Bloc
k
*
pBlock
,
SVersionRange
*
pVerRange
)
{
static
bool
keyOverlapFileBlock
(
TSDBKEY
key
,
S
DataBl
k
*
pBlock
,
SVersionRange
*
pVerRange
)
{
return
(
key
.
ts
>=
pBlock
->
minKey
.
ts
&&
key
.
ts
<=
pBlock
->
maxKey
.
ts
)
&&
(
pBlock
->
maxVer
>=
pVerRange
->
minVer
)
&&
(
pBlock
->
minVer
<=
pVerRange
->
maxVer
);
}
static
bool
doCheckforDatablockOverlap
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
S
Bloc
k
*
pBlock
)
{
static
bool
doCheckforDatablockOverlap
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
S
DataBl
k
*
pBlock
)
{
size_t
num
=
taosArrayGetSize
(
pBlockScanInfo
->
delSkyline
);
for
(
int32_t
i
=
pBlockScanInfo
->
fileDelIndex
;
i
<
num
;
i
+=
1
)
{
...
...
@@ -1103,7 +1103,7 @@ static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, cons
return
false
;
}
static
bool
overlapWithDelSkyline
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
S
Bloc
k
*
pBlock
,
int32_t
order
)
{
static
bool
overlapWithDelSkyline
(
STableBlockScanInfo
*
pBlockScanInfo
,
const
S
DataBl
k
*
pBlock
,
int32_t
order
)
{
if
(
pBlockScanInfo
->
delSkyline
==
NULL
)
{
return
false
;
}
...
...
@@ -1138,10 +1138,10 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBl
// 3. current timestamp should not be overlap with each other
// 4. output buffer should be large enough to hold all rows in current block
// 5. delete info should not overlap with current block data
static
bool
fileBlockShouldLoad
(
STsdbReader
*
pReader
,
SFileDataBlockInfo
*
pFBlock
,
S
Bloc
k
*
pBlock
,
static
bool
fileBlockShouldLoad
(
STsdbReader
*
pReader
,
SFileDataBlockInfo
*
pFBlock
,
S
DataBl
k
*
pBlock
,
STableBlockScanInfo
*
pScanInfo
,
TSDBKEY
key
,
SLastBlockReader
*
pLastBlockReader
)
{
int32_t
neighborIndex
=
0
;
S
Bloc
k
*
pNeighbor
=
getNeighborBlockOfSameTable
(
pFBlock
,
pScanInfo
,
&
neighborIndex
,
pReader
->
order
);
int32_t
neighborIndex
=
0
;
S
DataBl
k
*
pNeighbor
=
getNeighborBlockOfSameTable
(
pFBlock
,
pScanInfo
,
&
neighborIndex
,
pReader
->
order
);
// overlap with neighbor
bool
overlapWithNeighbor
=
false
;
...
...
@@ -1948,7 +1948,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
pDumpInfo
->
rowIndex
+=
step
;
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
if
(
pDumpInfo
->
rowIndex
>=
pBlock
->
nRow
||
pDumpInfo
->
rowIndex
<
0
)
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
break
;
...
...
@@ -1967,7 +1967,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
// currently loaded file data block is consumed
if
((
pBlockData
->
nRow
>
0
)
&&
(
pDumpInfo
->
rowIndex
>=
pBlockData
->
nRow
||
pDumpInfo
->
rowIndex
<
0
))
{
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
break
;
}
...
...
@@ -2320,8 +2320,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
}
static
int32_t
doBuildDataBlock
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
S
Bloc
k
*
pBlock
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
S
DataBl
k
*
pBlock
=
NULL
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
...
...
@@ -2418,7 +2418,7 @@ 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
)
{
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
...
...
@@ -2789,7 +2789,7 @@ typedef enum {
CHECK_FILEBLOCK_QUIT
=
0x2
,
}
CHECK_FILEBLOCK_STATE
;
static
int32_t
checkForNeighborFileBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pScanInfo
,
S
Bloc
k
*
pBlock
,
static
int32_t
checkForNeighborFileBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pScanInfo
,
S
DataBl
k
*
pBlock
,
SFileDataBlockInfo
*
pFBlock
,
SRowMerger
*
pMerger
,
int64_t
key
,
CHECK_FILEBLOCK_STATE
*
state
)
{
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
...
...
@@ -2798,8 +2798,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
*
state
=
CHECK_FILEBLOCK_QUIT
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
1
:
-
1
;
int32_t
nextIndex
=
-
1
;
S
Bloc
k
*
pNeighborBlock
=
getNeighborBlockOfSameTable
(
pFBlock
,
pScanInfo
,
&
nextIndex
,
pReader
->
order
);
int32_t
nextIndex
=
-
1
;
S
DataBl
k
*
pNeighborBlock
=
getNeighborBlockOfSameTable
(
pFBlock
,
pScanInfo
,
&
nextIndex
,
pReader
->
order
);
if
(
pNeighborBlock
==
NULL
)
{
// do nothing
return
0
;
}
...
...
@@ -2863,7 +2863,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
CHECK_FILEBLOCK_STATE
st
;
SFileDataBlockInfo
*
pFileBlockInfo
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
S
Block
*
pCurrentBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
S
DataBlk
*
pCurrentBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
checkForNeighborFileBlock
(
pReader
,
pScanInfo
,
pCurrentBlock
,
pFileBlockInfo
,
pMerger
,
key
,
&
st
);
if
(
st
==
CHECK_FILEBLOCK_QUIT
)
{
break
;
...
...
@@ -3447,8 +3447,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
int64_t
stime
=
taosGetTimestampUs
();
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
int64_t
stime
=
taosGetTimestampUs
();
SBlockLoadSuppInfo
*
pSup
=
&
pReader
->
suppInfo
;
...
...
@@ -3629,7 +3629,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
while
(
true
)
{
if
(
hasNext
)
{
S
Bloc
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
S
DataBl
k
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
int32_t
numOfRows
=
pBlock
->
nRow
;
pTableBlockInfo
->
totalRows
+=
numOfRows
;
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
aec4297e
...
...
@@ -677,9 +677,9 @@ _err:
return
code
;
}
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
S
Block
*
pBloc
k
,
SArray
*
aColumnDataAgg
)
{
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
S
DataBlk
*
pDataBl
k
,
SArray
*
aColumnDataAgg
)
{
int32_t
code
=
0
;
SSmaInfo
*
pSmaInfo
=
&
p
Bloc
k
->
smaInfo
;
SSmaInfo
*
pSmaInfo
=
&
p
DataBl
k
->
smaInfo
;
ASSERT
(
pSmaInfo
->
size
>
0
);
...
...
@@ -843,13 +843,13 @@ _err:
return
code
;
}
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
S
Block
*
pBloc
k
,
SBlockData
*
pBlockData
)
{
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
S
DataBlk
*
pDataBl
k
,
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
code
=
tsdbReadBlockDataImpl
(
pReader
,
&
p
Bloc
k
->
aSubBlock
[
0
],
0
,
pBlockData
);
code
=
tsdbReadBlockDataImpl
(
pReader
,
&
p
DataBl
k
->
aSubBlock
[
0
],
0
,
pBlockData
);
if
(
code
)
goto
_err
;
if
(
p
Bloc
k
->
nSubBlock
>
1
)
{
if
(
p
DataBl
k
->
nSubBlock
>
1
)
{
SBlockData
bData1
;
SBlockData
bData2
;
...
...
@@ -863,8 +863,8 @@ int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBl
tBlockDataInitEx
(
&
bData1
,
pBlockData
);
tBlockDataInitEx
(
&
bData2
,
pBlockData
);
for
(
int32_t
iSubBlock
=
1
;
iSubBlock
<
p
Bloc
k
->
nSubBlock
;
iSubBlock
++
)
{
code
=
tsdbReadBlockDataImpl
(
pReader
,
&
p
Bloc
k
->
aSubBlock
[
iSubBlock
],
0
,
&
bData1
);
for
(
int32_t
iSubBlock
=
1
;
iSubBlock
<
p
DataBl
k
->
nSubBlock
;
iSubBlock
++
)
{
code
=
tsdbReadBlockDataImpl
(
pReader
,
&
p
DataBl
k
->
aSubBlock
[
iSubBlock
],
0
,
&
bData1
);
if
(
code
)
{
tBlockDataDestroy
(
&
bData1
,
1
);
tBlockDataDestroy
(
&
bData2
,
1
);
...
...
@@ -1355,28 +1355,28 @@ _err:
return
code
;
}
static
void
tsdbUpdateBlockInfo
(
SBlockData
*
pBlockData
,
S
Block
*
pBloc
k
)
{
static
void
tsdbUpdateBlockInfo
(
SBlockData
*
pBlockData
,
S
DataBlk
*
pDataBl
k
)
{
for
(
int32_t
iRow
=
0
;
iRow
<
pBlockData
->
nRow
;
iRow
++
)
{
TSDBKEY
key
=
{.
ts
=
pBlockData
->
aTSKEY
[
iRow
],
.
version
=
pBlockData
->
aVersion
[
iRow
]};
if
(
iRow
==
0
)
{
if
(
tsdbKeyCmprFn
(
&
p
Bloc
k
->
minKey
,
&
key
)
>
0
)
{
p
Bloc
k
->
minKey
=
key
;
if
(
tsdbKeyCmprFn
(
&
p
DataBl
k
->
minKey
,
&
key
)
>
0
)
{
p
DataBl
k
->
minKey
=
key
;
}
}
else
{
if
(
pBlockData
->
aTSKEY
[
iRow
]
==
pBlockData
->
aTSKEY
[
iRow
-
1
])
{
p
Bloc
k
->
hasDup
=
1
;
p
DataBl
k
->
hasDup
=
1
;
}
}
if
(
iRow
==
pBlockData
->
nRow
-
1
&&
tsdbKeyCmprFn
(
&
p
Bloc
k
->
maxKey
,
&
key
)
<
0
)
{
p
Bloc
k
->
maxKey
=
key
;
if
(
iRow
==
pBlockData
->
nRow
-
1
&&
tsdbKeyCmprFn
(
&
p
DataBl
k
->
maxKey
,
&
key
)
<
0
)
{
p
DataBl
k
->
maxKey
=
key
;
}
p
Block
->
minVer
=
TMIN
(
pBloc
k
->
minVer
,
key
.
version
);
p
Block
->
maxVer
=
TMAX
(
pBloc
k
->
maxVer
,
key
.
version
);
p
DataBlk
->
minVer
=
TMIN
(
pDataBl
k
->
minVer
,
key
.
version
);
p
DataBlk
->
maxVer
=
TMAX
(
pDataBl
k
->
maxVer
,
key
.
version
);
}
p
Bloc
k
->
nRow
+=
pBlockData
->
nRow
;
p
DataBl
k
->
nRow
+=
pBlockData
->
nRow
;
}
static
int32_t
tsdbWriteBlockSma
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SSmaInfo
*
pSmaInfo
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
aec4297e
...
...
@@ -33,7 +33,7 @@ struct STsdbSnapReader {
int32_t
iBlockIdx
;
int32_t
iBlockL
;
SMapData
mBlock
;
// SMapData<S
Bloc
k>
SMapData
mBlock
;
// SMapData<S
DataBl
k>
int32_t
iBlock
;
SBlockData
oBlockData
;
SBlockData
nBlockData
;
...
...
@@ -115,8 +115,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
// }
}
else
if
(
pReader
->
pBlockIdx
)
{
while
(
pReader
->
iBlock
<
pReader
->
mBlock
.
nItem
)
{
S
Bloc
k
block
;
tMapDataGetItemByIdx
(
&
pReader
->
mBlock
,
pReader
->
iBlock
,
&
block
,
tGet
Bloc
k
);
S
DataBl
k
block
;
tMapDataGetItemByIdx
(
&
pReader
->
mBlock
,
pReader
->
iBlock
,
&
block
,
tGet
DataBl
k
);
if
(
block
.
minVer
<=
pReader
->
ever
&&
block
.
maxVer
>=
pReader
->
sver
)
{
// load data (todo)
...
...
@@ -426,7 +426,7 @@ struct STsdbSnapWriter {
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
int32_t
iBlockIdx
;
SBlockIdx
*
pBlockIdx
;
SMapData
mBlock
;
// SMapData<S
Bloc
k>
SMapData
mBlock
;
// SMapData<S
DataBl
k>
int32_t
iBlock
;
SBlockData
*
pBlockData
;
int32_t
iRow
;
...
...
@@ -437,11 +437,11 @@ struct STsdbSnapWriter {
SDataFWriter
*
pDataFWriter
;
SBlockIdx
*
pBlockIdxW
;
// NULL when no committing table
S
Block
blockW
;
S
DataBlk
blockW
;
SBlockData
bDataW
;
SBlockIdx
blockIdxW
;
SMapData
mBlockW
;
// SMapData<S
Bloc
k>
SMapData
mBlockW
;
// SMapData<S
DataBl
k>
SArray
*
aBlockIdxW
;
// SArray<SBlockIdx>
SArray
*
aBlockLW
;
// SArray<SSstBlk>
...
...
@@ -475,7 +475,7 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
// &pWriter->blockW, pWriter->cmprAlg);
if
(
code
)
goto
_err
;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
tBlockReset
(
&
pWriter
->
blockW
);
...
...
@@ -499,15 +499,15 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
// &pWriter->blockW, pWriter->cmprAlg);
// if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
}
while
(
true
)
{
if
(
pWriter
->
iBlock
>=
pWriter
->
mBlock
.
nItem
)
break
;
S
Bloc
k
block
;
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGet
Bloc
k
);
S
DataBl
k
block
;
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGet
DataBl
k
);
// if (block.last) {
// code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
...
...
@@ -520,13 +520,13 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
// if (code) goto _err;
// }
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
pWriter
->
iBlock
++
;
}
// S
Bloc
k
// S
DataBl
k
// code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, NULL, pWriter->pBlockIdxW);
// if (code) goto _err;
...
...
@@ -553,10 +553,10 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p
if
(
code
)
goto
_err
;
// SBlockData
S
Bloc
k
block
;
S
DataBl
k
block
;
tMapDataReset
(
&
pWriter
->
mBlockW
);
for
(
int32_t
iBlock
=
0
;
iBlock
<
pWriter
->
mBlock
.
nItem
;
iBlock
++
)
{
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
iBlock
,
&
block
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
iBlock
,
&
block
,
tGet
DataBl
k
);
// if (block.last) {
// code = tsdbReadBlockData(pWriter->pDataFReader, pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
...
...
@@ -570,11 +570,11 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p
// if (code) goto _err;
// }
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
}
// S
Bloc
k
// S
DataBl
k
SBlockIdx
blockIdx
=
{.
suid
=
pBlockIdx
->
suid
,
.
uid
=
pBlockIdx
->
uid
};
code
=
tsdbWriteBlock
(
pWriter
->
pDataFWriter
,
&
pWriter
->
mBlockW
,
&
blockIdx
);
if
(
code
)
goto
_err
;
...
...
@@ -642,10 +642,10 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
while
(
true
)
{
if
(
pWriter
->
iBlock
>=
pWriter
->
mBlock
.
nItem
)
break
;
S
Block
block
;
int32_t
c
;
S
DataBlk
block
;
int32_t
c
;
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGet
Bloc
k
);
tMapDataGetItemByIdx
(
&
pWriter
->
mBlock
,
pWriter
->
iBlock
,
&
block
,
tGet
DataBl
k
);
// if (block.last) {
// pWriter->pBlockData = &pWriter->bDataR;
...
...
@@ -668,14 +668,14 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
// &pWriter->blockW, pWriter->cmprAlg);
// if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
tBlockReset
(
&
pWriter
->
blockW
);
tBlockDataClear
(
&
pWriter
->
bDataW
);
}
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
block
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
pWriter
->
iBlock
++
;
...
...
@@ -719,7 +719,7 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
// &pWriter->blockW, pWriter->cmprAlg);
// if (code) goto _err;
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
Bloc
k
);
code
=
tMapDataPutItem
(
&
pWriter
->
mBlockW
,
&
pWriter
->
blockW
,
tPut
DataBl
k
);
if
(
code
)
goto
_err
;
tBlockReset
(
&
pWriter
->
blockW
);
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
aec4297e
...
...
@@ -231,69 +231,69 @@ int32_t tCmprBlockL(void const *lhs, void const *rhs) {
return
0
;
}
// S
Bloc
k ======================================================
void
tBlockReset
(
S
Block
*
pBloc
k
)
{
*
p
Block
=
(
SBloc
k
){.
minKey
=
TSDBKEY_MAX
,
.
maxKey
=
TSDBKEY_MIN
,
.
minVer
=
VERSION_MAX
,
.
maxVer
=
VERSION_MIN
};
// S
DataBl
k ======================================================
void
tBlockReset
(
S
DataBlk
*
pDataBl
k
)
{
*
p
DataBlk
=
(
SDataBl
k
){.
minKey
=
TSDBKEY_MAX
,
.
maxKey
=
TSDBKEY_MIN
,
.
minVer
=
VERSION_MAX
,
.
maxVer
=
VERSION_MIN
};
}
int32_t
tPut
Bloc
k
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
S
Block
*
pBlock
=
(
SBloc
k
*
)
ph
;
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
minKey
.
version
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
minKey
.
ts
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
maxKey
.
version
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
maxKey
.
ts
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
minVer
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
maxVer
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
nRow
);
n
+=
tPutI8
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
hasDup
);
n
+=
tPutI8
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
nSubBlock
);
for
(
int8_t
iSubBlock
=
0
;
iSubBlock
<
p
Bloc
k
->
nSubBlock
;
iSubBlock
++
)
{
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
offset
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
szBlock
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
szKey
);
}
if
(
p
Block
->
nSubBlock
==
1
&&
!
pBloc
k
->
hasDup
)
{
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
smaInfo
.
offset
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
Bloc
k
->
smaInfo
.
size
);
int32_t
tPut
DataBl
k
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
S
DataBlk
*
pDataBlk
=
(
SDataBl
k
*
)
ph
;
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
minKey
.
version
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
minKey
.
ts
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
maxKey
.
version
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
maxKey
.
ts
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
minVer
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
maxVer
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
nRow
);
n
+=
tPutI8
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
hasDup
);
n
+=
tPutI8
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
nSubBlock
);
for
(
int8_t
iSubBlock
=
0
;
iSubBlock
<
p
DataBl
k
->
nSubBlock
;
iSubBlock
++
)
{
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
offset
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
szBlock
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
szKey
);
}
if
(
p
DataBlk
->
nSubBlock
==
1
&&
!
pDataBl
k
->
hasDup
)
{
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
smaInfo
.
offset
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
p
DataBl
k
->
smaInfo
.
size
);
}
return
n
;
}
int32_t
tGet
Bloc
k
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
S
Block
*
pBlock
=
(
SBloc
k
*
)
ph
;
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
minKey
.
version
);
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
minKey
.
ts
);
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
maxKey
.
version
);
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
maxKey
.
ts
);
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
minVer
);
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
maxVer
);
n
+=
tGetI32v
(
p
+
n
,
&
p
Bloc
k
->
nRow
);
n
+=
tGetI8
(
p
+
n
,
&
p
Bloc
k
->
hasDup
);
n
+=
tGetI8
(
p
+
n
,
&
p
Bloc
k
->
nSubBlock
);
for
(
int8_t
iSubBlock
=
0
;
iSubBlock
<
p
Bloc
k
->
nSubBlock
;
iSubBlock
++
)
{
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
offset
);
n
+=
tGetI32v
(
p
+
n
,
&
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
szBlock
);
n
+=
tGetI32v
(
p
+
n
,
&
p
Bloc
k
->
aSubBlock
[
iSubBlock
].
szKey
);
}
if
(
p
Block
->
nSubBlock
==
1
&&
!
pBloc
k
->
hasDup
)
{
n
+=
tGetI64v
(
p
+
n
,
&
p
Bloc
k
->
smaInfo
.
offset
);
n
+=
tGetI32v
(
p
+
n
,
&
p
Bloc
k
->
smaInfo
.
size
);
int32_t
tGet
DataBl
k
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
S
DataBlk
*
pDataBlk
=
(
SDataBl
k
*
)
ph
;
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
minKey
.
version
);
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
minKey
.
ts
);
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
maxKey
.
version
);
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
maxKey
.
ts
);
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
minVer
);
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
maxVer
);
n
+=
tGetI32v
(
p
+
n
,
&
p
DataBl
k
->
nRow
);
n
+=
tGetI8
(
p
+
n
,
&
p
DataBl
k
->
hasDup
);
n
+=
tGetI8
(
p
+
n
,
&
p
DataBl
k
->
nSubBlock
);
for
(
int8_t
iSubBlock
=
0
;
iSubBlock
<
p
DataBl
k
->
nSubBlock
;
iSubBlock
++
)
{
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
offset
);
n
+=
tGetI32v
(
p
+
n
,
&
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
szBlock
);
n
+=
tGetI32v
(
p
+
n
,
&
p
DataBl
k
->
aSubBlock
[
iSubBlock
].
szKey
);
}
if
(
p
DataBlk
->
nSubBlock
==
1
&&
!
pDataBl
k
->
hasDup
)
{
n
+=
tGetI64v
(
p
+
n
,
&
p
DataBl
k
->
smaInfo
.
offset
);
n
+=
tGetI32v
(
p
+
n
,
&
p
DataBl
k
->
smaInfo
.
size
);
}
else
{
p
Bloc
k
->
smaInfo
.
offset
=
0
;
p
Bloc
k
->
smaInfo
.
size
=
0
;
p
DataBl
k
->
smaInfo
.
offset
=
0
;
p
DataBl
k
->
smaInfo
.
size
=
0
;
}
return
n
;
}
int32_t
tBlockCmprFn
(
const
void
*
p1
,
const
void
*
p2
)
{
S
Block
*
pBlock1
=
(
SBloc
k
*
)
p1
;
S
Block
*
pBlock2
=
(
SBloc
k
*
)
p2
;
S
DataBlk
*
pBlock1
=
(
SDataBl
k
*
)
p1
;
S
DataBlk
*
pBlock2
=
(
SDataBl
k
*
)
p2
;
if
(
tsdbKeyCmprFn
(
&
pBlock1
->
maxKey
,
&
pBlock2
->
minKey
)
<
0
)
{
return
-
1
;
...
...
@@ -304,11 +304,11 @@ int32_t tBlockCmprFn(const void *p1, const void *p2) {
return
0
;
}
bool
tBlockHasSma
(
S
Block
*
pBloc
k
)
{
if
(
p
Bloc
k
->
nSubBlock
>
1
)
return
false
;
if
(
p
Bloc
k
->
hasDup
)
return
false
;
bool
tBlockHasSma
(
S
DataBlk
*
pDataBl
k
)
{
if
(
p
DataBl
k
->
nSubBlock
>
1
)
return
false
;
if
(
p
DataBl
k
->
hasDup
)
return
false
;
return
p
Bloc
k
->
smaInfo
.
size
>
0
;
return
p
DataBl
k
->
smaInfo
.
size
>
0
;
}
// SSstBlk ======================================================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录