Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d603faa4
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d603faa4
编写于
9月 06, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
9月 06, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16670 from taosdata/3.0
release: build 3.0.1.0
上级
3028934f
f261fe78
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
461 addition
and
454 deletion
+461
-454
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+2
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-0
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+20
-20
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+2
-2
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+5
-1
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+7
-7
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+4
-2
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+47
-47
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+99
-99
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+21
-21
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+68
-46
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+47
-87
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+58
-58
source/dnode/vnode/src/tsdb/tsdbRetention.c
source/dnode/vnode/src/tsdb/tsdbRetention.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+18
-18
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+30
-30
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+7
-2
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+6
-2
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+2
-10
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+2
-0
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+2
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
d603faa4
...
@@ -845,6 +845,8 @@ typedef struct {
...
@@ -845,6 +845,8 @@ typedef struct {
int64_t
uid
;
int64_t
uid
;
int32_t
vgVersion
;
int32_t
vgVersion
;
int32_t
vgNum
;
int32_t
vgNum
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int8_t
hashMethod
;
int8_t
hashMethod
;
SArray
*
pVgroupInfos
;
// Array of SVgroupInfo
SArray
*
pVgroupInfos
;
// Array of SVgroupInfo
}
SUseDbRsp
;
}
SUseDbRsp
;
...
...
include/libs/qcom/query.h
浏览文件 @
d603faa4
...
@@ -116,6 +116,8 @@ typedef struct STableMeta {
...
@@ -116,6 +116,8 @@ typedef struct STableMeta {
typedef
struct
SDBVgInfo
{
typedef
struct
SDBVgInfo
{
int32_t
vgVersion
;
int32_t
vgVersion
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int8_t
hashMethod
;
int8_t
hashMethod
;
int32_t
numOfTable
;
// DB's table num, unit is TSDB_TABLE_NUM_UNIT
int32_t
numOfTable
;
// DB's table num, unit is TSDB_TABLE_NUM_UNIT
SHashObj
*
vgHash
;
// key:vgId, value:SVgroupInfo
SHashObj
*
vgHash
;
// key:vgId, value:SVgroupInfo
...
...
source/client/src/clientHb.c
浏览文件 @
d603faa4
...
@@ -73,6 +73,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -73,6 +73,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
vgInfo
->
vgVersion
=
rsp
->
vgVersion
;
vgInfo
->
vgVersion
=
rsp
->
vgVersion
;
vgInfo
->
hashMethod
=
rsp
->
hashMethod
;
vgInfo
->
hashMethod
=
rsp
->
hashMethod
;
vgInfo
->
hashPrefix
=
rsp
->
hashPrefix
;
vgInfo
->
hashSuffix
=
rsp
->
hashSuffix
;
vgInfo
->
vgHash
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
vgInfo
->
vgHash
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
vgInfo
->
vgHash
)
{
if
(
NULL
==
vgInfo
->
vgHash
)
{
taosMemoryFree
(
vgInfo
);
taosMemoryFree
(
vgInfo
);
...
...
source/common/src/tmsg.c
浏览文件 @
d603faa4
...
@@ -2463,6 +2463,8 @@ int32_t tSerializeSUseDbRspImp(SEncoder *pEncoder, const SUseDbRsp *pRsp) {
...
@@ -2463,6 +2463,8 @@ int32_t tSerializeSUseDbRspImp(SEncoder *pEncoder, const SUseDbRsp *pRsp) {
if
(
tEncodeI64
(
pEncoder
,
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pRsp
->
vgNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
vgNum
;
++
i
)
{
...
@@ -2514,6 +2516,8 @@ int32_t tDeserializeSUseDbRspImp(SDecoder *pDecoder, SUseDbRsp *pRsp) {
...
@@ -2514,6 +2516,8 @@ int32_t tDeserializeSUseDbRspImp(SDecoder *pDecoder, SUseDbRsp *pRsp) {
if
(
tDecodeI64
(
pDecoder
,
&
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
if
(
pRsp
->
vgNum
<=
0
)
{
if
(
pRsp
->
vgNum
<=
0
)
{
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
d603faa4
...
@@ -1171,6 +1171,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
...
@@ -1171,6 +1171,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
pRsp
->
vgVersion
=
pDb
->
vgVersion
;
pRsp
->
vgVersion
=
pDb
->
vgVersion
;
pRsp
->
vgNum
=
taosArrayGetSize
(
pRsp
->
pVgroupInfos
);
pRsp
->
vgNum
=
taosArrayGetSize
(
pRsp
->
pVgroupInfos
);
pRsp
->
hashMethod
=
pDb
->
cfg
.
hashMethod
;
pRsp
->
hashMethod
=
pDb
->
cfg
.
hashMethod
;
pRsp
->
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
pRsp
->
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
return
0
;
return
0
;
}
}
...
@@ -1303,6 +1305,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
...
@@ -1303,6 +1305,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
hashMethod
=
pDb
->
cfg
.
hashMethod
;
usedbRsp
.
hashMethod
=
pDb
->
cfg
.
hashMethod
;
usedbRsp
.
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
usedbRsp
.
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
d603faa4
...
@@ -43,14 +43,14 @@ typedef struct STbDataIter STbDataIter;
...
@@ -43,14 +43,14 @@ typedef struct STbDataIter STbDataIter;
typedef
struct
SMapData
SMapData
;
typedef
struct
SMapData
SMapData
;
typedef
struct
SBlockIdx
SBlockIdx
;
typedef
struct
SBlockIdx
SBlockIdx
;
typedef
struct
SDataBlk
SDataBlk
;
typedef
struct
SDataBlk
SDataBlk
;
typedef
struct
SS
stBlk
SSs
tBlk
;
typedef
struct
SS
ttBlk
SSt
tBlk
;
typedef
struct
SColData
SColData
;
typedef
struct
SColData
SColData
;
typedef
struct
SDiskDataHdr
SDiskDataHdr
;
typedef
struct
SDiskDataHdr
SDiskDataHdr
;
typedef
struct
SBlockData
SBlockData
;
typedef
struct
SBlockData
SBlockData
;
typedef
struct
SDelFile
SDelFile
;
typedef
struct
SDelFile
SDelFile
;
typedef
struct
SHeadFile
SHeadFile
;
typedef
struct
SHeadFile
SHeadFile
;
typedef
struct
SDataFile
SDataFile
;
typedef
struct
SDataFile
SDataFile
;
typedef
struct
SS
stFile
SSs
tFile
;
typedef
struct
SS
ttFile
SSt
tFile
;
typedef
struct
SSmaFile
SSmaFile
;
typedef
struct
SSmaFile
SSmaFile
;
typedef
struct
SDFileSet
SDFileSet
;
typedef
struct
SDFileSet
SDFileSet
;
typedef
struct
SDataFWriter
SDataFWriter
;
typedef
struct
SDataFWriter
SDataFWriter
;
...
@@ -69,8 +69,8 @@ typedef struct SLDataIter SLDataIter;
...
@@ -69,8 +69,8 @@ typedef struct SLDataIter SLDataIter;
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_MAX_S
S
T_FILE 16
#define TSDB_MAX_S
T
T_FILE 16
#define TSDB_DEFAULT_S
S
T_FILE 8
#define TSDB_DEFAULT_S
T
T_FILE 8
#define TSDB_FHDR_SIZE 512
#define TSDB_FHDR_SIZE 512
#define TSDB_DEFAULT_PAGE_SIZE 4096
#define TSDB_DEFAULT_PAGE_SIZE 4096
...
@@ -130,9 +130,9 @@ int32_t tPutDataBlk(uint8_t *p, void *ph);
...
@@ -130,9 +130,9 @@ int32_t tPutDataBlk(uint8_t *p, void *ph);
int32_t
tGetDataBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetDataBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tDataBlkCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tDataBlkCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
bool
tDataBlkHasSma
(
SDataBlk
*
pDataBlk
);
bool
tDataBlkHasSma
(
SDataBlk
*
pDataBlk
);
// SS
s
tBlk
// SS
t
tBlk
int32_t
tPutS
s
tBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tPutS
t
tBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetS
s
tBlk
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetS
t
tBlk
(
uint8_t
*
p
,
void
*
ph
);
// SBlockIdx
// SBlockIdx
int32_t
tPutBlockIdx
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tPutBlockIdx
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetBlockIdx
(
uint8_t
*
p
,
void
*
ph
);
int32_t
tGetBlockIdx
(
uint8_t
*
p
,
void
*
ph
);
...
@@ -228,7 +228,7 @@ bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2);
...
@@ -228,7 +228,7 @@ bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2);
int32_t
tsdbDFileRollback
(
STsdb
*
pTsdb
,
SDFileSet
*
pSet
,
EDataFileT
ftype
);
int32_t
tsdbDFileRollback
(
STsdb
*
pTsdb
,
SDFileSet
*
pSet
,
EDataFileT
ftype
);
int32_t
tPutHeadFile
(
uint8_t
*
p
,
SHeadFile
*
pHeadFile
);
int32_t
tPutHeadFile
(
uint8_t
*
p
,
SHeadFile
*
pHeadFile
);
int32_t
tPutDataFile
(
uint8_t
*
p
,
SDataFile
*
pDataFile
);
int32_t
tPutDataFile
(
uint8_t
*
p
,
SDataFile
*
pDataFile
);
int32_t
tPutS
stFile
(
uint8_t
*
p
,
SSstFile
*
pSs
tFile
);
int32_t
tPutS
ttFile
(
uint8_t
*
p
,
SSttFile
*
pSt
tFile
);
int32_t
tPutSmaFile
(
uint8_t
*
p
,
SSmaFile
*
pSmaFile
);
int32_t
tPutSmaFile
(
uint8_t
*
p
,
SSmaFile
*
pSmaFile
);
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
);
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
);
int32_t
tGetDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
);
int32_t
tGetDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
);
...
@@ -237,7 +237,7 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet);
...
@@ -237,7 +237,7 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet);
void
tsdbHeadFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SHeadFile
*
pHeadF
,
char
fname
[]);
void
tsdbHeadFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SHeadFile
*
pHeadF
,
char
fname
[]);
void
tsdbDataFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SDataFile
*
pDataF
,
char
fname
[]);
void
tsdbDataFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SDataFile
*
pDataF
,
char
fname
[]);
void
tsdbS
stFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSstFile
*
pSs
tF
,
char
fname
[]);
void
tsdbS
ttFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSttFile
*
pSt
tF
,
char
fname
[]);
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSmaFile
*
pSmaF
,
char
fname
[]);
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSmaFile
*
pSmaF
,
char
fname
[]);
// SDelFile
// SDelFile
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[]);
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[]);
...
@@ -263,7 +263,7 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync);
...
@@ -263,7 +263,7 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync);
int32_t
tsdbUpdateDFileSetHeader
(
SDataFWriter
*
pWriter
);
int32_t
tsdbUpdateDFileSetHeader
(
SDataFWriter
*
pWriter
);
int32_t
tsdbWriteBlockIdx
(
SDataFWriter
*
pWriter
,
SArray
*
aBlockIdx
);
int32_t
tsdbWriteBlockIdx
(
SDataFWriter
*
pWriter
,
SArray
*
aBlockIdx
);
int32_t
tsdbWriteBlock
(
SDataFWriter
*
pWriter
,
SMapData
*
pMapData
,
SBlockIdx
*
pBlockIdx
);
int32_t
tsdbWriteBlock
(
SDataFWriter
*
pWriter
,
SMapData
*
pMapData
,
SBlockIdx
*
pBlockIdx
);
int32_t
tsdbWriteS
stBlk
(
SDataFWriter
*
pWriter
,
SArray
*
aSs
tBlk
);
int32_t
tsdbWriteS
ttBlk
(
SDataFWriter
*
pWriter
,
SArray
*
aSt
tBlk
);
int32_t
tsdbWriteBlockData
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SBlockInfo
*
pBlkInfo
,
SSmaInfo
*
pSmaInfo
,
int32_t
tsdbWriteBlockData
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SBlockInfo
*
pBlkInfo
,
SSmaInfo
*
pSmaInfo
,
int8_t
cmprAlg
,
int8_t
toLast
);
int8_t
cmprAlg
,
int8_t
toLast
);
...
@@ -273,10 +273,10 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
...
@@ -273,10 +273,10 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
int32_t
tsdbDataFReaderClose
(
SDataFReader
**
ppReader
);
int32_t
tsdbDataFReaderClose
(
SDataFReader
**
ppReader
);
int32_t
tsdbReadBlockIdx
(
SDataFReader
*
pReader
,
SArray
*
aBlockIdx
);
int32_t
tsdbReadBlockIdx
(
SDataFReader
*
pReader
,
SArray
*
aBlockIdx
);
int32_t
tsdbReadBlock
(
SDataFReader
*
pReader
,
SBlockIdx
*
pBlockIdx
,
SMapData
*
pMapData
);
int32_t
tsdbReadBlock
(
SDataFReader
*
pReader
,
SBlockIdx
*
pBlockIdx
,
SMapData
*
pMapData
);
int32_t
tsdbReadS
stBlk
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SArray
*
aSs
tBlk
);
int32_t
tsdbReadS
ttBlk
(
SDataFReader
*
pReader
,
int32_t
iStt
,
SArray
*
aSt
tBlk
);
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
SDataBlk
*
pBlock
,
SArray
*
aColumnDataAgg
);
int32_t
tsdbReadBlockSma
(
SDataFReader
*
pReader
,
SDataBlk
*
pBlock
,
SArray
*
aColumnDataAgg
);
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
SDataBlk
*
pBlock
,
SBlockData
*
pBlockData
);
int32_t
tsdbReadDataBlock
(
SDataFReader
*
pReader
,
SDataBlk
*
pBlock
,
SBlockData
*
pBlockData
);
int32_t
tsdbReadS
stBlock
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SSstBlk
*
pSs
tBlk
,
SBlockData
*
pBlockData
);
int32_t
tsdbReadS
ttBlock
(
SDataFReader
*
pReader
,
int32_t
iStt
,
SSttBlk
*
pSt
tBlk
,
SBlockData
*
pBlockData
);
// SDelFWriter
// SDelFWriter
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
);
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
);
int32_t
tsdbDelFWriterClose
(
SDelFWriter
**
ppWriter
,
int8_t
sync
);
int32_t
tsdbDelFWriterClose
(
SDelFWriter
**
ppWriter
,
int8_t
sync
);
...
@@ -448,7 +448,7 @@ struct SDataBlk {
...
@@ -448,7 +448,7 @@ struct SDataBlk {
SSmaInfo
smaInfo
;
SSmaInfo
smaInfo
;
};
};
struct
SS
s
tBlk
{
struct
SS
t
tBlk
{
int64_t
suid
;
int64_t
suid
;
int64_t
minUid
;
int64_t
minUid
;
int64_t
maxUid
;
int64_t
maxUid
;
...
@@ -550,7 +550,7 @@ struct SDataFile {
...
@@ -550,7 +550,7 @@ struct SDataFile {
int64_t
size
;
int64_t
size
;
};
};
struct
SS
s
tFile
{
struct
SS
t
tFile
{
volatile
int32_t
nRef
;
volatile
int32_t
nRef
;
int64_t
commitID
;
int64_t
commitID
;
...
@@ -571,8 +571,8 @@ struct SDFileSet {
...
@@ -571,8 +571,8 @@ struct SDFileSet {
SHeadFile
*
pHeadF
;
SHeadFile
*
pHeadF
;
SDataFile
*
pDataF
;
SDataFile
*
pDataF
;
SSmaFile
*
pSmaF
;
SSmaFile
*
pSmaF
;
uint8_t
nS
s
tF
;
uint8_t
nS
t
tF
;
SS
stFile
*
aSstF
[
TSDB_MAX_SS
T_FILE
];
SS
ttFile
*
aSttF
[
TSDB_MAX_ST
T_FILE
];
};
};
struct
SRowIter
{
struct
SRowIter
{
...
@@ -617,12 +617,12 @@ struct SDataFWriter {
...
@@ -617,12 +617,12 @@ struct SDataFWriter {
STsdbFD
*
pHeadFD
;
STsdbFD
*
pHeadFD
;
STsdbFD
*
pDataFD
;
STsdbFD
*
pDataFD
;
STsdbFD
*
pSmaFD
;
STsdbFD
*
pSmaFD
;
STsdbFD
*
pS
s
tFD
;
STsdbFD
*
pS
t
tFD
;
SHeadFile
fHead
;
SHeadFile
fHead
;
SDataFile
fData
;
SDataFile
fData
;
SSmaFile
fSma
;
SSmaFile
fSma
;
SS
stFile
fSst
[
TSDB_MAX_SS
T_FILE
];
SS
ttFile
fStt
[
TSDB_MAX_ST
T_FILE
];
uint8_t
*
aBuf
[
4
];
uint8_t
*
aBuf
[
4
];
};
};
...
@@ -633,7 +633,7 @@ struct SDataFReader {
...
@@ -633,7 +633,7 @@ struct SDataFReader {
STsdbFD
*
pHeadFD
;
STsdbFD
*
pHeadFD
;
STsdbFD
*
pDataFD
;
STsdbFD
*
pDataFD
;
STsdbFD
*
pSmaFD
;
STsdbFD
*
pSmaFD
;
STsdbFD
*
aS
stFD
[
TSDB_MAX_SS
T_FILE
];
STsdbFD
*
aS
ttFD
[
TSDB_MAX_ST
T_FILE
];
uint8_t
*
aBuf
[
3
];
uint8_t
*
aBuf
[
3
];
};
};
...
@@ -650,7 +650,7 @@ typedef struct SMergeTree {
...
@@ -650,7 +650,7 @@ typedef struct SMergeTree {
SLDataIter
*
pIter
;
SLDataIter
*
pIter
;
}
SMergeTree
;
}
SMergeTree
;
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
uid
,
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
);
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
d603faa4
...
@@ -104,7 +104,7 @@ int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq*
...
@@ -104,7 +104,7 @@ int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq*
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
,
SArray
*
tbUidList
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
,
SArray
*
tbUidList
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
,
STableMetaRsp
**
pMetaRsp
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
,
STableMetaRsp
**
pMetaRsp
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
,
int64_t
*
tbUid
);
int
metaTtlDropTable
(
SMeta
*
pMeta
,
int64_t
ttl
,
SArray
*
tbUids
);
int
metaTtlDropTable
(
SMeta
*
pMeta
,
int64_t
ttl
,
SArray
*
tbUids
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
...
@@ -208,7 +208,7 @@ int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
...
@@ -208,7 +208,7 @@ int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
int32_t
tdProcessRSmaSubmit
(
SSma
*
pSma
,
void
*
pMsg
,
int32_t
inputType
);
int32_t
tdProcessRSmaSubmit
(
SSma
*
pSma
,
void
*
pMsg
,
int32_t
inputType
);
int32_t
tdProcessRSmaDrop
(
SSma
*
pSma
,
SVDropStbReq
*
pReq
);
int32_t
tdProcessRSmaDrop
(
SSma
*
pSma
,
SVDropStbReq
*
pReq
);
int32_t
tdFetchTbUidList
(
SSma
*
pSma
,
STbUidStore
**
ppStore
,
tb_uid_t
suid
,
tb_uid_t
uid
);
int32_t
tdFetchTbUidList
(
SSma
*
pSma
,
STbUidStore
**
ppStore
,
tb_uid_t
suid
,
tb_uid_t
uid
);
int32_t
tdUpdateTbUidList
(
SSma
*
pSma
,
STbUidStore
*
pUidStore
);
int32_t
tdUpdateTbUidList
(
SSma
*
pSma
,
STbUidStore
*
pUidStore
,
bool
isAdd
);
void
tdUidStoreDestory
(
STbUidStore
*
pStore
);
void
tdUidStoreDestory
(
STbUidStore
*
pStore
);
void
*
tdUidStoreFree
(
STbUidStore
*
pStore
);
void
*
tdUidStoreFree
(
STbUidStore
*
pStore
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
d603faa4
...
@@ -474,7 +474,7 @@ _err:
...
@@ -474,7 +474,7 @@ _err:
return
-
1
;
return
-
1
;
}
}
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
,
tb_uid_t
*
tbUid
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
...
@@ -496,6 +496,10 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
...
@@ -496,6 +496,10 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
taosArrayPush
(
tbUids
,
&
uid
);
taosArrayPush
(
tbUids
,
&
uid
);
}
}
if
((
type
==
TSDB_CHILD_TABLE
)
&&
tbUid
)
{
*
tbUid
=
uid
;
}
tdbFree
(
pData
);
tdbFree
(
pData
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
d603faa4
...
@@ -34,7 +34,7 @@ typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem;
...
@@ -34,7 +34,7 @@ typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
static
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
,
bool
isAdd
);
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSmaStat
*
pStat
,
SRSmaInfo
*
pRSmaInfo
,
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSmaStat
*
pStat
,
SRSmaInfo
*
pRSmaInfo
,
int8_t
idx
);
int8_t
idx
);
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
msgSize
,
int32_t
inputType
,
SRSmaInfo
*
pInfo
,
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
msgSize
,
int32_t
inputType
,
SRSmaInfo
*
pInfo
,
...
@@ -175,7 +175,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
...
@@ -175,7 +175,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
)
{
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
,
bool
isAdd
)
{
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
if
(
!
suid
||
!
tbUids
)
{
if
(
!
suid
||
!
tbUids
)
{
...
@@ -199,7 +199,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
...
@@ -199,7 +199,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
if
(
pRSmaInfo
->
taskInfo
[
i
])
{
if
(
pRSmaInfo
->
taskInfo
[
i
])
{
if
(((
terrno
=
qUpdateQualifiedTableId
(
pRSmaInfo
->
taskInfo
[
i
],
tbUids
,
true
))
<
0
))
{
if
(((
terrno
=
qUpdateQualifiedTableId
(
pRSmaInfo
->
taskInfo
[
i
],
tbUids
,
isAdd
))
<
0
))
{
tdReleaseRSmaInfo
(
pSma
,
pRSmaInfo
);
tdReleaseRSmaInfo
(
pSma
,
pRSmaInfo
);
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" level %d since %s"
,
SMA_VID
(
pSma
),
*
suid
,
i
,
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" level %d since %s"
,
SMA_VID
(
pSma
),
*
suid
,
i
,
terrstr
());
terrstr
());
...
@@ -215,12 +215,12 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
...
@@ -215,12 +215,12 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tdUpdateTbUidList
(
SSma
*
pSma
,
STbUidStore
*
pStore
)
{
int32_t
tdUpdateTbUidList
(
SSma
*
pSma
,
STbUidStore
*
pStore
,
bool
isAdd
)
{
if
(
!
pStore
||
(
taosArrayGetSize
(
pStore
->
tbUids
)
==
0
))
{
if
(
!
pStore
||
(
taosArrayGetSize
(
pStore
->
tbUids
)
==
0
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
tdUpdateTbUidListImpl
(
pSma
,
&
pStore
->
suid
,
pStore
->
tbUids
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tdUpdateTbUidListImpl
(
pSma
,
&
pStore
->
suid
,
pStore
->
tbUids
,
isAdd
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -229,7 +229,7 @@ int32_t tdUpdateTbUidList(SSma *pSma, STbUidStore *pStore) {
...
@@ -229,7 +229,7 @@ int32_t tdUpdateTbUidList(SSma *pSma, STbUidStore *pStore) {
tb_uid_t
*
pTbSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
tb_uid_t
*
pTbSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
SArray
*
pTbUids
=
*
(
SArray
**
)
pIter
;
SArray
*
pTbUids
=
*
(
SArray
**
)
pIter
;
if
(
tdUpdateTbUidListImpl
(
pSma
,
pTbSuid
,
pTbUids
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tdUpdateTbUidListImpl
(
pSma
,
pTbSuid
,
pTbUids
,
isAdd
)
!=
TSDB_CODE_SUCCESS
)
{
taosHashCancelIterate
(
pStore
->
uidHash
,
pIter
);
taosHashCancelIterate
(
pStore
->
uidHash
,
pIter
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -1118,7 +1118,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) {
...
@@ -1118,7 +1118,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) {
goto
_err
;
goto
_err
;
}
}
if
(
tdUpdateTbUidList
(
pVnode
->
pSma
,
&
uidStore
)
<
0
)
{
if
(
tdUpdateTbUidList
(
pVnode
->
pSma
,
&
uidStore
,
true
)
<
0
)
{
smaError
(
"vgId:%d, rsma restore, update tb uid list failed for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
smaError
(
"vgId:%d, rsma restore, update tb uid list failed for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
terrstr
());
terrstr
());
goto
_err
;
goto
_err
;
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
d603faa4
...
@@ -420,6 +420,7 @@ typedef enum {
...
@@ -420,6 +420,7 @@ typedef enum {
typedef
struct
{
typedef
struct
{
SFSLASTNEXTROWSTATES
state
;
// [input]
SFSLASTNEXTROWSTATES
state
;
// [input]
STsdb
*
pTsdb
;
// [input]
STsdb
*
pTsdb
;
// [input]
tb_uid_t
suid
;
tb_uid_t
uid
;
tb_uid_t
uid
;
int32_t
nFileSet
;
int32_t
nFileSet
;
int32_t
iFileSet
;
int32_t
iFileSet
;
...
@@ -454,7 +455,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
...
@@ -454,7 +455,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
code
=
tsdbDataFReaderOpen
(
&
state
->
pDataFReader
,
state
->
pTsdb
,
pFileSet
);
code
=
tsdbDataFReaderOpen
(
&
state
->
pDataFReader
,
state
->
pTsdb
,
pFileSet
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
tMergeTreeOpen
(
&
state
->
mergeTree
,
1
,
state
->
pDataFReader
,
state
->
uid
,
tMergeTreeOpen
(
&
state
->
mergeTree
,
1
,
state
->
pDataFReader
,
state
->
suid
,
state
->
uid
,
&
(
STimeWindow
){.
skey
=
TSKEY_MIN
,
.
ekey
=
TSKEY_MAX
},
&
(
STimeWindow
){.
skey
=
TSKEY_MIN
,
.
ekey
=
TSKEY_MAX
},
&
(
SVersionRange
){.
minVer
=
0
,
.
maxVer
=
UINT64_MAX
});
&
(
SVersionRange
){.
minVer
=
0
,
.
maxVer
=
UINT64_MAX
});
bool
hasVal
=
tMergeTreeNext
(
&
state
->
mergeTree
);
bool
hasVal
=
tMergeTreeNext
(
&
state
->
mergeTree
);
...
@@ -796,7 +797,7 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) {
...
@@ -796,7 +797,7 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) {
if
(
key
->
ts
>
pItemBack
->
ts
)
{
if
(
key
->
ts
>
pItemBack
->
ts
)
{
return
false
;
return
false
;
}
else
if
(
key
->
ts
>=
pItemFront
->
ts
&&
key
->
ts
<=
pItemBack
->
ts
)
{
}
else
if
(
key
->
ts
>=
pItemFront
->
ts
&&
key
->
ts
<=
pItemBack
->
ts
)
{
if
(
(
key
->
version
<=
pItemFront
->
version
||
key
->
ts
==
pItemBack
->
ts
&&
key
->
version
<=
pItemBack
->
version
))
{
if
(
key
->
version
<=
pItemFront
->
version
||
(
key
->
ts
==
pItemBack
->
ts
&&
key
->
version
<=
pItemBack
->
version
))
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -890,6 +891,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
...
@@ -890,6 +891,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
pIter
->
fsLastState
.
state
=
(
SFSLASTNEXTROWSTATES
)
SFSNEXTROW_FS
;
pIter
->
fsLastState
.
state
=
(
SFSLASTNEXTROWSTATES
)
SFSNEXTROW_FS
;
pIter
->
fsLastState
.
pTsdb
=
pTsdb
;
pIter
->
fsLastState
.
pTsdb
=
pTsdb
;
pIter
->
fsLastState
.
aDFileSet
=
pIter
->
pReadSnap
->
fs
.
aDFileSet
;
pIter
->
fsLastState
.
aDFileSet
=
pIter
->
pReadSnap
->
fs
.
aDFileSet
;
pIter
->
fsLastState
.
suid
=
suid
;
pIter
->
fsLastState
.
uid
=
uid
;
pIter
->
fsLastState
.
uid
=
uid
;
pIter
->
fsState
.
state
=
SFSNEXTROW_FS
;
pIter
->
fsState
.
state
=
SFSNEXTROW_FS
;
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
d603faa4
...
@@ -32,12 +32,12 @@ typedef struct {
...
@@ -32,12 +32,12 @@ typedef struct {
STbDataIter
iter
;
STbDataIter
iter
;
};
// memory data iter
};
// memory data iter
struct
{
struct
{
int32_t
iS
s
t
;
int32_t
iS
t
t
;
SArray
*
aS
s
tBlk
;
SArray
*
aS
t
tBlk
;
int32_t
iS
s
tBlk
;
int32_t
iS
t
tBlk
;
SBlockData
bData
;
SBlockData
bData
;
int32_t
iRow
;
int32_t
iRow
;
};
// s
s
t file data iter
};
// s
t
t file data iter
};
};
}
SDataIter
;
}
SDataIter
;
...
@@ -71,13 +71,13 @@ typedef struct {
...
@@ -71,13 +71,13 @@ typedef struct {
SDataIter
*
pIter
;
SDataIter
*
pIter
;
SRBTree
rbt
;
SRBTree
rbt
;
SDataIter
dataIter
;
SDataIter
dataIter
;
SDataIter
aDataIter
[
TSDB_MAX_S
S
T_FILE
];
SDataIter
aDataIter
[
TSDB_MAX_S
T
T_FILE
];
int8_t
toLastOnly
;
int8_t
toLastOnly
;
};
};
struct
{
struct
{
SDataFWriter
*
pWriter
;
SDataFWriter
*
pWriter
;
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
SArray
*
aS
stBlk
;
// SArray<SSs
tBlk>
SArray
*
aS
ttBlk
;
// SArray<SSt
tBlk>
SMapData
mBlock
;
// SMapData<SDataBlk>
SMapData
mBlock
;
// SMapData<SDataBlk>
SBlockData
bData
;
SBlockData
bData
;
SBlockData
bDatal
;
SBlockData
bDatal
;
...
@@ -428,21 +428,21 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
...
@@ -428,21 +428,21 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
pCommitter
->
toLastOnly
=
0
;
pCommitter
->
toLastOnly
=
0
;
SDataFReader
*
pReader
=
pCommitter
->
dReader
.
pReader
;
SDataFReader
*
pReader
=
pCommitter
->
dReader
.
pReader
;
if
(
pReader
)
{
if
(
pReader
)
{
if
(
pReader
->
pSet
->
nS
s
tF
>=
pCommitter
->
maxLast
)
{
if
(
pReader
->
pSet
->
nS
t
tF
>=
pCommitter
->
maxLast
)
{
int8_t
iIter
=
0
;
int8_t
iIter
=
0
;
for
(
int32_t
iS
st
=
0
;
iSst
<
pReader
->
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pReader
->
pSet
->
nSttF
;
iSt
t
++
)
{
pIter
=
&
pCommitter
->
aDataIter
[
iIter
];
pIter
=
&
pCommitter
->
aDataIter
[
iIter
];
pIter
->
type
=
LAST_DATA_ITER
;
pIter
->
type
=
LAST_DATA_ITER
;
pIter
->
iS
st
=
iSs
t
;
pIter
->
iS
tt
=
iSt
t
;
code
=
tsdbReadS
stBlk
(
pCommitter
->
dReader
.
pReader
,
iSst
,
pIter
->
aSs
tBlk
);
code
=
tsdbReadS
ttBlk
(
pCommitter
->
dReader
.
pReader
,
iStt
,
pIter
->
aSt
tBlk
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
if
(
taosArrayGetSize
(
pIter
->
aS
s
tBlk
)
==
0
)
continue
;
if
(
taosArrayGetSize
(
pIter
->
aS
t
tBlk
)
==
0
)
continue
;
pIter
->
iS
s
tBlk
=
0
;
pIter
->
iS
t
tBlk
=
0
;
SS
stBlk
*
pSstBlk
=
(
SSstBlk
*
)
taosArrayGet
(
pIter
->
aSs
tBlk
,
0
);
SS
ttBlk
*
pSttBlk
=
(
SSttBlk
*
)
taosArrayGet
(
pIter
->
aSt
tBlk
,
0
);
code
=
tsdbReadS
stBlock
(
pCommitter
->
dReader
.
pReader
,
iSst
,
pSs
tBlk
,
&
pIter
->
bData
);
code
=
tsdbReadS
ttBlock
(
pCommitter
->
dReader
.
pReader
,
iStt
,
pSt
tBlk
,
&
pIter
->
bData
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
pIter
->
iRow
=
0
;
pIter
->
iRow
=
0
;
...
@@ -454,9 +454,9 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
...
@@ -454,9 +454,9 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
iIter
++
;
iIter
++
;
}
}
}
else
{
}
else
{
for
(
int32_t
iS
st
=
0
;
iSst
<
pReader
->
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pReader
->
pSet
->
nSttF
;
iSt
t
++
)
{
SS
stFile
*
pSstFile
=
pReader
->
pSet
->
aSstF
[
iSs
t
];
SS
ttFile
*
pSttFile
=
pReader
->
pSet
->
aSttF
[
iSt
t
];
if
(
pS
stFile
->
size
>
pSs
tFile
->
offset
)
{
if
(
pS
ttFile
->
size
>
pSt
tFile
->
offset
)
{
pCommitter
->
toLastOnly
=
1
;
pCommitter
->
toLastOnly
=
1
;
break
;
break
;
}
}
...
@@ -512,34 +512,34 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
...
@@ -512,34 +512,34 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
SHeadFile
fHead
=
{.
commitID
=
pCommitter
->
commitID
};
SHeadFile
fHead
=
{.
commitID
=
pCommitter
->
commitID
};
SDataFile
fData
=
{.
commitID
=
pCommitter
->
commitID
};
SDataFile
fData
=
{.
commitID
=
pCommitter
->
commitID
};
SSmaFile
fSma
=
{.
commitID
=
pCommitter
->
commitID
};
SSmaFile
fSma
=
{.
commitID
=
pCommitter
->
commitID
};
SS
stFile
fSs
t
=
{.
commitID
=
pCommitter
->
commitID
};
SS
ttFile
fSt
t
=
{.
commitID
=
pCommitter
->
commitID
};
SDFileSet
wSet
=
{.
fid
=
pCommitter
->
commitFid
,
.
pHeadF
=
&
fHead
,
.
pDataF
=
&
fData
,
.
pSmaF
=
&
fSma
};
SDFileSet
wSet
=
{.
fid
=
pCommitter
->
commitFid
,
.
pHeadF
=
&
fHead
,
.
pDataF
=
&
fData
,
.
pSmaF
=
&
fSma
};
if
(
pRSet
)
{
if
(
pRSet
)
{
ASSERT
(
pRSet
->
nS
s
tF
<=
pCommitter
->
maxLast
);
ASSERT
(
pRSet
->
nS
t
tF
<=
pCommitter
->
maxLast
);
fData
=
*
pRSet
->
pDataF
;
fData
=
*
pRSet
->
pDataF
;
fSma
=
*
pRSet
->
pSmaF
;
fSma
=
*
pRSet
->
pSmaF
;
wSet
.
diskId
=
pRSet
->
diskId
;
wSet
.
diskId
=
pRSet
->
diskId
;
if
(
pRSet
->
nS
s
tF
<
pCommitter
->
maxLast
)
{
if
(
pRSet
->
nS
t
tF
<
pCommitter
->
maxLast
)
{
for
(
int32_t
iS
st
=
0
;
iSst
<
pRSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pRSet
->
nSttF
;
iSt
t
++
)
{
wSet
.
aS
stF
[
iSst
]
=
pRSet
->
aSstF
[
iSs
t
];
wSet
.
aS
ttF
[
iStt
]
=
pRSet
->
aSttF
[
iSt
t
];
}
}
wSet
.
nS
stF
=
pRSet
->
nSs
tF
+
1
;
wSet
.
nS
ttF
=
pRSet
->
nSt
tF
+
1
;
}
else
{
}
else
{
wSet
.
nS
s
tF
=
1
;
wSet
.
nS
t
tF
=
1
;
}
}
}
else
{
}
else
{
SDiskID
did
=
{
0
};
SDiskID
did
=
{
0
};
tfsAllocDisk
(
pTsdb
->
pVnode
->
pTfs
,
0
,
&
did
);
tfsAllocDisk
(
pTsdb
->
pVnode
->
pTfs
,
0
,
&
did
);
tfsMkdirRecurAt
(
pTsdb
->
pVnode
->
pTfs
,
pTsdb
->
path
,
did
);
tfsMkdirRecurAt
(
pTsdb
->
pVnode
->
pTfs
,
pTsdb
->
path
,
did
);
wSet
.
diskId
=
did
;
wSet
.
diskId
=
did
;
wSet
.
nS
s
tF
=
1
;
wSet
.
nS
t
tF
=
1
;
}
}
wSet
.
aS
stF
[
wSet
.
nSstF
-
1
]
=
&
fSs
t
;
wSet
.
aS
ttF
[
wSet
.
nSttF
-
1
]
=
&
fSt
t
;
code
=
tsdbDataFWriterOpen
(
&
pCommitter
->
dWriter
.
pWriter
,
pTsdb
,
&
wSet
);
code
=
tsdbDataFWriterOpen
(
&
pCommitter
->
dWriter
.
pWriter
,
pTsdb
,
&
wSet
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
taosArrayClear
(
pCommitter
->
dWriter
.
aBlockIdx
);
taosArrayClear
(
pCommitter
->
dWriter
.
aBlockIdx
);
taosArrayClear
(
pCommitter
->
dWriter
.
aS
s
tBlk
);
taosArrayClear
(
pCommitter
->
dWriter
.
aS
t
tBlk
);
tMapDataReset
(
&
pCommitter
->
dWriter
.
mBlock
);
tMapDataReset
(
&
pCommitter
->
dWriter
.
mBlock
);
tBlockDataReset
(
&
pCommitter
->
dWriter
.
bData
);
tBlockDataReset
(
&
pCommitter
->
dWriter
.
bData
);
tBlockDataReset
(
&
pCommitter
->
dWriter
.
bDatal
);
tBlockDataReset
(
&
pCommitter
->
dWriter
.
bDatal
);
...
@@ -610,7 +610,7 @@ _err:
...
@@ -610,7 +610,7 @@ _err:
static
int32_t
tsdbCommitLastBlock
(
SCommitter
*
pCommitter
)
{
static
int32_t
tsdbCommitLastBlock
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SS
s
tBlk
blockL
;
SS
t
tBlk
blockL
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bDatal
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bDatal
;
ASSERT
(
pBlockData
->
nRow
>
0
);
ASSERT
(
pBlockData
->
nRow
>
0
);
...
@@ -635,8 +635,8 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
...
@@ -635,8 +635,8 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
code
=
tsdbWriteBlockData
(
pCommitter
->
dWriter
.
pWriter
,
pBlockData
,
&
blockL
.
bInfo
,
NULL
,
pCommitter
->
cmprAlg
,
1
);
code
=
tsdbWriteBlockData
(
pCommitter
->
dWriter
.
pWriter
,
pBlockData
,
&
blockL
.
bInfo
,
NULL
,
pCommitter
->
cmprAlg
,
1
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// push SS
s
tBlk
// push SS
t
tBlk
if
(
taosArrayPush
(
pCommitter
->
dWriter
.
aS
s
tBlk
,
&
blockL
)
==
NULL
)
{
if
(
taosArrayPush
(
pCommitter
->
dWriter
.
aS
t
tBlk
,
&
blockL
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
...
@@ -658,8 +658,8 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
...
@@ -658,8 +658,8 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
code
=
tsdbWriteBlockIdx
(
pCommitter
->
dWriter
.
pWriter
,
pCommitter
->
dWriter
.
aBlockIdx
);
code
=
tsdbWriteBlockIdx
(
pCommitter
->
dWriter
.
pWriter
,
pCommitter
->
dWriter
.
aBlockIdx
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// write aS
s
tBlk
// write aS
t
tBlk
code
=
tsdbWriteS
stBlk
(
pCommitter
->
dWriter
.
pWriter
,
pCommitter
->
dWriter
.
aSs
tBlk
);
code
=
tsdbWriteS
ttBlk
(
pCommitter
->
dWriter
.
pWriter
,
pCommitter
->
dWriter
.
aSt
tBlk
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// update file header
// update file header
...
@@ -757,7 +757,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
...
@@ -757,7 +757,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
pCommitter
->
minRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
minRows
;
pCommitter
->
minRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
minRows
;
pCommitter
->
maxRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
;
pCommitter
->
maxRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
;
pCommitter
->
cmprAlg
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
compression
;
pCommitter
->
cmprAlg
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
compression
;
pCommitter
->
maxLast
=
TSDB_DEFAULT_S
S
T_FILE
;
// TODO: make it as a config
pCommitter
->
maxLast
=
TSDB_DEFAULT_S
T
T_FILE
;
// TODO: make it as a config
pCommitter
->
aTbDataP
=
tsdbMemTableGetTbDataArray
(
pTsdb
->
imem
);
pCommitter
->
aTbDataP
=
tsdbMemTableGetTbDataArray
(
pTsdb
->
imem
);
if
(
pCommitter
->
aTbDataP
==
NULL
)
{
if
(
pCommitter
->
aTbDataP
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -787,10 +787,10 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
...
@@ -787,10 +787,10 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
if
(
code
)
goto
_exit
;
if
(
code
)
goto
_exit
;
// merger
// merger
for
(
int32_t
iS
st
=
0
;
iSst
<
TSDB_MAX_SST_FILE
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
TSDB_MAX_STT_FILE
;
iSt
t
++
)
{
SDataIter
*
pIter
=
&
pCommitter
->
aDataIter
[
iS
s
t
];
SDataIter
*
pIter
=
&
pCommitter
->
aDataIter
[
iS
t
t
];
pIter
->
aS
stBlk
=
taosArrayInit
(
0
,
sizeof
(
SSs
tBlk
));
pIter
->
aS
ttBlk
=
taosArrayInit
(
0
,
sizeof
(
SSt
tBlk
));
if
(
pIter
->
aS
s
tBlk
==
NULL
)
{
if
(
pIter
->
aS
t
tBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
...
@@ -806,8 +806,8 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
...
@@ -806,8 +806,8 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
goto
_exit
;
goto
_exit
;
}
}
pCommitter
->
dWriter
.
aS
stBlk
=
taosArrayInit
(
0
,
sizeof
(
SSs
tBlk
));
pCommitter
->
dWriter
.
aS
ttBlk
=
taosArrayInit
(
0
,
sizeof
(
SSt
tBlk
));
if
(
pCommitter
->
dWriter
.
aS
s
tBlk
==
NULL
)
{
if
(
pCommitter
->
dWriter
.
aS
t
tBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
...
@@ -829,15 +829,15 @@ static void tsdbCommitDataEnd(SCommitter *pCommitter) {
...
@@ -829,15 +829,15 @@ static void tsdbCommitDataEnd(SCommitter *pCommitter) {
tBlockDataDestroy
(
&
pCommitter
->
dReader
.
bData
,
1
);
tBlockDataDestroy
(
&
pCommitter
->
dReader
.
bData
,
1
);
// merger
// merger
for
(
int32_t
iS
st
=
0
;
iSst
<
TSDB_MAX_SST_FILE
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
TSDB_MAX_STT_FILE
;
iSt
t
++
)
{
SDataIter
*
pIter
=
&
pCommitter
->
aDataIter
[
iS
s
t
];
SDataIter
*
pIter
=
&
pCommitter
->
aDataIter
[
iS
t
t
];
taosArrayDestroy
(
pIter
->
aS
s
tBlk
);
taosArrayDestroy
(
pIter
->
aS
t
tBlk
);
tBlockDataDestroy
(
&
pIter
->
bData
,
1
);
tBlockDataDestroy
(
&
pIter
->
bData
,
1
);
}
}
// writer
// writer
taosArrayDestroy
(
pCommitter
->
dWriter
.
aBlockIdx
);
taosArrayDestroy
(
pCommitter
->
dWriter
.
aBlockIdx
);
taosArrayDestroy
(
pCommitter
->
dWriter
.
aS
s
tBlk
);
taosArrayDestroy
(
pCommitter
->
dWriter
.
aS
t
tBlk
);
tMapDataClear
(
&
pCommitter
->
dWriter
.
mBlock
);
tMapDataClear
(
&
pCommitter
->
dWriter
.
mBlock
);
tBlockDataDestroy
(
&
pCommitter
->
dWriter
.
bData
,
1
);
tBlockDataDestroy
(
&
pCommitter
->
dWriter
.
bData
,
1
);
tBlockDataDestroy
(
&
pCommitter
->
dWriter
.
bDatal
,
1
);
tBlockDataDestroy
(
&
pCommitter
->
dWriter
.
bDatal
,
1
);
...
@@ -1052,11 +1052,11 @@ static int32_t tsdbNextCommitRow(SCommitter *pCommitter) {
...
@@ -1052,11 +1052,11 @@ static int32_t tsdbNextCommitRow(SCommitter *pCommitter) {
pIter
->
r
.
uid
=
pIter
->
bData
.
uid
?
pIter
->
bData
.
uid
:
pIter
->
bData
.
aUid
[
pIter
->
iRow
];
pIter
->
r
.
uid
=
pIter
->
bData
.
uid
?
pIter
->
bData
.
uid
:
pIter
->
bData
.
aUid
[
pIter
->
iRow
];
pIter
->
r
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
bData
,
pIter
->
iRow
);
pIter
->
r
.
row
=
tsdbRowFromBlockData
(
&
pIter
->
bData
,
pIter
->
iRow
);
}
else
{
}
else
{
pIter
->
iS
s
tBlk
++
;
pIter
->
iS
t
tBlk
++
;
if
(
pIter
->
iS
stBlk
<
taosArrayGetSize
(
pIter
->
aSs
tBlk
))
{
if
(
pIter
->
iS
ttBlk
<
taosArrayGetSize
(
pIter
->
aSt
tBlk
))
{
SS
stBlk
*
pSstBlk
=
(
SSstBlk
*
)
taosArrayGet
(
pIter
->
aSstBlk
,
pIter
->
iSs
tBlk
);
SS
ttBlk
*
pSttBlk
=
(
SSttBlk
*
)
taosArrayGet
(
pIter
->
aSttBlk
,
pIter
->
iSt
tBlk
);
code
=
tsdbReadS
stBlock
(
pCommitter
->
dReader
.
pReader
,
pIter
->
iSst
,
pSs
tBlk
,
&
pIter
->
bData
);
code
=
tsdbReadS
ttBlock
(
pCommitter
->
dReader
.
pReader
,
pIter
->
iStt
,
pSt
tBlk
,
&
pIter
->
bData
);
if
(
code
)
goto
_exit
;
if
(
code
)
goto
_exit
;
pIter
->
iRow
=
0
;
pIter
->
iRow
=
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
d603faa4
...
@@ -113,7 +113,7 @@ _err:
...
@@ -113,7 +113,7 @@ _err:
// taosRemoveFile(fname);
// taosRemoveFile(fname);
// }
// }
// // s
s
t
// // s
t
t
// if (isSameDisk && pFrom->pLastF->commitID == pTo->pLastF->commitID) {
// if (isSameDisk && pFrom->pLastF->commitID == pTo->pLastF->commitID) {
// if (pFrom->pLastF->size > pTo->pLastF->size) {
// if (pFrom->pLastF->size > pTo->pLastF->size) {
// code = tsdbDFileRollback(pFS->pTsdb, pTo, TSDB_LAST_FILE);
// code = tsdbDFileRollback(pFS->pTsdb, pTo, TSDB_LAST_FILE);
...
@@ -143,7 +143,7 @@ _err:
...
@@ -143,7 +143,7 @@ _err:
// tsdbDataFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pDataF, fname);
// tsdbDataFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pDataF, fname);
// taosRemoveFile(fname);
// taosRemoveFile(fname);
// // s
s
t
// // s
t
t
// tsdbLastFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pLastF, fname);
// tsdbLastFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pLastF, fname);
// taosRemoveFile(fname);
// taosRemoveFile(fname);
...
@@ -258,8 +258,8 @@ void tsdbFSDestroy(STsdbFS *pFS) {
...
@@ -258,8 +258,8 @@ void tsdbFSDestroy(STsdbFS *pFS) {
taosMemoryFree
(
pSet
->
pHeadF
);
taosMemoryFree
(
pSet
->
pHeadF
);
taosMemoryFree
(
pSet
->
pDataF
);
taosMemoryFree
(
pSet
->
pDataF
);
taosMemoryFree
(
pSet
->
pSmaF
);
taosMemoryFree
(
pSet
->
pSmaF
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
taosMemoryFree
(
pSet
->
aS
stF
[
iSs
t
]);
taosMemoryFree
(
pSet
->
aS
ttF
[
iSt
t
]);
}
}
}
}
...
@@ -328,14 +328,14 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
...
@@ -328,14 +328,14 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
// s
s
t ===========
// s
t
t ===========
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
tsdbS
stFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSstF
[
iSs
t
],
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSttF
[
iSt
t
],
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
}
if
(
size
!=
LOGIC_TO_FILE_SIZE
(
pSet
->
aS
stF
[
iSs
t
]
->
size
,
TSDB_DEFAULT_PAGE_SIZE
))
{
if
(
size
!=
LOGIC_TO_FILE_SIZE
(
pSet
->
aS
ttF
[
iSt
t
]
->
size
,
TSDB_DEFAULT_PAGE_SIZE
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
goto
_err
;
}
}
...
@@ -519,10 +519,10 @@ int32_t tsdbFSClose(STsdb *pTsdb) {
...
@@ -519,10 +519,10 @@ int32_t tsdbFSClose(STsdb *pTsdb) {
ASSERT
(
pSet
->
pSmaF
->
nRef
==
1
);
ASSERT
(
pSet
->
pSmaF
->
nRef
==
1
);
taosMemoryFree
(
pSet
->
pSmaF
);
taosMemoryFree
(
pSet
->
pSmaF
);
// s
s
t
// s
t
t
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
ASSERT
(
pSet
->
aS
stF
[
iSs
t
]
->
nRef
==
1
);
ASSERT
(
pSet
->
aS
ttF
[
iSt
t
]
->
nRef
==
1
);
taosMemoryFree
(
pSet
->
aS
stF
[
iSs
t
]);
taosMemoryFree
(
pSet
->
aS
ttF
[
iSt
t
]);
}
}
}
}
...
@@ -579,14 +579,14 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) {
...
@@ -579,14 +579,14 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) {
}
}
*
fSet
.
pSmaF
=
*
pSet
->
pSmaF
;
*
fSet
.
pSmaF
=
*
pSet
->
pSmaF
;
// s
s
t
// s
t
t
for
(
fSet
.
nS
stF
=
0
;
fSet
.
nSstF
<
pSet
->
nSstF
;
fSet
.
nSs
tF
++
)
{
for
(
fSet
.
nS
ttF
=
0
;
fSet
.
nSttF
<
pSet
->
nSttF
;
fSet
.
nSt
tF
++
)
{
fSet
.
aS
stF
[
fSet
.
nSstF
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
fSet
.
aS
ttF
[
fSet
.
nSttF
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
fSet
.
aS
stF
[
fSet
.
nSs
tF
]
==
NULL
)
{
if
(
fSet
.
aS
ttF
[
fSet
.
nSt
tF
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
*
fSet
.
aS
stF
[
fSet
.
nSstF
]
=
*
pSet
->
aSstF
[
fSet
.
nSs
tF
];
*
fSet
.
aS
ttF
[
fSet
.
nSttF
]
=
*
pSet
->
aSttF
[
fSet
.
nSt
tF
];
}
}
if
(
taosArrayPush
(
pFS
->
aDFileSet
,
&
fSet
)
==
NULL
)
{
if
(
taosArrayPush
(
pFS
->
aDFileSet
,
&
fSet
)
==
NULL
)
{
...
@@ -639,28 +639,28 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
...
@@ -639,28 +639,28 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
*
pDFileSet
->
pHeadF
=
*
pSet
->
pHeadF
;
*
pDFileSet
->
pHeadF
=
*
pSet
->
pHeadF
;
*
pDFileSet
->
pDataF
=
*
pSet
->
pDataF
;
*
pDFileSet
->
pDataF
=
*
pSet
->
pDataF
;
*
pDFileSet
->
pSmaF
=
*
pSet
->
pSmaF
;
*
pDFileSet
->
pSmaF
=
*
pSet
->
pSmaF
;
// s
s
t
// s
t
t
if
(
pSet
->
nS
stF
>
pDFileSet
->
nSs
tF
)
{
if
(
pSet
->
nS
ttF
>
pDFileSet
->
nSt
tF
)
{
ASSERT
(
pSet
->
nS
stF
==
pDFileSet
->
nSs
tF
+
1
);
ASSERT
(
pSet
->
nS
ttF
==
pDFileSet
->
nSt
tF
+
1
);
pDFileSet
->
aS
stF
[
pDFileSet
->
nSstF
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
pDFileSet
->
aS
ttF
[
pDFileSet
->
nSttF
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
pDFileSet
->
aS
stF
[
pDFileSet
->
nSs
tF
]
==
NULL
)
{
if
(
pDFileSet
->
aS
ttF
[
pDFileSet
->
nSt
tF
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
*
pDFileSet
->
aS
stF
[
pDFileSet
->
nSstF
]
=
*
pSet
->
aSstF
[
pSet
->
nSs
tF
-
1
];
*
pDFileSet
->
aS
ttF
[
pDFileSet
->
nSttF
]
=
*
pSet
->
aSttF
[
pSet
->
nSt
tF
-
1
];
pDFileSet
->
nS
s
tF
++
;
pDFileSet
->
nS
t
tF
++
;
}
else
if
(
pSet
->
nS
stF
<
pDFileSet
->
nSs
tF
)
{
}
else
if
(
pSet
->
nS
ttF
<
pDFileSet
->
nSt
tF
)
{
ASSERT
(
pSet
->
nS
s
tF
==
1
);
ASSERT
(
pSet
->
nS
t
tF
==
1
);
for
(
int32_t
iS
st
=
1
;
iSst
<
pDFileSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
1
;
iStt
<
pDFileSet
->
nSttF
;
iSt
t
++
)
{
taosMemoryFree
(
pDFileSet
->
aS
stF
[
iSs
t
]);
taosMemoryFree
(
pDFileSet
->
aS
ttF
[
iSt
t
]);
}
}
*
pDFileSet
->
aS
stF
[
0
]
=
*
pSet
->
aSs
tF
[
0
];
*
pDFileSet
->
aS
ttF
[
0
]
=
*
pSet
->
aSt
tF
[
0
];
pDFileSet
->
nS
s
tF
=
1
;
pDFileSet
->
nS
t
tF
=
1
;
}
else
{
}
else
{
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
*
pDFileSet
->
aS
stF
[
iSst
]
=
*
pSet
->
aSstF
[
iSs
t
];
*
pDFileSet
->
aS
ttF
[
iStt
]
=
*
pSet
->
aSttF
[
iSt
t
];
}
}
}
}
...
@@ -668,8 +668,8 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
...
@@ -668,8 +668,8 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
}
}
}
}
ASSERT
(
pSet
->
nS
s
tF
==
1
);
ASSERT
(
pSet
->
nS
t
tF
==
1
);
SDFileSet
fSet
=
{.
diskId
=
pSet
->
diskId
,
.
fid
=
pSet
->
fid
,
.
nS
s
tF
=
1
};
SDFileSet
fSet
=
{.
diskId
=
pSet
->
diskId
,
.
fid
=
pSet
->
fid
,
.
nS
t
tF
=
1
};
// head
// head
fSet
.
pHeadF
=
(
SHeadFile
*
)
taosMemoryMalloc
(
sizeof
(
SHeadFile
));
fSet
.
pHeadF
=
(
SHeadFile
*
)
taosMemoryMalloc
(
sizeof
(
SHeadFile
));
...
@@ -695,13 +695,13 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
...
@@ -695,13 +695,13 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
}
}
*
fSet
.
pSmaF
=
*
pSet
->
pSmaF
;
*
fSet
.
pSmaF
=
*
pSet
->
pSmaF
;
// s
s
t
// s
t
t
fSet
.
aS
stF
[
0
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
fSet
.
aS
ttF
[
0
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
fSet
.
aS
s
tF
[
0
]
==
NULL
)
{
if
(
fSet
.
aS
t
tF
[
0
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
*
fSet
.
aS
stF
[
0
]
=
*
pSet
->
aSs
tF
[
0
];
*
fSet
.
aS
ttF
[
0
]
=
*
pSet
->
aSt
tF
[
0
];
if
(
taosArrayInsert
(
pFS
->
aDFileSet
,
idx
,
&
fSet
)
==
NULL
)
{
if
(
taosArrayInsert
(
pFS
->
aDFileSet
,
idx
,
&
fSet
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -869,81 +869,81 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
...
@@ -869,81 +869,81 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
pSetOld
->
pSmaF
->
size
=
pSetNew
->
pSmaF
->
size
;
pSetOld
->
pSmaF
->
size
=
pSetNew
->
pSmaF
->
size
;
}
}
// s
s
t
// s
t
t
if
(
sameDisk
)
{
if
(
sameDisk
)
{
if
(
pSetNew
->
nS
stF
>
pSetOld
->
nSs
tF
)
{
if
(
pSetNew
->
nS
ttF
>
pSetOld
->
nSt
tF
)
{
ASSERT
(
pSetNew
->
nS
stF
=
pSetOld
->
nSs
tF
+
1
);
ASSERT
(
pSetNew
->
nS
ttF
=
pSetOld
->
nSt
tF
+
1
);
pSetOld
->
aS
stF
[
pSetOld
->
nSstF
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
pSetOld
->
aS
ttF
[
pSetOld
->
nSttF
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
pSetOld
->
aS
stF
[
pSetOld
->
nSs
tF
]
==
NULL
)
{
if
(
pSetOld
->
aS
ttF
[
pSetOld
->
nSt
tF
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
*
pSetOld
->
aS
stF
[
pSetOld
->
nSstF
]
=
*
pSetNew
->
aSstF
[
pSetOld
->
nSs
tF
];
*
pSetOld
->
aS
ttF
[
pSetOld
->
nSttF
]
=
*
pSetNew
->
aSttF
[
pSetOld
->
nSt
tF
];
pSetOld
->
aS
stF
[
pSetOld
->
nSs
tF
]
->
nRef
=
1
;
pSetOld
->
aS
ttF
[
pSetOld
->
nSt
tF
]
->
nRef
=
1
;
pSetOld
->
nS
s
tF
++
;
pSetOld
->
nS
t
tF
++
;
}
else
if
(
pSetNew
->
nS
stF
<
pSetOld
->
nSs
tF
)
{
}
else
if
(
pSetNew
->
nS
ttF
<
pSetOld
->
nSt
tF
)
{
ASSERT
(
pSetNew
->
nS
s
tF
==
1
);
ASSERT
(
pSetNew
->
nS
t
tF
==
1
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSetOld
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSetOld
->
nSttF
;
iSt
t
++
)
{
SS
stFile
*
pSstFile
=
pSetOld
->
aSstF
[
iSs
t
];
SS
ttFile
*
pSttFile
=
pSetOld
->
aSttF
[
iSt
t
];
nRef
=
atomic_sub_fetch_32
(
&
pS
s
tFile
->
nRef
,
1
);
nRef
=
atomic_sub_fetch_32
(
&
pS
t
tFile
->
nRef
,
1
);
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
tsdbS
stFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSs
tFile
,
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSt
tFile
,
fname
);
taosRemoveFile
(
fname
);
taosRemoveFile
(
fname
);
taosMemoryFree
(
pS
s
tFile
);
taosMemoryFree
(
pS
t
tFile
);
}
}
pSetOld
->
aS
stF
[
iSs
t
]
=
NULL
;
pSetOld
->
aS
ttF
[
iSt
t
]
=
NULL
;
}
}
pSetOld
->
nS
s
tF
=
1
;
pSetOld
->
nS
t
tF
=
1
;
pSetOld
->
aS
stF
[
0
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
pSetOld
->
aS
ttF
[
0
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
pSetOld
->
aS
s
tF
[
0
]
==
NULL
)
{
if
(
pSetOld
->
aS
t
tF
[
0
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
*
pSetOld
->
aS
stF
[
0
]
=
*
pSetNew
->
aSs
tF
[
0
];
*
pSetOld
->
aS
ttF
[
0
]
=
*
pSetNew
->
aSt
tF
[
0
];
pSetOld
->
aS
s
tF
[
0
]
->
nRef
=
1
;
pSetOld
->
aS
t
tF
[
0
]
->
nRef
=
1
;
}
else
{
}
else
{
for
(
int32_t
iS
st
=
0
;
iSst
<
pSetOld
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSetOld
->
nSttF
;
iSt
t
++
)
{
if
(
pSetOld
->
aS
stF
[
iSst
]
->
commitID
!=
pSetNew
->
aSstF
[
iSs
t
]
->
commitID
)
{
if
(
pSetOld
->
aS
ttF
[
iStt
]
->
commitID
!=
pSetNew
->
aSttF
[
iSt
t
]
->
commitID
)
{
SS
stFile
*
pSstFile
=
pSetOld
->
aSstF
[
iSs
t
];
SS
ttFile
*
pSttFile
=
pSetOld
->
aSttF
[
iSt
t
];
nRef
=
atomic_sub_fetch_32
(
&
pS
s
tFile
->
nRef
,
1
);
nRef
=
atomic_sub_fetch_32
(
&
pS
t
tFile
->
nRef
,
1
);
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
tsdbS
stFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSs
tFile
,
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSt
tFile
,
fname
);
taosRemoveFile
(
fname
);
taosRemoveFile
(
fname
);
taosMemoryFree
(
pS
s
tFile
);
taosMemoryFree
(
pS
t
tFile
);
}
}
pSetOld
->
aS
stF
[
iSst
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
pSetOld
->
aS
ttF
[
iStt
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
pSetOld
->
aS
stF
[
iSs
t
]
==
NULL
)
{
if
(
pSetOld
->
aS
ttF
[
iSt
t
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
*
pSetOld
->
aS
stF
[
iSst
]
=
*
pSetNew
->
aSstF
[
iSs
t
];
*
pSetOld
->
aS
ttF
[
iStt
]
=
*
pSetNew
->
aSttF
[
iSt
t
];
pSetOld
->
aS
stF
[
iSs
t
]
->
nRef
=
1
;
pSetOld
->
aS
ttF
[
iSt
t
]
->
nRef
=
1
;
}
else
{
}
else
{
ASSERT
(
pSetOld
->
aS
stF
[
iSst
]
->
size
==
pSetOld
->
aSstF
[
iSs
t
]
->
size
);
ASSERT
(
pSetOld
->
aS
ttF
[
iStt
]
->
size
==
pSetOld
->
aSttF
[
iSt
t
]
->
size
);
ASSERT
(
pSetOld
->
aS
stF
[
iSst
]
->
offset
==
pSetOld
->
aSstF
[
iSs
t
]
->
offset
);
ASSERT
(
pSetOld
->
aS
ttF
[
iStt
]
->
offset
==
pSetOld
->
aSttF
[
iSt
t
]
->
offset
);
}
}
}
}
}
}
}
else
{
}
else
{
ASSERT
(
pSetOld
->
nS
stF
==
pSetNew
->
nSs
tF
);
ASSERT
(
pSetOld
->
nS
ttF
==
pSetNew
->
nSt
tF
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSetOld
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSetOld
->
nSttF
;
iSt
t
++
)
{
SS
stFile
*
pSstFile
=
pSetOld
->
aSstF
[
iSs
t
];
SS
ttFile
*
pSttFile
=
pSetOld
->
aSttF
[
iSt
t
];
nRef
=
atomic_sub_fetch_32
(
&
pS
s
tFile
->
nRef
,
1
);
nRef
=
atomic_sub_fetch_32
(
&
pS
t
tFile
->
nRef
,
1
);
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
tsdbS
stFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSs
tFile
,
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSt
tFile
,
fname
);
taosRemoveFile
(
fname
);
taosRemoveFile
(
fname
);
taosMemoryFree
(
pS
s
tFile
);
taosMemoryFree
(
pS
t
tFile
);
}
}
pSetOld
->
aS
stF
[
iSst
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
pSetOld
->
aS
ttF
[
iStt
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
pSetOld
->
aS
stF
[
iSs
t
]
==
NULL
)
{
if
(
pSetOld
->
aS
ttF
[
iSt
t
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
*
pSetOld
->
aS
stF
[
iSst
]
=
*
pSetNew
->
aSstF
[
iSs
t
];
*
pSetOld
->
aS
ttF
[
iStt
]
=
*
pSetNew
->
aSttF
[
iSt
t
];
pSetOld
->
aS
stF
[
iSs
t
]
->
nRef
=
1
;
pSetOld
->
aS
ttF
[
iSt
t
]
->
nRef
=
1
;
}
}
}
}
...
@@ -977,12 +977,12 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
...
@@ -977,12 +977,12 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
taosMemoryFree
(
pSetOld
->
pSmaF
);
taosMemoryFree
(
pSetOld
->
pSmaF
);
}
}
for
(
int8_t
iS
st
=
0
;
iSst
<
pSetOld
->
nSstF
;
iSs
t
++
)
{
for
(
int8_t
iS
tt
=
0
;
iStt
<
pSetOld
->
nSttF
;
iSt
t
++
)
{
nRef
=
atomic_sub_fetch_32
(
&
pSetOld
->
aS
stF
[
iSs
t
]
->
nRef
,
1
);
nRef
=
atomic_sub_fetch_32
(
&
pSetOld
->
aS
ttF
[
iSt
t
]
->
nRef
,
1
);
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
tsdbS
stFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSetOld
->
aSstF
[
iSs
t
],
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSetOld
->
diskId
,
pSetOld
->
fid
,
pSetOld
->
aSttF
[
iSt
t
],
fname
);
taosRemoveFile
(
fname
);
taosRemoveFile
(
fname
);
taosMemoryFree
(
pSetOld
->
aS
stF
[
iSs
t
]);
taosMemoryFree
(
pSetOld
->
aS
ttF
[
iSt
t
]);
}
}
}
}
...
@@ -990,7 +990,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
...
@@ -990,7 +990,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
continue
;
continue
;
_add_new:
_add_new:
fSet
=
(
SDFileSet
){.
diskId
=
pSetNew
->
diskId
,
.
fid
=
pSetNew
->
fid
,
.
nS
s
tF
=
1
};
fSet
=
(
SDFileSet
){.
diskId
=
pSetNew
->
diskId
,
.
fid
=
pSetNew
->
fid
,
.
nS
t
tF
=
1
};
// head
// head
fSet
.
pHeadF
=
(
SHeadFile
*
)
taosMemoryMalloc
(
sizeof
(
SHeadFile
));
fSet
.
pHeadF
=
(
SHeadFile
*
)
taosMemoryMalloc
(
sizeof
(
SHeadFile
));
...
@@ -1019,15 +1019,15 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
...
@@ -1019,15 +1019,15 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
*
fSet
.
pSmaF
=
*
pSetNew
->
pSmaF
;
*
fSet
.
pSmaF
=
*
pSetNew
->
pSmaF
;
fSet
.
pSmaF
->
nRef
=
1
;
fSet
.
pSmaF
->
nRef
=
1
;
// s
s
t
// s
t
t
ASSERT
(
pSetNew
->
nS
s
tF
==
1
);
ASSERT
(
pSetNew
->
nS
t
tF
==
1
);
fSet
.
aS
stF
[
0
]
=
(
SSstFile
*
)
taosMemoryMalloc
(
sizeof
(
SSs
tFile
));
fSet
.
aS
ttF
[
0
]
=
(
SSttFile
*
)
taosMemoryMalloc
(
sizeof
(
SSt
tFile
));
if
(
fSet
.
aS
s
tF
[
0
]
==
NULL
)
{
if
(
fSet
.
aS
t
tF
[
0
]
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
*
fSet
.
aS
stF
[
0
]
=
*
pSetNew
->
aSs
tF
[
0
];
*
fSet
.
aS
ttF
[
0
]
=
*
pSetNew
->
aSt
tF
[
0
];
fSet
.
aS
s
tF
[
0
]
->
nRef
=
1
;
fSet
.
aS
t
tF
[
0
]
->
nRef
=
1
;
if
(
taosArrayInsert
(
pTsdb
->
fs
.
aDFileSet
,
iOld
,
&
fSet
)
==
NULL
)
{
if
(
taosArrayInsert
(
pTsdb
->
fs
.
aDFileSet
,
iOld
,
&
fSet
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -1075,8 +1075,8 @@ int32_t tsdbFSRef(STsdb *pTsdb, STsdbFS *pFS) {
...
@@ -1075,8 +1075,8 @@ int32_t tsdbFSRef(STsdb *pTsdb, STsdbFS *pFS) {
nRef
=
atomic_fetch_add_32
(
&
pSet
->
pSmaF
->
nRef
,
1
);
nRef
=
atomic_fetch_add_32
(
&
pSet
->
pSmaF
->
nRef
,
1
);
ASSERT
(
nRef
>
0
);
ASSERT
(
nRef
>
0
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
nRef
=
atomic_fetch_add_32
(
&
pSet
->
aS
stF
[
iSs
t
]
->
nRef
,
1
);
nRef
=
atomic_fetch_add_32
(
&
pSet
->
aS
ttF
[
iSt
t
]
->
nRef
,
1
);
ASSERT
(
nRef
>
0
);
ASSERT
(
nRef
>
0
);
}
}
...
@@ -1134,14 +1134,14 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
...
@@ -1134,14 +1134,14 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
taosMemoryFree
(
pSet
->
pSmaF
);
taosMemoryFree
(
pSet
->
pSmaF
);
}
}
// s
s
t
// s
t
t
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
nRef
=
atomic_sub_fetch_32
(
&
pSet
->
aS
stF
[
iSs
t
]
->
nRef
,
1
);
nRef
=
atomic_sub_fetch_32
(
&
pSet
->
aS
ttF
[
iSt
t
]
->
nRef
,
1
);
ASSERT
(
nRef
>=
0
);
ASSERT
(
nRef
>=
0
);
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
tsdbS
stFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSstF
[
iSs
t
],
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSttF
[
iSt
t
],
fname
);
taosRemoveFile
(
fname
);
taosRemoveFile
(
fname
);
taosMemoryFree
(
pSet
->
aS
stF
[
iSs
t
]);
taosMemoryFree
(
pSet
->
aS
ttF
[
iSt
t
]);
/* code */
/* code */
}
}
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
d603faa4
...
@@ -53,22 +53,22 @@ static int32_t tGetDataFile(uint8_t *p, SDataFile *pDataFile) {
...
@@ -53,22 +53,22 @@ static int32_t tGetDataFile(uint8_t *p, SDataFile *pDataFile) {
return
n
;
return
n
;
}
}
int32_t
tPutS
stFile
(
uint8_t
*
p
,
SSstFile
*
pSs
tFile
)
{
int32_t
tPutS
ttFile
(
uint8_t
*
p
,
SSttFile
*
pSt
tFile
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tFile
->
commitID
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tFile
->
commitID
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tFile
->
size
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tFile
->
size
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tFile
->
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tFile
->
offset
);
return
n
;
return
n
;
}
}
static
int32_t
tGetS
stFile
(
uint8_t
*
p
,
SSstFile
*
pSs
tFile
)
{
static
int32_t
tGetS
ttFile
(
uint8_t
*
p
,
SSttFile
*
pSt
tFile
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tFile
->
commitID
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tFile
->
commitID
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tFile
->
size
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tFile
->
size
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tFile
->
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tFile
->
offset
);
return
n
;
return
n
;
}
}
...
@@ -102,9 +102,9 @@ void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF,
...
@@ -102,9 +102,9 @@ void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF,
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
fid
,
pDataF
->
commitID
,
".data"
);
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
fid
,
pDataF
->
commitID
,
".data"
);
}
}
void
tsdbS
stFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSstFile
*
pSs
tF
,
char
fname
[])
{
void
tsdbS
ttFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSttFile
*
pSt
tF
,
char
fname
[])
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sv%df%dver%"
PRId64
"%s"
,
tfsGetDiskPath
(
pTsdb
->
pVnode
->
pTfs
,
did
),
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sv%df%dver%"
PRId64
"%s"
,
tfsGetDiskPath
(
pTsdb
->
pVnode
->
pTfs
,
did
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
fid
,
pS
stF
->
commitID
,
".ss
t"
);
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
fid
,
pS
ttF
->
commitID
,
".st
t"
);
}
}
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSmaFile
*
pSmaF
,
char
fname
[])
{
void
tsdbSmaFileName
(
STsdb
*
pTsdb
,
SDiskID
did
,
int32_t
fid
,
SSmaFile
*
pSmaF
,
char
fname
[])
{
...
@@ -194,10 +194,10 @@ int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) {
...
@@ -194,10 +194,10 @@ int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) {
n
+=
tPutDataFile
(
p
?
p
+
n
:
p
,
pSet
->
pDataF
);
n
+=
tPutDataFile
(
p
?
p
+
n
:
p
,
pSet
->
pDataF
);
n
+=
tPutSmaFile
(
p
?
p
+
n
:
p
,
pSet
->
pSmaF
);
n
+=
tPutSmaFile
(
p
?
p
+
n
:
p
,
pSet
->
pSmaF
);
// s
s
t
// s
t
t
n
+=
tPutU8
(
p
?
p
+
n
:
p
,
pSet
->
nS
s
tF
);
n
+=
tPutU8
(
p
?
p
+
n
:
p
,
pSet
->
nS
t
tF
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
n
+=
tPutS
stFile
(
p
?
p
+
n
:
p
,
pSet
->
aSstF
[
iSs
t
]);
n
+=
tPutS
ttFile
(
p
?
p
+
n
:
p
,
pSet
->
aSttF
[
iSt
t
]);
}
}
return
n
;
return
n
;
...
@@ -234,15 +234,15 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
...
@@ -234,15 +234,15 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
pSet
->
pSmaF
->
nRef
=
1
;
pSet
->
pSmaF
->
nRef
=
1
;
n
+=
tGetSmaFile
(
p
+
n
,
pSet
->
pSmaF
);
n
+=
tGetSmaFile
(
p
+
n
,
pSet
->
pSmaF
);
// s
s
t
// s
t
t
n
+=
tGetU8
(
p
+
n
,
&
pSet
->
nS
s
tF
);
n
+=
tGetU8
(
p
+
n
,
&
pSet
->
nS
t
tF
);
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
pSet
->
aS
stF
[
iSst
]
=
(
SSstFile
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSs
tFile
));
pSet
->
aS
ttF
[
iStt
]
=
(
SSttFile
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSt
tFile
));
if
(
pSet
->
aS
stF
[
iSs
t
]
==
NULL
)
{
if
(
pSet
->
aS
ttF
[
iSt
t
]
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
pSet
->
aS
stF
[
iSs
t
]
->
nRef
=
1
;
pSet
->
aS
ttF
[
iSt
t
]
->
nRef
=
1
;
n
+=
tGetS
stFile
(
p
+
n
,
pSet
->
aSstF
[
iSs
t
]);
n
+=
tGetS
ttFile
(
p
+
n
,
pSet
->
aSttF
[
iSt
t
]);
}
}
return
n
;
return
n
;
...
...
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
d603faa4
...
@@ -18,12 +18,12 @@
...
@@ -18,12 +18,12 @@
// SLDataIter =================================================
// SLDataIter =================================================
struct
SLDataIter
{
struct
SLDataIter
{
SRBTreeNode
node
;
SRBTreeNode
node
;
SS
stBlk
*
pSs
tBlk
;
SS
ttBlk
*
pSt
tBlk
;
SDataFReader
*
pReader
;
SDataFReader
*
pReader
;
int32_t
iS
s
t
;
int32_t
iS
t
t
;
int8_t
backward
;
int8_t
backward
;
SArray
*
aS
s
tBlk
;
SArray
*
aS
t
tBlk
;
int32_t
iS
s
tBlk
;
int32_t
iS
t
tBlk
;
SBlockData
bData
[
2
];
SBlockData
bData
[
2
];
int32_t
loadIndex
;
int32_t
loadIndex
;
int32_t
iRow
;
int32_t
iRow
;
...
@@ -40,8 +40,8 @@ static SBlockData *getNextBlock(SLDataIter *pIter) {
...
@@ -40,8 +40,8 @@ static SBlockData *getNextBlock(SLDataIter *pIter) {
return
getCurrentBlock
(
pIter
);
return
getCurrentBlock
(
pIter
);
}
}
int32_t
tLDataIterOpen
(
struct
SLDataIter
**
pIter
,
SDataFReader
*
pReader
,
int32_t
iS
st
,
int8_t
backward
,
uint64_t
uid
,
int32_t
tLDataIterOpen
(
struct
SLDataIter
**
pIter
,
SDataFReader
*
pReader
,
int32_t
iS
tt
,
int8_t
backward
,
uint64_t
s
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
)
{
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
*
pIter
=
taosMemoryCalloc
(
1
,
sizeof
(
SLDataIter
));
*
pIter
=
taosMemoryCalloc
(
1
,
sizeof
(
SLDataIter
));
if
(
*
pIter
==
NULL
)
{
if
(
*
pIter
==
NULL
)
{
...
@@ -50,13 +50,13 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -50,13 +50,13 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
}
}
(
*
pIter
)
->
uid
=
uid
;
(
*
pIter
)
->
uid
=
uid
;
(
*
pIter
)
->
timeWindow
=
*
pTimeWindow
;
(
*
pIter
)
->
verRange
=
*
pRange
;
(
*
pIter
)
->
pReader
=
pReader
;
(
*
pIter
)
->
pReader
=
pReader
;
(
*
pIter
)
->
iS
st
=
iSs
t
;
(
*
pIter
)
->
iS
tt
=
iSt
t
;
(
*
pIter
)
->
backward
=
backward
;
(
*
pIter
)
->
backward
=
backward
;
(
*
pIter
)
->
aSstBlk
=
taosArrayInit
(
0
,
sizeof
(
SSstBlk
));
(
*
pIter
)
->
verRange
=
*
pRange
;
if
((
*
pIter
)
->
aSstBlk
==
NULL
)
{
(
*
pIter
)
->
timeWindow
=
*
pTimeWindow
;
(
*
pIter
)
->
aSttBlk
=
taosArrayInit
(
0
,
sizeof
(
SSttBlk
));
if
((
*
pIter
)
->
aSttBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
...
@@ -71,18 +71,22 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -71,18 +71,22 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
goto
_exit
;
goto
_exit
;
}
}
code
=
tsdbReadS
stBlk
(
pReader
,
iSst
,
(
*
pIter
)
->
aSs
tBlk
);
code
=
tsdbReadS
ttBlk
(
pReader
,
iStt
,
(
*
pIter
)
->
aSt
tBlk
);
if
(
code
)
{
if
(
code
)
{
goto
_exit
;
goto
_exit
;
}
}
size_t
size
=
taosArrayGetSize
((
*
pIter
)
->
aS
s
tBlk
);
size_t
size
=
taosArrayGetSize
((
*
pIter
)
->
aS
t
tBlk
);
// find the start block
// find the start block
int32_t
index
=
-
1
;
int32_t
index
=
-
1
;
if
(
!
backward
)
{
// asc
if
(
!
backward
)
{
// asc
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSstBlk
*
p
=
taosArrayGet
((
*
pIter
)
->
aSstBlk
,
i
);
SSttBlk
*
p
=
taosArrayGet
((
*
pIter
)
->
aSttBlk
,
i
);
if
(
p
->
suid
!=
suid
)
{
continue
;
}
if
(
p
->
minUid
<=
uid
&&
p
->
maxUid
>=
uid
)
{
if
(
p
->
minUid
<=
uid
&&
p
->
maxUid
>=
uid
)
{
index
=
i
;
index
=
i
;
break
;
break
;
...
@@ -90,7 +94,11 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -90,7 +94,11 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
}
}
}
else
{
// desc
}
else
{
// desc
for
(
int32_t
i
=
size
-
1
;
i
>=
0
;
--
i
)
{
for
(
int32_t
i
=
size
-
1
;
i
>=
0
;
--
i
)
{
SSstBlk
*
p
=
taosArrayGet
((
*
pIter
)
->
aSstBlk
,
i
);
SSttBlk
*
p
=
taosArrayGet
((
*
pIter
)
->
aSttBlk
,
i
);
if
(
p
->
suid
!=
suid
)
{
continue
;
}
if
(
p
->
minUid
<=
uid
&&
p
->
maxUid
>=
uid
)
{
if
(
p
->
minUid
<=
uid
&&
p
->
maxUid
>=
uid
)
{
index
=
i
;
index
=
i
;
break
;
break
;
...
@@ -98,9 +106,9 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
...
@@ -98,9 +106,9 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
}
}
}
}
(
*
pIter
)
->
iS
s
tBlk
=
index
;
(
*
pIter
)
->
iS
t
tBlk
=
index
;
if
(
index
!=
-
1
)
{
if
(
index
!=
-
1
)
{
(
*
pIter
)
->
pS
stBlk
=
taosArrayGet
((
*
pIter
)
->
aSstBlk
,
(
*
pIter
)
->
iSs
tBlk
);
(
*
pIter
)
->
pS
ttBlk
=
taosArrayGet
((
*
pIter
)
->
aSttBlk
,
(
*
pIter
)
->
iSt
tBlk
);
}
}
_exit:
_exit:
...
@@ -110,18 +118,18 @@ _exit:
...
@@ -110,18 +118,18 @@ _exit:
void
tLDataIterClose
(
SLDataIter
*
pIter
)
{
void
tLDataIterClose
(
SLDataIter
*
pIter
)
{
tBlockDataDestroy
(
&
pIter
->
bData
[
0
],
1
);
tBlockDataDestroy
(
&
pIter
->
bData
[
0
],
1
);
tBlockDataDestroy
(
&
pIter
->
bData
[
1
],
1
);
tBlockDataDestroy
(
&
pIter
->
bData
[
1
],
1
);
taosArrayDestroy
(
pIter
->
aS
s
tBlk
);
taosArrayDestroy
(
pIter
->
aS
t
tBlk
);
taosMemoryFree
(
pIter
);
taosMemoryFree
(
pIter
);
}
}
void
tLDataIterNextBlock
(
SLDataIter
*
pIter
)
{
void
tLDataIterNextBlock
(
SLDataIter
*
pIter
)
{
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
pIter
->
iS
s
tBlk
+=
step
;
pIter
->
iS
t
tBlk
+=
step
;
int32_t
index
=
-
1
;
int32_t
index
=
-
1
;
size_t
size
=
taosArrayGetSize
(
pIter
->
aS
s
tBlk
);
size_t
size
=
taosArrayGetSize
(
pIter
->
aS
t
tBlk
);
for
(
int32_t
i
=
pIter
->
iS
s
tBlk
;
i
<
size
&&
i
>=
0
;
i
+=
step
)
{
for
(
int32_t
i
=
pIter
->
iS
t
tBlk
;
i
<
size
&&
i
>=
0
;
i
+=
step
)
{
SS
stBlk
*
p
=
taosArrayGet
(
pIter
->
aSs
tBlk
,
i
);
SS
ttBlk
*
p
=
taosArrayGet
(
pIter
->
aSt
tBlk
,
i
);
if
((
!
pIter
->
backward
)
&&
p
->
minUid
>
pIter
->
uid
)
{
if
((
!
pIter
->
backward
)
&&
p
->
minUid
>
pIter
->
uid
)
{
break
;
break
;
}
}
...
@@ -130,16 +138,38 @@ void tLDataIterNextBlock(SLDataIter *pIter) {
...
@@ -130,16 +138,38 @@ void tLDataIterNextBlock(SLDataIter *pIter) {
break
;
break
;
}
}
// check uid firstly
if
(
p
->
minUid
<=
pIter
->
uid
&&
p
->
maxUid
>=
pIter
->
uid
)
{
if
(
p
->
minUid
<=
pIter
->
uid
&&
p
->
maxUid
>=
pIter
->
uid
)
{
index
=
i
;
if
((
!
pIter
->
backward
)
&&
p
->
minKey
>
pIter
->
timeWindow
.
ekey
)
{
break
;
break
;
}
if
(
pIter
->
backward
&&
p
->
maxKey
<
pIter
->
timeWindow
.
skey
)
{
break
;
}
// check time range secondly
if
(
p
->
minKey
<=
pIter
->
timeWindow
.
ekey
&&
p
->
maxKey
>=
pIter
->
timeWindow
.
skey
)
{
if
((
!
pIter
->
backward
)
&&
p
->
minVer
>
pIter
->
verRange
.
maxVer
)
{
break
;
}
if
(
pIter
->
backward
&&
p
->
maxVer
<
pIter
->
verRange
.
minVer
)
{
break
;
}
if
(
p
->
minVer
<=
pIter
->
verRange
.
maxVer
&&
p
->
maxVer
>=
pIter
->
verRange
.
minVer
)
{
index
=
i
;
break
;
}
}
}
}
}
}
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
{
pIter
->
pS
s
tBlk
=
NULL
;
pIter
->
pS
t
tBlk
=
NULL
;
}
else
{
}
else
{
pIter
->
pS
stBlk
=
(
SSstBlk
*
)
taosArrayGet
(
pIter
->
aSstBlk
,
pIter
->
iSs
tBlk
);
pIter
->
pS
ttBlk
=
(
SSttBlk
*
)
taosArrayGet
(
pIter
->
aSttBlk
,
pIter
->
iSt
tBlk
);
}
}
}
}
...
@@ -192,14 +222,6 @@ static void findNextValidRow(SLDataIter *pIter) {
...
@@ -192,14 +222,6 @@ static void findNextValidRow(SLDataIter *pIter) {
continue
;
continue
;
}
}
// todo handle delete soon
#if 0
TSDBKEY k = {.ts = ts, .version = ver};
if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) {
continue;
}
#endif
hasVal
=
true
;
hasVal
=
true
;
break
;
break
;
}
}
...
@@ -212,16 +234,16 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
...
@@ -212,16 +234,16 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
int32_t
step
=
pIter
->
backward
?
-
1
:
1
;
// no qualified last file block in current file, no need to fetch row
// no qualified last file block in current file, no need to fetch row
if
(
pIter
->
pS
s
tBlk
==
NULL
)
{
if
(
pIter
->
pS
t
tBlk
==
NULL
)
{
return
false
;
return
false
;
}
}
int32_t
iBlockL
=
pIter
->
iS
s
tBlk
;
int32_t
iBlockL
=
pIter
->
iS
t
tBlk
;
SBlockData
*
pBlockData
=
getCurrentBlock
(
pIter
);
SBlockData
*
pBlockData
=
getCurrentBlock
(
pIter
);
if
(
pBlockData
->
nRow
==
0
&&
pIter
->
pS
s
tBlk
!=
NULL
)
{
// current block not loaded yet
if
(
pBlockData
->
nRow
==
0
&&
pIter
->
pS
t
tBlk
!=
NULL
)
{
// current block not loaded yet
pBlockData
=
getNextBlock
(
pIter
);
pBlockData
=
getNextBlock
(
pIter
);
code
=
tsdbReadS
stBlock
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSs
tBlk
,
pBlockData
);
code
=
tsdbReadS
ttBlock
(
pIter
->
pReader
,
pIter
->
iStt
,
pIter
->
pSt
tBlk
,
pBlockData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_exit
;
goto
_exit
;
}
}
...
@@ -236,16 +258,16 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
...
@@ -236,16 +258,16 @@ bool tLDataIterNextRow(SLDataIter *pIter) {
if
(
pIter
->
iRow
>=
pBlockData
->
nRow
||
pIter
->
iRow
<
0
)
{
if
(
pIter
->
iRow
>=
pBlockData
->
nRow
||
pIter
->
iRow
<
0
)
{
tLDataIterNextBlock
(
pIter
);
tLDataIterNextBlock
(
pIter
);
if
(
pIter
->
pS
s
tBlk
==
NULL
)
{
// no more data
if
(
pIter
->
pS
t
tBlk
==
NULL
)
{
// no more data
goto
_exit
;
goto
_exit
;
}
}
}
else
{
}
else
{
break
;
break
;
}
}
if
(
iBlockL
!=
pIter
->
iS
s
tBlk
)
{
if
(
iBlockL
!=
pIter
->
iS
t
tBlk
)
{
pBlockData
=
getNextBlock
(
pIter
);
pBlockData
=
getNextBlock
(
pIter
);
code
=
tsdbReadS
stBlock
(
pIter
->
pReader
,
pIter
->
iSst
,
pIter
->
pSs
tBlk
,
pBlockData
);
code
=
tsdbReadS
ttBlock
(
pIter
->
pReader
,
pIter
->
iStt
,
pIter
->
pSt
tBlk
,
pBlockData
);
if
(
code
)
{
if
(
code
)
{
goto
_exit
;
goto
_exit
;
}
}
...
@@ -262,7 +284,7 @@ _exit:
...
@@ -262,7 +284,7 @@ _exit:
terrno
=
code
;
terrno
=
code
;
}
}
return
(
code
==
TSDB_CODE_SUCCESS
)
&&
(
pIter
->
pS
s
tBlk
!=
NULL
);
return
(
code
==
TSDB_CODE_SUCCESS
)
&&
(
pIter
->
pS
t
tBlk
!=
NULL
);
}
}
SRowInfo
*
tLDataIterGet
(
SLDataIter
*
pIter
)
{
return
&
pIter
->
rInfo
;
}
SRowInfo
*
tLDataIterGet
(
SLDataIter
*
pIter
)
{
return
&
pIter
->
rInfo
;
}
...
@@ -290,7 +312,7 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
...
@@ -290,7 +312,7 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
}
}
}
}
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
uid
,
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
)
{
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
)
{
pMTree
->
backward
=
backward
;
pMTree
->
backward
=
backward
;
pMTree
->
pIter
=
NULL
;
pMTree
->
pIter
=
NULL
;
...
@@ -302,9 +324,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
...
@@ -302,9 +324,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
tRBTreeCreate
(
&
pMTree
->
rbt
,
tLDataIterCmprFn
);
int32_t
code
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
code
=
TSDB_CODE_OUT_OF_MEMORY
;
struct
SLDataIter
*
pIterList
[
TSDB_DEFAULT_S
S
T_FILE
]
=
{
0
};
struct
SLDataIter
*
pIterList
[
TSDB_DEFAULT_S
T
T_FILE
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nS
s
tF
;
++
i
)
{
// open all last file
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nS
t
tF
;
++
i
)
{
// open all last file
code
=
tLDataIterOpen
(
&
pIterList
[
i
],
pFReader
,
i
,
pMTree
->
backward
,
uid
,
pTimeWindow
,
pVerRange
);
code
=
tLDataIterOpen
(
&
pIterList
[
i
],
pFReader
,
i
,
pMTree
->
backward
,
suid
,
uid
,
pTimeWindow
,
pVerRange
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
goto
_end
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
d603faa4
...
@@ -226,16 +226,13 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
...
@@ -226,16 +226,13 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
return
NULL
;
return
NULL
;
}
}
int32_t
step
=
ASCENDING_TRAVERSE
(
pTsdbReader
->
order
)
?
1
:-
1
;
for
(
int32_t
j
=
0
;
j
<
numOfTables
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfTables
;
++
j
)
{
STableBlockScanInfo
info
=
{.
lastKey
=
0
,
.
uid
=
idList
[
j
].
uid
};
STableBlockScanInfo
info
=
{.
lastKey
=
0
,
.
uid
=
idList
[
j
].
uid
};
if
(
ASCENDING_TRAVERSE
(
pTsdbReader
->
order
))
{
if
(
ASCENDING_TRAVERSE
(
pTsdbReader
->
order
))
{
if
(
info
.
lastKey
==
INT64_MIN
||
info
.
lastKey
<
pTsdbReader
->
window
.
skey
)
{
info
.
lastKey
=
pTsdbReader
->
window
.
skey
-
step
;
info
.
lastKey
=
pTsdbReader
->
window
.
skey
;
}
ASSERT
(
info
.
lastKey
>=
pTsdbReader
->
window
.
skey
&&
info
.
lastKey
<=
pTsdbReader
->
window
.
ekey
);
}
else
{
}
else
{
info
.
lastKey
=
pTsdbReader
->
window
.
skey
;
info
.
lastKey
=
pTsdbReader
->
window
.
ekey
-
step
;
}
}
taosHashPut
(
pTableMap
,
&
info
.
uid
,
sizeof
(
uint64_t
),
&
info
,
sizeof
(
info
));
taosHashPut
(
pTableMap
,
&
info
.
uid
,
sizeof
(
uint64_t
),
&
info
,
sizeof
(
info
));
...
@@ -249,7 +246,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
...
@@ -249,7 +246,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
return
pTableMap
;
return
pTableMap
;
}
}
static
void
resetDataBlockScanInfo
(
SHashObj
*
pTableMap
)
{
static
void
resetDataBlockScanInfo
(
SHashObj
*
pTableMap
,
int64_t
ts
)
{
STableBlockScanInfo
*
p
=
NULL
;
STableBlockScanInfo
*
p
=
NULL
;
while
((
p
=
taosHashIterate
(
pTableMap
,
p
))
!=
NULL
)
{
while
((
p
=
taosHashIterate
(
pTableMap
,
p
))
!=
NULL
)
{
...
@@ -260,6 +257,7 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
...
@@ -260,6 +257,7 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
}
}
p
->
delSkyline
=
taosArrayDestroy
(
p
->
delSkyline
);
p
->
delSkyline
=
taosArrayDestroy
(
p
->
delSkyline
);
p
->
lastKey
=
ts
;
}
}
}
}
...
@@ -621,7 +619,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
...
@@ -621,7 +619,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
}
}
}
}
pBlockNum
->
numOfLastFiles
=
pReader
->
pFileReader
->
pSet
->
nS
s
tF
;
pBlockNum
->
numOfLastFiles
=
pReader
->
pFileReader
->
pSet
->
nS
t
tF
;
int32_t
total
=
pBlockNum
->
numOfLastFiles
+
pBlockNum
->
numOfBlocks
;
int32_t
total
=
pBlockNum
->
numOfLastFiles
+
pBlockNum
->
numOfBlocks
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
...
@@ -1163,7 +1161,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBloc
...
@@ -1163,7 +1161,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBloc
bool
overlapWithlastBlock
=
false
;
bool
overlapWithlastBlock
=
false
;
#if 0
#if 0
if (taosArrayGetSize(pLastBlockReader->pSstBlk) > 0 && (pLastBlockReader->currentBlockIndex != -1)) {
if (taosArrayGetSize(pLastBlockReader->pSstBlk) > 0 && (pLastBlockReader->currentBlockIndex != -1)) {
SS
s
tBlk* pSstBlk = taosArrayGet(pLastBlockReader->pSstBlk, pLastBlockReader->currentBlockIndex);
SS
t
tBlk* pSstBlk = taosArrayGet(pLastBlockReader->pSstBlk, pLastBlockReader->currentBlockIndex);
overlapWithlastBlock = !(pBlock->maxKey.ts < pSstBlk->minKey || pBlock->minKey.ts > pSstBlk->maxKey);
overlapWithlastBlock = !(pBlock->maxKey.ts < pSstBlk->minKey || pBlock->minKey.ts > pSstBlk->maxKey);
}
}
#endif
#endif
...
@@ -1380,7 +1378,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
...
@@ -1380,7 +1378,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
bool
mergeBlockData
)
{
bool
mergeBlockData
)
{
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
// SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
// SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
int64_t
tsLastBlock
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
int64_t
tsLastBlock
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
STSRow
*
pTSRow
=
NULL
;
STSRow
*
pTSRow
=
NULL
;
SRowMerger
merge
=
{
0
};
SRowMerger
merge
=
{
0
};
...
@@ -1430,6 +1428,10 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
...
@@ -1430,6 +1428,10 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
tRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
tRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tRowMerge
(
&
merge
,
&
fRow1
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
&
merge
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
&
merge
);
int32_t
code
=
tRowMergerGetRow
(
&
merge
,
&
pTSRow
);
int32_t
code
=
tRowMergerGetRow
(
&
merge
,
&
pTSRow
);
...
@@ -1779,7 +1781,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
...
@@ -1779,7 +1781,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
pBlockScanInfo
->
iter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iter
.
iter
)
!=
NULL
);
pBlockScanInfo
->
iter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iter
.
iter
)
!=
NULL
);
tsdbDebug
(
"%p uid:%"
PRId64
", check data in mem from skey:%"
PRId64
", order:%d, ts range in buf:%"
PRId64
tsdbDebug
(
"%p uid:%"
PRId64
", check data in mem from skey:%"
PRId64
", order:%d, ts range in buf:%"
PRId64
"-%"
PRId64
" %s"
,
"-%"
PRId64
" %s"
,
pReader
,
pBlockScanInfo
->
uid
,
startKey
.
ts
,
pReader
->
order
,
d
->
minKey
,
d
->
maxKey
,
pReader
->
idStr
);
pReader
,
pBlockScanInfo
->
uid
,
startKey
.
ts
,
pReader
->
order
,
d
->
minKey
,
d
->
maxKey
,
pReader
->
idStr
);
}
else
{
}
else
{
tsdbError
(
"%p uid:%"
PRId64
", failed to create iterator for imem, code:%s, %s"
,
pReader
,
pBlockScanInfo
->
uid
,
tsdbError
(
"%p uid:%"
PRId64
", failed to create iterator for imem, code:%s, %s"
,
pReader
,
pBlockScanInfo
->
uid
,
...
@@ -1800,7 +1802,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
...
@@ -1800,7 +1802,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
pBlockScanInfo
->
iiter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iiter
.
iter
)
!=
NULL
);
pBlockScanInfo
->
iiter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iiter
.
iter
)
!=
NULL
);
tsdbDebug
(
"%p uid:%"
PRId64
", check data in imem from skey:%"
PRId64
", order:%d, ts range in buf:%"
PRId64
tsdbDebug
(
"%p uid:%"
PRId64
", check data in imem from skey:%"
PRId64
", order:%d, ts range in buf:%"
PRId64
"-%"
PRId64
" %s"
,
"-%"
PRId64
" %s"
,
pReader
,
pBlockScanInfo
->
uid
,
startKey
.
ts
,
pReader
->
order
,
di
->
minKey
,
di
->
maxKey
,
pReader
->
idStr
);
pReader
,
pBlockScanInfo
->
uid
,
startKey
.
ts
,
pReader
->
order
,
di
->
minKey
,
di
->
maxKey
,
pReader
->
idStr
);
}
else
{
}
else
{
tsdbError
(
"%p uid:%"
PRId64
", failed to create iterator for mem, code:%s, %s"
,
pReader
,
pBlockScanInfo
->
uid
,
tsdbError
(
"%p uid:%"
PRId64
", failed to create iterator for mem, code:%s, %s"
,
pReader
,
pBlockScanInfo
->
uid
,
...
@@ -1850,7 +1852,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
...
@@ -1850,7 +1852,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
static
bool
outOfTimeWindow
(
int64_t
ts
,
STimeWindow
*
pWindow
)
{
return
(
ts
>
pWindow
->
ekey
)
||
(
ts
<
pWindow
->
skey
);
}
static
bool
outOfTimeWindow
(
int64_t
ts
,
STimeWindow
*
pWindow
)
{
return
(
ts
>
pWindow
->
ekey
)
||
(
ts
<
pWindow
->
skey
);
}
static
bool
nextRowFromLastBlocks
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
static
bool
nextRowFromLastBlocks
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
while
(
1
)
{
while
(
1
)
{
bool
hasVal
=
tMergeTreeNext
(
&
pLastBlockReader
->
mergeTree
);
bool
hasVal
=
tMergeTreeNext
(
&
pLastBlockReader
->
mergeTree
);
if
(
!
hasVal
)
{
if
(
!
hasVal
)
{
return
false
;
return
false
;
...
@@ -1862,61 +1864,6 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
...
@@ -1862,61 +1864,6 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
return
true
;
return
true
;
}
}
}
}
#if 0
*(pLastBlockReader->rowIndex) += step;
SBlockData* pBlockData = &pLastBlockReader->lastBlockData;
for (int32_t i = *(pLastBlockReader->rowIndex); i < pBlockData->nRow && i >= 0; i += step) {
if (pBlockData->aUid != NULL) {
if (asc) {
if (pBlockData->aUid[i] < pLastBlockReader->uid) {
continue;
} else if (pBlockData->aUid[i] > pLastBlockReader->uid) {
break;
}
} else {
if (pBlockData->aUid[i] > pLastBlockReader->uid) {
continue;
} else if (pBlockData->aUid[i] < pLastBlockReader->uid) {
break;
}
}
}
int64_t ts = pBlockData->aTSKEY[i];
if (ts < pLastBlockReader->window.skey) {
continue;
}
int64_t ver = pBlockData->aVersion[i];
if (ver < pLastBlockReader->verRange.minVer) {
continue;
}
// no data any more, todo opt handle desc case
if (ts > pLastBlockReader->window.ekey) {
continue;
}
// todo opt handle desc case
if (ver > pLastBlockReader->verRange.maxVer) {
continue;
}
TSDBKEY k = {.ts = ts, .version = ver};
if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) {
continue;
}
*(pLastBlockReader->rowIndex) = i;
return true;
}
// set all data is consumed in last block
setAllRowsChecked(pLastBlockReader);
return false;
#endif
}
}
static
bool
initLastBlockReader
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pBlockScanInfo
,
static
bool
initLastBlockReader
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pBlockScanInfo
,
...
@@ -1932,9 +1879,18 @@ static bool initLastBlockReader(SLastBlockReader* pLastBlockReader, STableBlockS
...
@@ -1932,9 +1879,18 @@ static bool initLastBlockReader(SLastBlockReader* pLastBlockReader, STableBlockS
initMemDataIterator
(
pBlockScanInfo
,
pReader
);
initMemDataIterator
(
pBlockScanInfo
,
pReader
);
pLastBlockReader
->
uid
=
pBlockScanInfo
->
uid
;
pLastBlockReader
->
uid
=
pBlockScanInfo
->
uid
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pLastBlockReader
->
order
)
?
1
:-
1
;
STimeWindow
w
=
pLastBlockReader
->
window
;
if
(
ASCENDING_TRAVERSE
(
pLastBlockReader
->
order
))
{
w
.
skey
=
pBlockScanInfo
->
lastKey
+
step
;
}
else
{
w
.
ekey
=
pBlockScanInfo
->
lastKey
+
step
;
}
int32_t
code
=
int32_t
code
=
tMergeTreeOpen
(
&
pLastBlockReader
->
mergeTree
,
(
pLastBlockReader
->
order
==
TSDB_ORDER_DESC
),
pReader
->
pFileReader
,
tMergeTreeOpen
(
&
pLastBlockReader
->
mergeTree
,
(
pLastBlockReader
->
order
==
TSDB_ORDER_DESC
),
pReader
->
pFileReader
,
pBlockScanInfo
->
uid
,
&
pLastBlockReader
->
windo
w
,
&
pLastBlockReader
->
verRange
);
pReader
->
suid
,
pBlockScanInfo
->
uid
,
&
w
,
&
pLastBlockReader
->
verRange
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
false
;
return
false
;
}
}
...
@@ -2166,7 +2122,7 @@ _err:
...
@@ -2166,7 +2122,7 @@ _err:
}
}
static
TSDBKEY
getCurrentKeyInBuf
(
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
)
{
static
TSDBKEY
getCurrentKeyInBuf
(
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
)
{
TSDBKEY
key
=
{.
ts
=
TSKEY_INITIAL_VAL
};
TSDBKEY
key
=
{.
ts
=
TSKEY_INITIAL_VAL
};
TSDBROW
*
pRow
=
getValidMemRow
(
&
pScanInfo
->
iter
,
pScanInfo
->
delSkyline
,
pReader
);
TSDBROW
*
pRow
=
getValidMemRow
(
&
pScanInfo
->
iter
,
pScanInfo
->
delSkyline
,
pReader
);
if
(
pRow
!=
NULL
)
{
if
(
pRow
!=
NULL
)
{
key
=
TSDBROW_KEY
(
pRow
);
key
=
TSDBROW_KEY
(
pRow
);
...
@@ -2204,7 +2160,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
...
@@ -2204,7 +2160,7 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
return
code
;
return
code
;
}
}
if
(
taosArrayGetSize
(
pIndexList
)
>
0
||
pReader
->
pFileReader
->
pSet
->
nS
s
tF
>
0
)
{
if
(
taosArrayGetSize
(
pIndexList
)
>
0
||
pReader
->
pFileReader
->
pSet
->
nS
t
tF
>
0
)
{
code
=
doLoadFileBlock
(
pReader
,
pIndexList
,
pBlockNum
);
code
=
doLoadFileBlock
(
pReader
,
pIndexList
,
pBlockNum
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosArrayDestroy
(
pIndexList
);
taosArrayDestroy
(
pIndexList
);
...
@@ -2314,7 +2270,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -2314,7 +2270,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
while
(
1
)
{
while
(
1
)
{
// load the last data block of current table
// load the last data block of current table
STableBlockScanInfo
*
pScanInfo
=
pStatus
->
pTableIter
;
STableBlockScanInfo
*
pScanInfo
=
pStatus
->
pTableIter
;
bool
hasVal
=
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
bool
hasVal
=
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
if
(
!
hasVal
)
{
if
(
!
hasVal
)
{
bool
hasNexTable
=
moveToNextTable
(
pOrderedCheckInfo
,
pStatus
);
bool
hasNexTable
=
moveToNextTable
(
pOrderedCheckInfo
,
pStatus
);
if
(
!
hasNexTable
)
{
if
(
!
hasNexTable
)
{
...
@@ -2537,22 +2493,24 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
...
@@ -2537,22 +2493,24 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
bool
hasNext
=
blockIteratorNext
(
&
pReader
->
status
.
blockIter
);
bool
hasNext
=
blockIteratorNext
(
&
pReader
->
status
.
blockIter
);
if
(
hasNext
)
{
// check for the next block in the block accessed order list
if
(
hasNext
)
{
// check for the next block in the block accessed order list
initBlockDumpInfo
(
pReader
,
pBlockIter
);
initBlockDumpInfo
(
pReader
,
pBlockIter
);
}
else
if
(
hasDataInLastBlock
(
pReader
->
status
.
fileIter
.
pLastBlockReader
))
{
// data blocks in current file are exhausted, let's try the next file now
tBlockDataReset
(
&
pReader
->
status
.
fileBlockData
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
goto
_begin
;
}
else
{
}
else
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
if
(
pReader
->
status
.
pCurrentFileset
->
nSttF
>
0
)
{
// data blocks in current file are exhausted, let's try the next file now
tBlockDataReset
(
&
pReader
->
status
.
fileBlockData
);
resetDataBlockIterator
(
pBlockIter
,
pReader
->
order
);
goto
_begin
;
}
else
{
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
// error happens or all the data files are completely checked
// error happens or all the data files are completely checked
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
return
code
;
return
code
;
}
}
// this file does not have blocks, let's start check the last block file
// this file does not have blocks, let's start check the last block file
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
if
(
pBlockIter
->
numOfBlocks
==
0
)
{
goto
_begin
;
goto
_begin
;
}
}
}
}
}
}
}
...
@@ -2898,6 +2856,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
...
@@ -2898,6 +2856,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
int32_t
doMergeRowsInLastBlock
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
int64_t
ts
,
int32_t
doMergeRowsInLastBlock
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
int64_t
ts
,
SRowMerger
*
pMerger
)
{
SRowMerger
*
pMerger
)
{
pScanInfo
->
lastKey
=
ts
;
while
(
nextRowFromLastBlocks
(
pLastBlockReader
,
pScanInfo
))
{
while
(
nextRowFromLastBlocks
(
pLastBlockReader
,
pScanInfo
))
{
int64_t
next1
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
int64_t
next1
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
if
(
next1
==
ts
)
{
if
(
next1
==
ts
)
{
...
@@ -3589,11 +3548,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
...
@@ -3589,11 +3548,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
int32_t
numOfTables
=
taosHashGetSize
(
pReader
->
status
.
pTableMap
);
int32_t
numOfTables
=
taosHashGetSize
(
pReader
->
status
.
pTableMap
);
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
);
resetDataBlockIterator
(
&
pReader
->
status
.
blockIter
,
pReader
->
order
);
resetDataBlockIterator
(
&
pReader
->
status
.
blockIter
,
pReader
->
order
);
resetDataBlockScanInfo
(
pReader
->
status
.
pTableMap
);
int64_t
ts
=
ASCENDING_TRAVERSE
(
pReader
->
order
)
?
pReader
->
window
.
skey
-
1
:
pReader
->
window
.
ekey
+
1
;
resetDataBlockScanInfo
(
pReader
->
status
.
pTableMap
,
ts
);
int32_t
code
=
0
;
int32_t
code
=
0
;
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
d603faa4
...
@@ -226,13 +226,13 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
...
@@ -226,13 +226,13 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
.
pHeadF
=
&
pWriter
->
fHead
,
.
pHeadF
=
&
pWriter
->
fHead
,
.
pDataF
=
&
pWriter
->
fData
,
.
pDataF
=
&
pWriter
->
fData
,
.
pSmaF
=
&
pWriter
->
fSma
,
.
pSmaF
=
&
pWriter
->
fSma
,
.
nS
stF
=
pSet
->
nSs
tF
};
.
nS
ttF
=
pSet
->
nSt
tF
};
pWriter
->
fHead
=
*
pSet
->
pHeadF
;
pWriter
->
fHead
=
*
pSet
->
pHeadF
;
pWriter
->
fData
=
*
pSet
->
pDataF
;
pWriter
->
fData
=
*
pSet
->
pDataF
;
pWriter
->
fSma
=
*
pSet
->
pSmaF
;
pWriter
->
fSma
=
*
pSet
->
pSmaF
;
for
(
int8_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int8_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
pWriter
->
wSet
.
aS
stF
[
iSst
]
=
&
pWriter
->
fSst
[
iSs
t
];
pWriter
->
wSet
.
aS
ttF
[
iStt
]
=
&
pWriter
->
fStt
[
iSt
t
];
pWriter
->
fS
st
[
iSst
]
=
*
pSet
->
aSstF
[
iSs
t
];
pWriter
->
fS
tt
[
iStt
]
=
*
pSet
->
aSttF
[
iSt
t
];
}
}
// head
// head
...
@@ -276,15 +276,15 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
...
@@ -276,15 +276,15 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
pWriter
->
fSma
.
size
+=
TSDB_FHDR_SIZE
;
pWriter
->
fSma
.
size
+=
TSDB_FHDR_SIZE
;
}
}
// s
s
t
// s
t
t
ASSERT
(
pWriter
->
fS
st
[
pSet
->
nSs
tF
-
1
].
size
==
0
);
ASSERT
(
pWriter
->
fS
tt
[
pSet
->
nSt
tF
-
1
].
size
==
0
);
flag
=
TD_FILE_READ
|
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
;
flag
=
TD_FILE_READ
|
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
;
tsdbS
stFileName
(
pTsdb
,
pWriter
->
wSet
.
diskId
,
pWriter
->
wSet
.
fid
,
&
pWriter
->
fSst
[
pSet
->
nSs
tF
-
1
],
fname
);
tsdbS
ttFileName
(
pTsdb
,
pWriter
->
wSet
.
diskId
,
pWriter
->
wSet
.
fid
,
&
pWriter
->
fStt
[
pSet
->
nSt
tF
-
1
],
fname
);
code
=
tsdbOpenFile
(
fname
,
szPage
,
flag
,
&
pWriter
->
pS
s
tFD
);
code
=
tsdbOpenFile
(
fname
,
szPage
,
flag
,
&
pWriter
->
pS
t
tFD
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
code
=
tsdbWriteFile
(
pWriter
->
pS
s
tFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
code
=
tsdbWriteFile
(
pWriter
->
pS
t
tFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
pWriter
->
fS
st
[
pWriter
->
wSet
.
nSs
tF
-
1
].
size
+=
TSDB_FHDR_SIZE
;
pWriter
->
fS
tt
[
pWriter
->
wSet
.
nSt
tF
-
1
].
size
+=
TSDB_FHDR_SIZE
;
*
ppWriter
=
pWriter
;
*
ppWriter
=
pWriter
;
return
code
;
return
code
;
...
@@ -312,14 +312,14 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) {
...
@@ -312,14 +312,14 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) {
code
=
tsdbFsyncFile
((
*
ppWriter
)
->
pSmaFD
);
code
=
tsdbFsyncFile
((
*
ppWriter
)
->
pSmaFD
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
code
=
tsdbFsyncFile
((
*
ppWriter
)
->
pS
s
tFD
);
code
=
tsdbFsyncFile
((
*
ppWriter
)
->
pS
t
tFD
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pHeadFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pHeadFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pDataFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pDataFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pSmaFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pSmaFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pS
s
tFD
);
tsdbCloseFile
(
&
(
*
ppWriter
)
->
pS
t
tFD
);
for
(
int32_t
iBuf
=
0
;
iBuf
<
sizeof
((
*
ppWriter
)
->
aBuf
)
/
sizeof
(
uint8_t
*
);
iBuf
++
)
{
for
(
int32_t
iBuf
=
0
;
iBuf
<
sizeof
((
*
ppWriter
)
->
aBuf
)
/
sizeof
(
uint8_t
*
);
iBuf
++
)
{
tFree
((
*
ppWriter
)
->
aBuf
[
iBuf
]);
tFree
((
*
ppWriter
)
->
aBuf
[
iBuf
]);
...
@@ -357,10 +357,10 @@ int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) {
...
@@ -357,10 +357,10 @@ int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) {
code
=
tsdbWriteFile
(
pWriter
->
pSmaFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
code
=
tsdbWriteFile
(
pWriter
->
pSmaFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// s
s
t ==============
// s
t
t ==============
memset
(
hdr
,
0
,
TSDB_FHDR_SIZE
);
memset
(
hdr
,
0
,
TSDB_FHDR_SIZE
);
tPutS
stFile
(
hdr
,
&
pWriter
->
fSst
[
pWriter
->
wSet
.
nSs
tF
-
1
]);
tPutS
ttFile
(
hdr
,
&
pWriter
->
fStt
[
pWriter
->
wSet
.
nSt
tF
-
1
]);
code
=
tsdbWriteFile
(
pWriter
->
pS
s
tFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
code
=
tsdbWriteFile
(
pWriter
->
pS
t
tFD
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
return
code
;
return
code
;
...
@@ -454,22 +454,22 @@ _err:
...
@@ -454,22 +454,22 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbWriteS
stBlk
(
SDataFWriter
*
pWriter
,
SArray
*
aSs
tBlk
)
{
int32_t
tsdbWriteS
ttBlk
(
SDataFWriter
*
pWriter
,
SArray
*
aSt
tBlk
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SS
stFile
*
pSstFile
=
&
pWriter
->
fSst
[
pWriter
->
wSet
.
nSs
tF
-
1
];
SS
ttFile
*
pSttFile
=
&
pWriter
->
fStt
[
pWriter
->
wSet
.
nSt
tF
-
1
];
int64_t
size
;
int64_t
size
;
int64_t
n
;
int64_t
n
;
// check
// check
if
(
taosArrayGetSize
(
aS
s
tBlk
)
==
0
)
{
if
(
taosArrayGetSize
(
aS
t
tBlk
)
==
0
)
{
pS
stFile
->
offset
=
pSs
tFile
->
size
;
pS
ttFile
->
offset
=
pSt
tFile
->
size
;
goto
_exit
;
goto
_exit
;
}
}
// size
// size
size
=
0
;
size
=
0
;
for
(
int32_t
iBlockL
=
0
;
iBlockL
<
taosArrayGetSize
(
aS
s
tBlk
);
iBlockL
++
)
{
for
(
int32_t
iBlockL
=
0
;
iBlockL
<
taosArrayGetSize
(
aS
t
tBlk
);
iBlockL
++
)
{
size
+=
tPutS
stBlk
(
NULL
,
taosArrayGet
(
aSs
tBlk
,
iBlockL
));
size
+=
tPutS
ttBlk
(
NULL
,
taosArrayGet
(
aSt
tBlk
,
iBlockL
));
}
}
// alloc
// alloc
...
@@ -478,21 +478,21 @@ int32_t tsdbWriteSstBlk(SDataFWriter *pWriter, SArray *aSstBlk) {
...
@@ -478,21 +478,21 @@ int32_t tsdbWriteSstBlk(SDataFWriter *pWriter, SArray *aSstBlk) {
// encode
// encode
n
=
0
;
n
=
0
;
for
(
int32_t
iBlockL
=
0
;
iBlockL
<
taosArrayGetSize
(
aS
s
tBlk
);
iBlockL
++
)
{
for
(
int32_t
iBlockL
=
0
;
iBlockL
<
taosArrayGetSize
(
aS
t
tBlk
);
iBlockL
++
)
{
n
+=
tPutS
stBlk
(
pWriter
->
aBuf
[
0
]
+
n
,
taosArrayGet
(
aSs
tBlk
,
iBlockL
));
n
+=
tPutS
ttBlk
(
pWriter
->
aBuf
[
0
]
+
n
,
taosArrayGet
(
aSt
tBlk
,
iBlockL
));
}
}
// write
// write
code
=
tsdbWriteFile
(
pWriter
->
pS
stFD
,
pSs
tFile
->
size
,
pWriter
->
aBuf
[
0
],
size
);
code
=
tsdbWriteFile
(
pWriter
->
pS
ttFD
,
pSt
tFile
->
size
,
pWriter
->
aBuf
[
0
],
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// update
// update
pS
stFile
->
offset
=
pSs
tFile
->
size
;
pS
ttFile
->
offset
=
pSt
tFile
->
size
;
pS
s
tFile
->
size
+=
size
;
pS
t
tFile
->
size
+=
size
;
_exit:
_exit:
tsdbTrace
(
"vgId:%d tsdb write s
s
t block, loffset:%"
PRId64
" size:%"
PRId64
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
tsdbTrace
(
"vgId:%d tsdb write s
t
t block, loffset:%"
PRId64
" size:%"
PRId64
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
pS
s
tFile
->
offset
,
size
);
pS
t
tFile
->
offset
,
size
);
return
code
;
return
code
;
_err:
_err:
...
@@ -546,7 +546,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
...
@@ -546,7 +546,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
ASSERT
(
pBlockData
->
nRow
>
0
);
ASSERT
(
pBlockData
->
nRow
>
0
);
if
(
toLast
)
{
if
(
toLast
)
{
pBlkInfo
->
offset
=
pWriter
->
fS
st
[
pWriter
->
wSet
.
nSs
tF
-
1
].
size
;
pBlkInfo
->
offset
=
pWriter
->
fS
tt
[
pWriter
->
wSet
.
nSt
tF
-
1
].
size
;
}
else
{
}
else
{
pBlkInfo
->
offset
=
pWriter
->
fData
.
size
;
pBlkInfo
->
offset
=
pWriter
->
fData
.
size
;
}
}
...
@@ -558,7 +558,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
...
@@ -558,7 +558,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// write =================
// write =================
STsdbFD
*
pFD
=
toLast
?
pWriter
->
pS
s
tFD
:
pWriter
->
pDataFD
;
STsdbFD
*
pFD
=
toLast
?
pWriter
->
pS
t
tFD
:
pWriter
->
pDataFD
;
pBlkInfo
->
szKey
=
aBufN
[
3
]
+
aBufN
[
2
];
pBlkInfo
->
szKey
=
aBufN
[
3
]
+
aBufN
[
2
];
pBlkInfo
->
szBlock
=
aBufN
[
0
]
+
aBufN
[
1
]
+
aBufN
[
2
]
+
aBufN
[
3
];
pBlkInfo
->
szBlock
=
aBufN
[
0
]
+
aBufN
[
1
]
+
aBufN
[
2
]
+
aBufN
[
3
];
...
@@ -585,7 +585,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
...
@@ -585,7 +585,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
// update info
// update info
if
(
toLast
)
{
if
(
toLast
)
{
pWriter
->
fS
st
[
pWriter
->
wSet
.
nSs
tF
-
1
].
size
+=
pBlkInfo
->
szBlock
;
pWriter
->
fS
tt
[
pWriter
->
wSet
.
nSt
tF
-
1
].
size
+=
pBlkInfo
->
szBlock
;
}
else
{
}
else
{
pWriter
->
fData
.
size
+=
pBlkInfo
->
szBlock
;
pWriter
->
fData
.
size
+=
pBlkInfo
->
szBlock
;
}
}
...
@@ -664,9 +664,9 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
...
@@ -664,9 +664,9 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
taosCloseFile
(
&
pOutFD
);
taosCloseFile
(
&
pOutFD
);
taosCloseFile
(
&
PInFD
);
taosCloseFile
(
&
PInFD
);
// s
s
t
// s
t
t
tsdbS
stFileName
(
pTsdb
,
pSetFrom
->
diskId
,
pSetFrom
->
fid
,
pSetFrom
->
aSs
tF
[
0
],
fNameFrom
);
tsdbS
ttFileName
(
pTsdb
,
pSetFrom
->
diskId
,
pSetFrom
->
fid
,
pSetFrom
->
aSt
tF
[
0
],
fNameFrom
);
tsdbS
stFileName
(
pTsdb
,
pSetTo
->
diskId
,
pSetTo
->
fid
,
pSetTo
->
aSs
tF
[
0
],
fNameTo
);
tsdbS
ttFileName
(
pTsdb
,
pSetTo
->
diskId
,
pSetTo
->
fid
,
pSetTo
->
aSt
tF
[
0
],
fNameTo
);
pOutFD
=
taosOpenFile
(
fNameTo
,
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
);
pOutFD
=
taosOpenFile
(
fNameTo
,
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
);
if
(
pOutFD
==
NULL
)
{
if
(
pOutFD
==
NULL
)
{
...
@@ -680,7 +680,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
...
@@ -680,7 +680,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
goto
_err
;
goto
_err
;
}
}
n
=
taosFSendFile
(
pOutFD
,
PInFD
,
0
,
pSetFrom
->
aS
s
tF
[
0
]
->
size
);
n
=
taosFSendFile
(
pOutFD
,
PInFD
,
0
,
pSetFrom
->
aS
t
tF
[
0
]
->
size
);
if
(
n
<
0
)
{
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
...
@@ -750,10 +750,10 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
...
@@ -750,10 +750,10 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
code
=
tsdbOpenFile
(
fname
,
szPage
,
TD_FILE_READ
,
&
pReader
->
pSmaFD
);
code
=
tsdbOpenFile
(
fname
,
szPage
,
TD_FILE_READ
,
&
pReader
->
pSmaFD
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// s
s
t
// s
t
t
for
(
int32_t
iS
st
=
0
;
iSst
<
pSet
->
nSstF
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
pSet
->
nSttF
;
iSt
t
++
)
{
tsdbS
stFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSstF
[
iSs
t
],
fname
);
tsdbS
ttFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSttF
[
iSt
t
],
fname
);
code
=
tsdbOpenFile
(
fname
,
szPage
,
TD_FILE_READ
,
&
pReader
->
aS
stFD
[
iSs
t
]);
code
=
tsdbOpenFile
(
fname
,
szPage
,
TD_FILE_READ
,
&
pReader
->
aS
ttFD
[
iSt
t
]);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
...
@@ -779,10 +779,10 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
...
@@ -779,10 +779,10 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
// sma
// sma
tsdbCloseFile
(
&
(
*
ppReader
)
->
pSmaFD
);
tsdbCloseFile
(
&
(
*
ppReader
)
->
pSmaFD
);
// s
s
t
// s
t
t
for
(
int32_t
iS
st
=
0
;
iSst
<
TSDB_MAX_SST_FILE
;
iSs
t
++
)
{
for
(
int32_t
iS
tt
=
0
;
iStt
<
TSDB_MAX_STT_FILE
;
iSt
t
++
)
{
if
((
*
ppReader
)
->
aS
stFD
[
iSs
t
])
{
if
((
*
ppReader
)
->
aS
ttFD
[
iSt
t
])
{
tsdbCloseFile
(
&
(
*
ppReader
)
->
aS
stFD
[
iSs
t
]);
tsdbCloseFile
(
&
(
*
ppReader
)
->
aS
ttFD
[
iSt
t
]);
}
}
}
}
...
@@ -835,13 +835,13 @@ _err:
...
@@ -835,13 +835,13 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbReadS
stBlk
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SArray
*
aSs
tBlk
)
{
int32_t
tsdbReadS
ttBlk
(
SDataFReader
*
pReader
,
int32_t
iStt
,
SArray
*
aSt
tBlk
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SS
stFile
*
pSstFile
=
pReader
->
pSet
->
aSstF
[
iSs
t
];
SS
ttFile
*
pSttFile
=
pReader
->
pSet
->
aSttF
[
iSt
t
];
int64_t
offset
=
pS
s
tFile
->
offset
;
int64_t
offset
=
pS
t
tFile
->
offset
;
int64_t
size
=
pS
s
tFile
->
size
-
offset
;
int64_t
size
=
pS
t
tFile
->
size
-
offset
;
taosArrayClear
(
aS
s
tBlk
);
taosArrayClear
(
aS
t
tBlk
);
if
(
size
==
0
)
return
code
;
if
(
size
==
0
)
return
code
;
// alloc
// alloc
...
@@ -849,16 +849,16 @@ int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) {
...
@@ -849,16 +849,16 @@ int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) {
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// read
// read
code
=
tsdbReadFile
(
pReader
->
aS
stFD
[
iSs
t
],
offset
,
pReader
->
aBuf
[
0
],
size
);
code
=
tsdbReadFile
(
pReader
->
aS
ttFD
[
iSt
t
],
offset
,
pReader
->
aBuf
[
0
],
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// decode
// decode
int64_t
n
=
0
;
int64_t
n
=
0
;
while
(
n
<
size
)
{
while
(
n
<
size
)
{
SS
stBlk
ss
tBlk
;
SS
ttBlk
st
tBlk
;
n
+=
tGetS
stBlk
(
pReader
->
aBuf
[
0
]
+
n
,
&
ss
tBlk
);
n
+=
tGetS
ttBlk
(
pReader
->
aBuf
[
0
]
+
n
,
&
st
tBlk
);
if
(
taosArrayPush
(
aS
stBlk
,
&
ss
tBlk
)
==
NULL
)
{
if
(
taosArrayPush
(
aS
ttBlk
,
&
st
tBlk
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
...
@@ -868,7 +868,7 @@ int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) {
...
@@ -868,7 +868,7 @@ int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) {
return
code
;
return
code
;
_err:
_err:
tsdbError
(
"vgId:%d read s
s
t blk failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d read s
t
t blk failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
return
code
;
}
}
...
@@ -1107,25 +1107,25 @@ _err:
...
@@ -1107,25 +1107,25 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbReadS
stBlock
(
SDataFReader
*
pReader
,
int32_t
iSst
,
SSstBlk
*
pSs
tBlk
,
SBlockData
*
pBlockData
)
{
int32_t
tsdbReadS
ttBlock
(
SDataFReader
*
pReader
,
int32_t
iStt
,
SSttBlk
*
pSt
tBlk
,
SBlockData
*
pBlockData
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
// alloc
// alloc
code
=
tRealloc
(
&
pReader
->
aBuf
[
0
],
pS
s
tBlk
->
bInfo
.
szBlock
);
code
=
tRealloc
(
&
pReader
->
aBuf
[
0
],
pS
t
tBlk
->
bInfo
.
szBlock
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// read
// read
code
=
tsdbReadFile
(
pReader
->
aS
stFD
[
iSst
],
pSstBlk
->
bInfo
.
offset
,
pReader
->
aBuf
[
0
],
pSs
tBlk
->
bInfo
.
szBlock
);
code
=
tsdbReadFile
(
pReader
->
aS
ttFD
[
iStt
],
pSttBlk
->
bInfo
.
offset
,
pReader
->
aBuf
[
0
],
pSt
tBlk
->
bInfo
.
szBlock
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// decmpr
// decmpr
code
=
tDecmprBlockData
(
pReader
->
aBuf
[
0
],
pS
s
tBlk
->
bInfo
.
szBlock
,
pBlockData
,
&
pReader
->
aBuf
[
1
]);
code
=
tDecmprBlockData
(
pReader
->
aBuf
[
0
],
pS
t
tBlk
->
bInfo
.
szBlock
,
pBlockData
,
&
pReader
->
aBuf
[
1
]);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
return
code
;
return
code
;
_err:
_err:
tsdbError
(
"vgId:%d tsdb read s
s
t block failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d tsdb read s
t
t block failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
return
code
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRetention.c
浏览文件 @
d603faa4
...
@@ -60,7 +60,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
...
@@ -60,7 +60,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
if
(
expLevel
<
0
)
{
if
(
expLevel
<
0
)
{
taosMemoryFree
(
pSet
->
pHeadF
);
taosMemoryFree
(
pSet
->
pHeadF
);
taosMemoryFree
(
pSet
->
pDataF
);
taosMemoryFree
(
pSet
->
pDataF
);
taosMemoryFree
(
pSet
->
aS
s
tF
[
0
]);
taosMemoryFree
(
pSet
->
aS
t
tF
[
0
]);
taosMemoryFree
(
pSet
->
pSmaF
);
taosMemoryFree
(
pSet
->
pSmaF
);
taosArrayRemove
(
fs
.
aDFileSet
,
iSet
);
taosArrayRemove
(
fs
.
aDFileSet
,
iSet
);
iSet
--
;
iSet
--
;
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
d603faa4
...
@@ -27,9 +27,9 @@ struct STsdbSnapReader {
...
@@ -27,9 +27,9 @@ struct STsdbSnapReader {
int32_t
fid
;
int32_t
fid
;
SDataFReader
*
pDataFReader
;
SDataFReader
*
pDataFReader
;
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
SArray
*
aBlockIdx
;
// SArray<SBlockIdx>
SArray
*
aSstBlk
;
// SArray<SS
s
tBlk>
SArray
*
aSstBlk
;
// SArray<SS
t
tBlk>
SBlockIdx
*
pBlockIdx
;
SBlockIdx
*
pBlockIdx
;
SS
s
tBlk
*
pSstBlk
;
SS
t
tBlk
*
pSstBlk
;
int32_t
iBlockIdx
;
int32_t
iBlockIdx
;
int32_t
iBlockL
;
int32_t
iBlockL
;
...
@@ -64,7 +64,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
...
@@ -64,7 +64,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
code
=
tsdbReadBlockIdx
(
pReader
->
pDataFReader
,
pReader
->
aBlockIdx
);
code
=
tsdbReadBlockIdx
(
pReader
->
pDataFReader
,
pReader
->
aBlockIdx
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
code
=
tsdbReadS
s
tBlk
(
pReader
->
pDataFReader
,
0
,
pReader
->
aSstBlk
);
code
=
tsdbReadS
t
tBlk
(
pReader
->
pDataFReader
,
0
,
pReader
->
aSstBlk
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// init
// init
...
@@ -87,7 +87,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
...
@@ -87,7 +87,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
break
;
break
;
}
}
pReader
->
pSstBlk
=
(
SS
s
tBlk
*
)
taosArrayGet
(
pReader
->
aSstBlk
,
pReader
->
iBlockL
);
pReader
->
pSstBlk
=
(
SS
t
tBlk
*
)
taosArrayGet
(
pReader
->
aSstBlk
,
pReader
->
iBlockL
);
if
(
pReader
->
pSstBlk
->
minVer
<=
pReader
->
ever
&&
pReader
->
pSstBlk
->
maxVer
>=
pReader
->
sver
)
{
if
(
pReader
->
pSstBlk
->
minVer
<=
pReader
->
ever
&&
pReader
->
pSstBlk
->
maxVer
>=
pReader
->
sver
)
{
// TODO
// TODO
break
;
break
;
...
@@ -151,7 +151,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
...
@@ -151,7 +151,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
// next
// next
pReader
->
iBlockL
++
;
pReader
->
iBlockL
++
;
if
(
pReader
->
iBlockL
<
taosArrayGetSize
(
pReader
->
aSstBlk
))
{
if
(
pReader
->
iBlockL
<
taosArrayGetSize
(
pReader
->
aSstBlk
))
{
pReader
->
pSstBlk
=
(
SS
s
tBlk
*
)
taosArrayGetSize
(
pReader
->
aSstBlk
);
pReader
->
pSstBlk
=
(
SS
t
tBlk
*
)
taosArrayGetSize
(
pReader
->
aSstBlk
);
}
else
{
}
else
{
pReader
->
pSstBlk
=
NULL
;
pReader
->
pSstBlk
=
NULL
;
}
}
...
@@ -298,7 +298,7 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
...
@@ -298,7 +298,7 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
pReader
->
aSstBlk
=
taosArrayInit
(
0
,
sizeof
(
SS
s
tBlk
));
pReader
->
aSstBlk
=
taosArrayInit
(
0
,
sizeof
(
SS
t
tBlk
));
if
(
pReader
->
aSstBlk
==
NULL
)
{
if
(
pReader
->
aSstBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
@@ -431,7 +431,7 @@ struct STsdbSnapWriter {
...
@@ -431,7 +431,7 @@ struct STsdbSnapWriter {
SBlockData
*
pBlockData
;
SBlockData
*
pBlockData
;
int32_t
iRow
;
int32_t
iRow
;
SBlockData
bDataR
;
SBlockData
bDataR
;
SArray
*
aSstBlk
;
// SArray<SS
s
tBlk>
SArray
*
aSstBlk
;
// SArray<SS
t
tBlk>
int32_t
iBlockL
;
int32_t
iBlockL
;
SBlockData
lDataR
;
SBlockData
lDataR
;
...
@@ -443,7 +443,7 @@ struct STsdbSnapWriter {
...
@@ -443,7 +443,7 @@ struct STsdbSnapWriter {
SMapData
mBlockW
;
// SMapData<SDataBlk>
SMapData
mBlockW
;
// SMapData<SDataBlk>
SArray
*
aBlockIdxW
;
// SArray<SBlockIdx>
SArray
*
aBlockIdxW
;
// SArray<SBlockIdx>
SArray
*
aBlockLW
;
// SArray<SS
s
tBlk>
SArray
*
aBlockLW
;
// SArray<SS
t
tBlk>
// for del file
// for del file
SDelFReader
*
pDelFReader
;
SDelFReader
*
pDelFReader
;
...
@@ -845,7 +845,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
...
@@ -845,7 +845,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
// write remain stuff
// write remain stuff
if
(
taosArrayGetSize
(
pWriter
->
aBlockLW
)
>
0
)
{
if
(
taosArrayGetSize
(
pWriter
->
aBlockLW
)
>
0
)
{
code
=
tsdbWriteS
s
tBlk
(
pWriter
->
pDataFWriter
,
pWriter
->
aBlockIdxW
);
code
=
tsdbWriteS
t
tBlk
(
pWriter
->
pDataFWriter
,
pWriter
->
aBlockIdxW
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
...
@@ -911,7 +911,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
...
@@ -911,7 +911,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
code
=
tsdbReadBlockIdx
(
pWriter
->
pDataFReader
,
pWriter
->
aBlockIdx
);
code
=
tsdbReadBlockIdx
(
pWriter
->
pDataFReader
,
pWriter
->
aBlockIdx
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
code
=
tsdbReadS
s
tBlk
(
pWriter
->
pDataFReader
,
0
,
pWriter
->
aSstBlk
);
code
=
tsdbReadS
t
tBlk
(
pWriter
->
pDataFReader
,
0
,
pWriter
->
aSstBlk
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
else
{
}
else
{
ASSERT
(
pWriter
->
pDataFReader
==
NULL
);
ASSERT
(
pWriter
->
pDataFReader
==
NULL
);
...
@@ -931,25 +931,25 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
...
@@ -931,25 +931,25 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
// write
// write
SHeadFile
fHead
;
SHeadFile
fHead
;
SDataFile
fData
;
SDataFile
fData
;
SS
s
tFile
fLast
;
SS
t
tFile
fLast
;
SSmaFile
fSma
;
SSmaFile
fSma
;
SDFileSet
wSet
=
{.
pHeadF
=
&
fHead
,
.
pDataF
=
&
fData
,
.
aS
s
tF
[
0
]
=
&
fLast
,
.
pSmaF
=
&
fSma
};
SDFileSet
wSet
=
{.
pHeadF
=
&
fHead
,
.
pDataF
=
&
fData
,
.
aS
t
tF
[
0
]
=
&
fLast
,
.
pSmaF
=
&
fSma
};
if
(
pSet
)
{
if
(
pSet
)
{
wSet
.
diskId
=
pSet
->
diskId
;
wSet
.
diskId
=
pSet
->
diskId
;
wSet
.
fid
=
fid
;
wSet
.
fid
=
fid
;
wSet
.
nS
s
tF
=
1
;
wSet
.
nS
t
tF
=
1
;
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
};
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
};
fData
=
*
pSet
->
pDataF
;
fData
=
*
pSet
->
pDataF
;
fLast
=
(
SS
s
tFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fLast
=
(
SS
t
tFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fSma
=
*
pSet
->
pSmaF
;
fSma
=
*
pSet
->
pSmaF
;
}
else
{
}
else
{
wSet
.
diskId
=
(
SDiskID
){.
level
=
0
,
.
id
=
0
};
wSet
.
diskId
=
(
SDiskID
){.
level
=
0
,
.
id
=
0
};
wSet
.
fid
=
fid
;
wSet
.
fid
=
fid
;
wSet
.
nS
s
tF
=
1
;
wSet
.
nS
t
tF
=
1
;
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
};
fHead
=
(
SHeadFile
){.
commitID
=
pWriter
->
commitID
,
.
offset
=
0
,
.
size
=
0
};
fData
=
(
SDataFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fData
=
(
SDataFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fLast
=
(
SS
s
tFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
,
.
offset
=
0
};
fLast
=
(
SS
t
tFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
,
.
offset
=
0
};
fSma
=
(
SSmaFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
fSma
=
(
SSmaFile
){.
commitID
=
pWriter
->
commitID
,
.
size
=
0
};
}
}
...
@@ -1147,7 +1147,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
...
@@ -1147,7 +1147,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
code
=
tBlockDataCreate
(
&
pWriter
->
bDataR
);
code
=
tBlockDataCreate
(
&
pWriter
->
bDataR
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
pWriter
->
aSstBlk
=
taosArrayInit
(
0
,
sizeof
(
SS
s
tBlk
));
pWriter
->
aSstBlk
=
taosArrayInit
(
0
,
sizeof
(
SS
t
tBlk
));
if
(
pWriter
->
aSstBlk
==
NULL
)
{
if
(
pWriter
->
aSstBlk
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
@@ -1161,7 +1161,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
...
@@ -1161,7 +1161,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
code
=
tBlockDataCreate
(
&
pWriter
->
bDataW
);
code
=
tBlockDataCreate
(
&
pWriter
->
bDataW
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
pWriter
->
aBlockLW
=
taosArrayInit
(
0
,
sizeof
(
SS
s
tBlk
));
pWriter
->
aBlockLW
=
taosArrayInit
(
0
,
sizeof
(
SS
t
tBlk
));
if
(
pWriter
->
aBlockLW
==
NULL
)
{
if
(
pWriter
->
aBlockLW
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
d603faa4
...
@@ -214,7 +214,7 @@ int32_t tCmprBlockIdx(void const *lhs, void const *rhs) {
...
@@ -214,7 +214,7 @@ int32_t tCmprBlockIdx(void const *lhs, void const *rhs) {
int32_t
tCmprBlockL
(
void
const
*
lhs
,
void
const
*
rhs
)
{
int32_t
tCmprBlockL
(
void
const
*
lhs
,
void
const
*
rhs
)
{
SBlockIdx
*
lBlockIdx
=
(
SBlockIdx
*
)
lhs
;
SBlockIdx
*
lBlockIdx
=
(
SBlockIdx
*
)
lhs
;
SS
stBlk
*
rBlockL
=
(
SSs
tBlk
*
)
rhs
;
SS
ttBlk
*
rBlockL
=
(
SSt
tBlk
*
)
rhs
;
if
(
lBlockIdx
->
suid
<
rBlockL
->
suid
)
{
if
(
lBlockIdx
->
suid
<
rBlockL
->
suid
)
{
return
-
1
;
return
-
1
;
...
@@ -311,41 +311,41 @@ bool tDataBlkHasSma(SDataBlk *pDataBlk) {
...
@@ -311,41 +311,41 @@ bool tDataBlkHasSma(SDataBlk *pDataBlk) {
return
pDataBlk
->
smaInfo
.
size
>
0
;
return
pDataBlk
->
smaInfo
.
size
>
0
;
}
}
// SS
s
tBlk ======================================================
// SS
t
tBlk ======================================================
int32_t
tPutS
s
tBlk
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
tPutS
t
tBlk
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
SS
stBlk
*
pSstBlk
=
(
SSs
tBlk
*
)
ph
;
SS
ttBlk
*
pSttBlk
=
(
SSt
tBlk
*
)
ph
;
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
suid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
suid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
minUid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
minUid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
maxUid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
maxUid
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
minKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
minKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
maxKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
maxKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
minVer
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
minVer
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
maxVer
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
maxVer
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
nRow
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
nRow
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
bInfo
.
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
bInfo
.
offset
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
bInfo
.
szBlock
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
bInfo
.
szBlock
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
s
tBlk
->
bInfo
.
szKey
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pS
t
tBlk
->
bInfo
.
szKey
);
return
n
;
return
n
;
}
}
int32_t
tGetS
s
tBlk
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
tGetS
t
tBlk
(
uint8_t
*
p
,
void
*
ph
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
SS
stBlk
*
pSstBlk
=
(
SSs
tBlk
*
)
ph
;
SS
ttBlk
*
pSttBlk
=
(
SSt
tBlk
*
)
ph
;
n
+=
tGetI64
(
p
+
n
,
&
pS
s
tBlk
->
suid
);
n
+=
tGetI64
(
p
+
n
,
&
pS
t
tBlk
->
suid
);
n
+=
tGetI64
(
p
+
n
,
&
pS
s
tBlk
->
minUid
);
n
+=
tGetI64
(
p
+
n
,
&
pS
t
tBlk
->
minUid
);
n
+=
tGetI64
(
p
+
n
,
&
pS
s
tBlk
->
maxUid
);
n
+=
tGetI64
(
p
+
n
,
&
pS
t
tBlk
->
maxUid
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tBlk
->
minKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tBlk
->
minKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tBlk
->
maxKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tBlk
->
maxKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tBlk
->
minVer
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tBlk
->
minVer
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tBlk
->
maxVer
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tBlk
->
maxVer
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
s
tBlk
->
nRow
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
t
tBlk
->
nRow
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
s
tBlk
->
bInfo
.
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pS
t
tBlk
->
bInfo
.
offset
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
s
tBlk
->
bInfo
.
szBlock
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
t
tBlk
->
bInfo
.
szBlock
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
s
tBlk
->
bInfo
.
szKey
);
n
+=
tGetI32v
(
p
+
n
,
&
pS
t
tBlk
->
bInfo
.
szKey
);
return
n
;
return
n
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
d603faa4
...
@@ -39,7 +39,7 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
...
@@ -39,7 +39,7 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
SSubmitBlkRsp
r
=
{
0
};
SSubmitBlkRsp
r
=
{
0
};
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
);
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
);
if
(
pBlock
==
NULL
)
break
;
if
(
pBlock
==
NULL
)
break
;
if
(
tsdbInsertTableData
(
pTsdb
,
version
,
&
msgIter
,
pBlock
,
&
r
)
<
0
)
{
if
(
(
terrno
=
tsdbInsertTableData
(
pTsdb
,
version
,
&
msgIter
,
pBlock
,
&
r
)
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
d603faa4
...
@@ -534,7 +534,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
...
@@ -534,7 +534,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
}
}
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
true
);
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
true
);
if
(
tdUpdateTbUidList
(
pVnode
->
pSma
,
pStore
)
<
0
)
{
if
(
tdUpdateTbUidList
(
pVnode
->
pSma
,
pStore
,
true
)
<
0
)
{
goto
_exit
;
goto
_exit
;
}
}
tdUidStoreFree
(
pStore
);
tdUidStoreFree
(
pStore
);
...
@@ -692,6 +692,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
...
@@ -692,6 +692,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
int32_t
ret
;
int32_t
ret
;
SArray
*
tbUids
=
NULL
;
SArray
*
tbUids
=
NULL
;
STbUidStore
*
pStore
=
NULL
;
pRsp
->
msgType
=
TDMT_VND_DROP_TABLE_RSP
;
pRsp
->
msgType
=
TDMT_VND_DROP_TABLE_RSP
;
pRsp
->
pCont
=
NULL
;
pRsp
->
pCont
=
NULL
;
...
@@ -715,9 +716,10 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
...
@@ -715,9 +716,10 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
for
(
int32_t
iReq
=
0
;
iReq
<
req
.
nReqs
;
iReq
++
)
{
for
(
int32_t
iReq
=
0
;
iReq
<
req
.
nReqs
;
iReq
++
)
{
SVDropTbReq
*
pDropTbReq
=
req
.
pReqs
+
iReq
;
SVDropTbReq
*
pDropTbReq
=
req
.
pReqs
+
iReq
;
SVDropTbRsp
dropTbRsp
=
{
0
};
SVDropTbRsp
dropTbRsp
=
{
0
};
tb_uid_t
tbUid
=
0
;
/* code */
/* code */
ret
=
metaDropTable
(
pVnode
->
pMeta
,
version
,
pDropTbReq
,
tbUids
);
ret
=
metaDropTable
(
pVnode
->
pMeta
,
version
,
pDropTbReq
,
tbUids
,
&
tbUid
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
pDropTbReq
->
igNotExists
&&
terrno
==
TSDB_CODE_VND_TABLE_NOT_EXIST
)
{
if
(
pDropTbReq
->
igNotExists
&&
terrno
==
TSDB_CODE_VND_TABLE_NOT_EXIST
)
{
dropTbRsp
.
code
=
TSDB_CODE_SUCCESS
;
dropTbRsp
.
code
=
TSDB_CODE_SUCCESS
;
...
@@ -726,15 +728,18 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
...
@@ -726,15 +728,18 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
}
}
}
else
{
}
else
{
dropTbRsp
.
code
=
TSDB_CODE_SUCCESS
;
dropTbRsp
.
code
=
TSDB_CODE_SUCCESS
;
if
(
tbUid
>
0
)
tdFetchTbUidList
(
pVnode
->
pSma
,
&
pStore
,
pDropTbReq
->
suid
,
tbUid
);
}
}
taosArrayPush
(
rsp
.
pArray
,
&
dropTbRsp
);
taosArrayPush
(
rsp
.
pArray
,
&
dropTbRsp
);
}
}
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
false
);
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
false
);
tdUpdateTbUidList
(
pVnode
->
pSma
,
pStore
,
false
);
_exit:
_exit:
taosArrayDestroy
(
tbUids
);
taosArrayDestroy
(
tbUids
);
tdUidStoreFree
(
pStore
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tEncodeSize
(
tEncodeSVDropTbBatchRsp
,
&
rsp
,
pRsp
->
contLen
,
ret
);
tEncodeSize
(
tEncodeSVDropTbBatchRsp
,
&
rsp
,
pRsp
->
contLen
,
ret
);
pRsp
->
pCont
=
rpcMallocCont
(
pRsp
->
contLen
);
pRsp
->
pCont
=
rpcMallocCont
(
pRsp
->
contLen
);
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
d603faa4
...
@@ -367,18 +367,22 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
...
@@ -367,18 +367,22 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
int32_t
stbNum
=
dbCache
->
stbCache
?
taosHashGetSize
(
dbCache
->
stbCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
stbCache
?
taosHashGetSize
(
dbCache
->
stbCache
)
:
0
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
hashMethod
=
-
1
;
int32_t
hashMethod
=
-
1
;
int16_t
hashPrefix
=
0
;
int16_t
hashSuffix
=
0
;
int32_t
vgNum
=
0
;
int32_t
vgNum
=
0
;
if
(
dbCache
->
vgCache
.
vgInfo
)
{
if
(
dbCache
->
vgCache
.
vgInfo
)
{
vgVersion
=
dbCache
->
vgCache
.
vgInfo
->
vgVersion
;
vgVersion
=
dbCache
->
vgCache
.
vgInfo
->
vgVersion
;
hashMethod
=
dbCache
->
vgCache
.
vgInfo
->
hashMethod
;
hashMethod
=
dbCache
->
vgCache
.
vgInfo
->
hashMethod
;
hashPrefix
=
dbCache
->
vgCache
.
vgInfo
->
hashPrefix
;
hashSuffix
=
dbCache
->
vgCache
.
vgInfo
->
hashSuffix
;
if
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
)
{
if
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
)
{
vgNum
=
taosHashGetSize
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
);
vgNum
=
taosHashGetSize
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
);
}
}
}
}
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d,
prefix:%d, suffix:%d,
vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
d603faa4
...
@@ -848,15 +848,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
...
@@ -848,15 +848,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
}
}
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pTableName
,
tbFullName
);
tNameExtractFullName
(
pTableName
,
tbFullName
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
)
);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
...
@@ -919,11 +915,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
...
@@ -919,11 +915,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
int32_t
tbNum
=
taosArrayGetSize
(
pNames
);
int32_t
tbNum
=
taosArrayGetSize
(
pNames
);
if
(
1
==
vgNum
)
{
if
(
1
==
vgNum
)
{
...
@@ -975,7 +967,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
...
@@ -975,7 +967,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
tbNameLen
=
offset
+
strlen
(
pName
->
tname
);
tbNameLen
=
offset
+
strlen
(
pName
->
tname
);
strcpy
(
tbFullName
+
offset
,
pName
->
tname
);
strcpy
(
tbFullName
+
offset
,
pName
->
tname
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
tbNameLen
);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
SVgroupInfo
**
p
=
taosArraySearch
(
pVgList
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
SVgroupInfo
**
p
=
taosArraySearch
(
pVgList
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
d603faa4
...
@@ -218,6 +218,8 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) {
...
@@ -218,6 +218,8 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) {
ctgTestCurrentVgVersion
=
dbVgroup
->
vgVersion
;
ctgTestCurrentVgVersion
=
dbVgroup
->
vgVersion
;
dbVgroup
->
hashMethod
=
0
;
dbVgroup
->
hashMethod
=
0
;
dbVgroup
->
hashPrefix
=
0
;
dbVgroup
->
hashSuffix
=
0
;
dbVgroup
->
vgHash
=
taosHashInit
(
ctgTestVgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
dbVgroup
->
vgHash
=
taosHashInit
(
ctgTestVgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
vgNum
=
ctgTestGetVgNumFromVgVersion
(
dbVgroup
->
vgVersion
);
vgNum
=
ctgTestGetVgNumFromVgVersion
(
dbVgroup
->
vgVersion
);
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
d603faa4
...
@@ -38,6 +38,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
...
@@ -38,6 +38,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
pOut
->
dbVgroup
->
vgVersion
=
usedbRsp
->
vgVersion
;
pOut
->
dbVgroup
->
vgVersion
=
usedbRsp
->
vgVersion
;
pOut
->
dbVgroup
->
hashMethod
=
usedbRsp
->
hashMethod
;
pOut
->
dbVgroup
->
hashMethod
=
usedbRsp
->
hashMethod
;
pOut
->
dbVgroup
->
hashPrefix
=
usedbRsp
->
hashPrefix
;
pOut
->
dbVgroup
->
hashSuffix
=
usedbRsp
->
hashSuffix
;
qDebug
(
"Got %d vgroup for db %s"
,
usedbRsp
->
vgNum
,
usedbRsp
->
db
);
qDebug
(
"Got %d vgroup for db %s"
,
usedbRsp
->
vgNum
,
usedbRsp
->
db
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录