Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d40f37b5
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d40f37b5
编写于
9月 22, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate sma to smad and smal
上级
24cbab3e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
113 addition
and
36 deletion
+113
-36
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+9
-1
src/tsdb/inc/tsdbReadImpl.h
src/tsdb/inc/tsdbReadImpl.h
+3
-2
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+88
-23
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+5
-3
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+7
-6
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+1
-1
未找到文件。
src/tsdb/inc/tsdbFile.h
浏览文件 @
d40f37b5
...
@@ -38,7 +38,15 @@
...
@@ -38,7 +38,15 @@
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
#define TSDB_FSET_NFILES_VALID(s) (((s)->nFiles >= TSDB_FILE_MIN) && ((s)->nFiles <= TSDB_FILE_MAX))
#define TSDB_FSET_NFILES_VALID(s) (((s)->nFiles >= TSDB_FILE_MIN) && ((s)->nFiles <= TSDB_FILE_MAX))
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
TSDB_FILE_DATA
,
TSDB_FILE_LAST
,
TSDB_FILE_SMA
,
TSDB_FILE_MAX
,
TSDB_FILE_META
}
TSDB_FILE_T
;
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
TSDB_FILE_DATA
,
TSDB_FILE_LAST
,
TSDB_FILE_SMAD
,
// sma for .data
TSDB_FILE_SMAL
,
// sma for .last
TSDB_FILE_MAX
,
TSDB_FILE_META
}
TSDB_FILE_T
;
#define TSDB_FILE_MIN 3U // min number of files in one DFileSet
#define TSDB_FILE_MIN 3U // min number of files in one DFileSet
...
...
src/tsdb/inc/tsdbReadImpl.h
浏览文件 @
d40f37b5
...
@@ -126,7 +126,7 @@ typedef struct {
...
@@ -126,7 +126,7 @@ typedef struct {
int32_t
len
;
int32_t
len
;
uint32_t
type
:
8
;
uint32_t
type
:
8
;
uint32_t
offset
:
24
;
uint32_t
offset
:
24
;
char
padding
[];
//
char padding[];
}
SBlockColV1
;
}
SBlockColV1
;
#define SBlockCol SBlockColV1 // latest SBlockCol definition
#define SBlockCol SBlockColV1 // latest SBlockCol definition
...
@@ -191,7 +191,8 @@ struct SReadH {
...
@@ -191,7 +191,8 @@ struct SReadH {
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_AGGR_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMA)
#define TSDB_READ_SMAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAD)
#define TSDB_READ_SMAL_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAL)
#define TSDB_READ_BUF(rh) ((rh)->pBuf)
#define TSDB_READ_BUF(rh) ((rh)->pBuf)
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
d40f37b5
...
@@ -35,7 +35,6 @@ typedef struct {
...
@@ -35,7 +35,6 @@ typedef struct {
SDFileSet
wSet
;
SDFileSet
wSet
;
bool
isDFileSame
;
bool
isDFileSame
;
bool
isLFileSame
;
bool
isLFileSame
;
bool
isSmaFileSame
;
TSKEY
minKey
;
TSKEY
minKey
;
TSKEY
maxKey
;
TSKEY
maxKey
;
SArray
*
aBlkIdx
;
// SBlockIdx array
SArray
*
aBlkIdx
;
// SBlockIdx array
...
@@ -52,7 +51,8 @@ typedef struct {
...
@@ -52,7 +51,8 @@ typedef struct {
#define TSDB_COMMIT_HEAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_HEAD)
#define TSDB_COMMIT_HEAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_HEAD)
#define TSDB_COMMIT_DATA_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_DATA)
#define TSDB_COMMIT_DATA_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_DATA)
#define TSDB_COMMIT_LAST_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_LAST)
#define TSDB_COMMIT_LAST_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_LAST)
#define TSDB_COMMIT_AGGR_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMA)
#define TSDB_COMMIT_SMAD_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAD)
#define TSDB_COMMIT_SMAL_FILE(ch) TSDB_DFILE_IN_SET(TSDB_COMMIT_WRITE_FSET(ch), TSDB_FILE_SMAL)
#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh))
#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh))
#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh))
#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh))
#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh))
#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh))
...
@@ -1055,7 +1055,9 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
...
@@ -1055,7 +1055,9 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
return
0
;
return
0
;
}
}
}
}
static
int
originalDataFileSize
=
0
;
static
int
originalLastFileSize
=
0
;
static
char
latestLastFile
[
TSDB_FILENAME_LEN
]
=
{
0
};
int
tsdbWriteBlockImpl
(
STsdbRepo
*
pRepo
,
STable
*
pTable
,
SDFile
*
pDFile
,
SDFile
*
pDFileAggr
,
SDataCols
*
pDataCols
,
int
tsdbWriteBlockImpl
(
STsdbRepo
*
pRepo
,
STable
*
pTable
,
SDFile
*
pDFile
,
SDFile
*
pDFileAggr
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
,
void
**
ppBuf
,
void
**
ppCBuf
,
void
**
ppExBuf
)
{
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
,
void
**
ppBuf
,
void
**
ppCBuf
,
void
**
ppExBuf
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
...
@@ -1064,6 +1066,11 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1064,6 +1066,11 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
int64_t
offset
=
0
,
offsetAggr
=
0
;
int64_t
offset
=
0
,
offsetAggr
=
0
;
int
rowsToWrite
=
pDataCols
->
numOfRows
;
int
rowsToWrite
=
pDataCols
->
numOfRows
;
int
blkSizeBefore
=
0
;
int
blkSizeAfter
=
0
;
int
aggrSizeBefore
=
0
;
int
aggrSizeAfter
=
0
;
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pCfg
->
maxRowsPerFileBlock
);
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pCfg
->
maxRowsPerFileBlock
);
ASSERT
((
!
isLast
)
||
rowsToWrite
<
pCfg
->
minRowsPerFileBlock
);
ASSERT
((
!
isLast
)
||
rowsToWrite
<
pCfg
->
minRowsPerFileBlock
);
...
@@ -1115,6 +1122,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1115,6 +1122,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
// Compress the data if neccessary
// Compress the data if neccessary
int
tcol
=
0
;
// counter of not all NULL and written columns
int
tcol
=
0
;
// counter of not all NULL and written columns
uint32_t
toffset
=
0
;
uint32_t
toffset
=
0
;
int32_t
tsizeV0
=
(
int32_t
)
tsdbBlockStatisSize
(
nColsNotAllNull
,
TSDB_SBLK_VER_0
);
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
nColsNotAllNull
,
SBlockVerLatest
);
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
nColsNotAllNull
,
SBlockVerLatest
);
int32_t
lsize
=
tsize
;
int32_t
lsize
=
tsize
;
int32_t
keyLen
=
0
;
int32_t
keyLen
=
0
;
...
@@ -1173,6 +1181,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1173,6 +1181,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
toffset
+=
flen
;
toffset
+=
flen
;
lsize
+=
flen
;
lsize
+=
flen
;
tsizeV0
+=
flen
;
}
}
pBlockData
->
delimiter
=
TSDB_FILE_DELIMITER
;
pBlockData
->
delimiter
=
TSDB_FILE_DELIMITER
;
...
@@ -1181,16 +1190,17 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1181,16 +1190,17 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pBlockData
,
tsize
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pBlockData
,
tsize
);
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
pBlockData
,
tsize
-
sizeof
(
TSCKSUM
)));
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
pBlockData
,
tsize
-
sizeof
(
TSCKSUM
)));
blkSizeBefore
=
pDFile
->
info
.
size
;
// Write the whole block to file
// Write the whole block to file
if
(
tsdbAppendDFile
(
pDFile
,
(
void
*
)
pBlockData
,
lsize
,
&
offset
)
<
lsize
)
{
if
(
tsdbAppendDFile
(
pDFile
,
(
void
*
)
pBlockData
,
lsize
,
&
offset
)
<
lsize
)
{
return
-
1
;
return
-
1
;
}
}
blkSizeAfter
=
pDFile
->
info
.
size
;
#ifdef __TD_6117__
#ifdef __TD_6117__
// pAggrBlkData->delimiter = TSDB_FILE_DELIMITER;
// pAggrBlkData->delimiter = TSDB_FILE_DELIMITER;
// pAggrBlkData->uid = TABLE_UID(pTable);
// pAggrBlkData->uid = TABLE_UID(pTable);
int
aggrStatus
=
((
aggrNum
>
0
)
&&
(
rowsToWrite
>
5
))
?
1
:
0
;
// TODO: How to make the decision?
int
aggrStatus
=
((
aggrNum
>
0
)
&&
(
rowsToWrite
>
5
))
?
1
:
0
;
// TODO: How to make the decision?
aggrSizeBefore
=
pDFileAggr
->
info
.
size
;
if
(
aggrStatus
>
0
)
{
if
(
aggrStatus
>
0
)
{
pAggrBlkData
->
numOfCols
=
nColsNotAllNull
;
pAggrBlkData
->
numOfCols
=
nColsNotAllNull
;
...
@@ -1203,6 +1213,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1203,6 +1213,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
}
}
}
}
#endif
#endif
aggrSizeAfter
=
pDFileAggr
->
info
.
size
;
// Update pBlock membership vairables
// Update pBlock membership vairables
pBlock
->
last
=
isLast
;
pBlock
->
last
=
isLast
;
...
@@ -1222,22 +1233,45 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
...
@@ -1222,22 +1233,45 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
pBlock
->
aggrLen
=
tsizeAggr
;
pBlock
->
aggrLen
=
tsizeAggr
;
#endif
#endif
#ifndef __TD_6117__
tsdbDebug
(
"vgId:%d tid:%d a block of data is written to file %s, offset %"
PRId64
tsdbDebug
(
"vgId:%d tid:%d a block of data is written to file %s, offset %"
PRId64
" numOfRows %d len %d numOfCols %"
PRId16
" keyFirst %"
PRId64
" keyLast %"
PRId64
,
" numOfRows %d len %d numOfCols %"
PRId16
" keyFirst %"
PRId64
" keyLast %"
PRId64
,
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
rowsToWrite
,
pBlock
->
len
,
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
rowsToWrite
,
pBlock
->
len
,
pBlock
->
numOfCols
,
pBlock
->
keyFirst
,
pBlock
->
keyLast
);
pBlock
->
numOfCols
,
pBlock
->
keyFirst
,
pBlock
->
keyLast
);
#else
if
(
isLast
)
{
if
(
strncmp
(
TSDB_FILE_FULL_NAME
(
pDFile
),
latestLastFile
,
TSDB_FILENAME_LEN
)
==
0
)
{
originalLastFileSize
+=
tsizeV0
;
}
else
{
originalLastFileSize
=
tsizeV0
;
strncpy
(
latestLastFile
,
TSDB_FILE_FULL_NAME
(
pDFile
),
TSDB_FILENAME_LEN
);
}
}
else
{
originalDataFileSize
+=
tsizeV0
;
}
tsdbDebug
(
"vgId:%d tid:%d a block of data is written to file %s, offset %"
PRId64
" numOfRows %d len %d numOfCols %"
PRId16
" keyFirst %"
PRId64
" keyLast %"
PRId64
,
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
rowsToWrite
,
pBlock
->
len
,
pBlock
->
numOfCols
,
pBlock
->
keyFirst
,
pBlock
->
keyLast
);
tsdbDebug
(
"prop:vgId:%d tid:%d a block of data is written to file %s(len:%d, size: %d -> %d), SMA (len:%d, size: %d -> "
"%d), .lastSize = %d, .dataSize = %d"
,
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
pBlock
->
len
,
blkSizeBefore
,
blkSizeAfter
,
pBlock
->
aggrLen
,
aggrSizeBefore
,
aggrSizeAfter
,
originalLastFileSize
,
originalDataFileSize
);
#endif
return
0
;
return
0
;
}
}
static
int
tsdbWriteBlock
(
SCommitH
*
pCommith
,
SDFile
*
pDFile
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
static
int
tsdbWriteBlock
(
SCommitH
*
pCommith
,
SDFile
*
pDFile
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
)
{
bool
isSuper
)
{
return
tsdbWriteBlockImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
TSDB_COMMIT_TABLE
(
pCommith
),
pDFile
,
TSDB_COMMIT_AGGR_FILE
(
pCommith
),
pDataCols
,
pBlock
,
isLast
,
return
tsdbWriteBlockImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
TSDB_COMMIT_TABLE
(
pCommith
),
pDFile
,
isSuper
,
(
void
**
)(
&
(
TSDB_COMMIT_BUF
(
pCommith
))),
isLast
?
TSDB_COMMIT_SMAL_FILE
(
pCommith
)
:
TSDB_COMMIT_SMAD_FILE
(
pCommith
),
pDataCols
,
pBlock
,
isLast
,
isSuper
,
(
void
**
)(
&
(
TSDB_COMMIT_BUF
(
pCommith
))),
(
void
**
)(
&
(
TSDB_COMMIT_COMP_BUF
(
pCommith
))),
(
void
**
)(
&
(
TSDB_COMMIT_EXBUF
(
pCommith
))));
(
void
**
)(
&
(
TSDB_COMMIT_COMP_BUF
(
pCommith
))),
(
void
**
)(
&
(
TSDB_COMMIT_EXBUF
(
pCommith
))));
}
}
static
int
tsdbWriteBlockInfo
(
SCommitH
*
pCommih
)
{
static
int
tsdbWriteBlockInfo
(
SCommitH
*
pCommih
)
{
SDFile
*
pHeadf
=
TSDB_COMMIT_HEAD_FILE
(
pCommih
);
SDFile
*
pHeadf
=
TSDB_COMMIT_HEAD_FILE
(
pCommih
);
SBlockIdx
blkIdx
;
SBlockIdx
blkIdx
;
...
@@ -1577,7 +1611,6 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -1577,7 +1611,6 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
pCommith
->
isDFileSame
=
false
;
pCommith
->
isDFileSame
=
false
;
pCommith
->
isLFileSame
=
false
;
pCommith
->
isLFileSame
=
false
;
pCommith
->
isSmaFileSame
=
false
;
tsdbDebug
(
"vgId:%d FSET %d at level %d disk id %d is created to commit"
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pWSet
),
tsdbDebug
(
"vgId:%d FSET %d at level %d disk id %d is created to commit"
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pWSet
),
TSDB_FSET_LEVEL
(
pWSet
),
TSDB_FSET_ID
(
pWSet
));
TSDB_FSET_LEVEL
(
pWSet
),
TSDB_FSET_ID
(
pWSet
));
}
else
{
}
else
{
...
@@ -1653,18 +1686,16 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -1653,18 +1686,16 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
}
}
}
}
// TSDB_FILE_SMA
// TSDB_FILE_SMAD
ASSERT
(
pWSet
->
nFiles
>=
TSDB_FILE_SMA
);
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pRSmaf
=
TSDB_READ_AGGR_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
SDFile
*
pWSmaf
=
TSDB_COMMIT_AGGR_FILE
(
pCommith
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmaf
),
F_OK
)
!=
0
)
{
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmadF
),
F_OK
)
!=
0
)
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmaf
));
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbInitDFile
(
pWSmaf
,
did
,
REPO_ID
(
pRepo
),
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMA
);
tsdbInitDFile
(
pWSmadF
,
did
,
REPO_ID
(
pRepo
),
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
pCommith
->
isLFileSame
=
false
;
if
(
tsdbCreateDFile
(
pWSma
f
,
true
,
TSDB_FILE_SMA
)
<
0
)
{
if
(
tsdbCreateDFile
(
pWSma
dF
,
true
,
TSDB_FILE_SMAD
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSma
f
),
tsdbError
(
"vgId:%d failed to create file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSma
dF
),
tstrerror
(
terrno
));
tstrerror
(
terrno
));
tsdbCloseDFileSet
(
pWSet
);
tsdbCloseDFileSet
(
pWSet
);
...
@@ -1675,10 +1706,29 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -1675,10 +1706,29 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
}
}
}
}
}
else
{
}
else
{
tsdbInitDFileEx
(
pWSmaf
,
pRSmaf
);
tsdbInitDFileEx
(
pWSmadF
,
pRSmadF
);
pCommith
->
isSmaFileSame
=
true
;
if
(
tsdbOpenDFile
(
pWSmadF
,
O_RDWR
)
<
0
)
{
if
(
tsdbOpenDFile
(
pWSmaf
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmadF
),
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmaf
),
tstrerror
(
terrno
));
tsdbCloseDFileSet
(
pWSet
);
tsdbRemoveDFile
(
pWHeadf
);
if
(
pCommith
->
isRFileSet
)
{
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
return
-
1
;
}
}
}
// TSDB_FILE_SMAL
ASSERT
(
pWSet
->
nFiles
>=
TSDB_FILE_SMAL
);
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
tstrerror
(
terrno
));
tstrerror
(
terrno
));
tsdbCloseDFileSet
(
pWSet
);
tsdbCloseDFileSet
(
pWSet
);
...
@@ -1688,6 +1738,21 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -1688,6 +1738,21 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
return
-
1
;
return
-
1
;
}
}
}
}
}
else
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmalF
));
tsdbInitDFile
(
pWSmalF
,
did
,
REPO_ID
(
pRepo
),
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAL
);
if
(
tsdbCreateDFile
(
pWSmalF
,
true
,
TSDB_FILE_SMAL
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
tstrerror
(
terrno
));
tsdbCloseDFileSet
(
pWSet
);
(
void
)
tsdbRemoveDFile
(
pWHeadf
);
if
(
pCommith
->
isRFileSet
)
{
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
return
-
1
;
}
}
}
}
}
}
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
d40f37b5
...
@@ -37,7 +37,8 @@ typedef struct {
...
@@ -37,7 +37,8 @@ typedef struct {
#define TSDB_COMPACT_HEAD_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_HEAD)
#define TSDB_COMPACT_HEAD_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_HEAD)
#define TSDB_COMPACT_DATA_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_DATA)
#define TSDB_COMPACT_DATA_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_DATA)
#define TSDB_COMPACT_LAST_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_LAST)
#define TSDB_COMPACT_LAST_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_LAST)
#define TSDB_COMPACT_AGGR_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_SMA)
#define TSDB_COMPACT_SMAD_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_SMAD)
#define TSDB_COMPACT_SMAL_FILE(pComph) TSDB_DFILE_IN_SET(TSDB_COMPACT_WSET(pComph), TSDB_FILE_SMAL)
#define TSDB_COMPACT_BUF(pComph) TSDB_READ_BUF(&((pComph)->readh))
#define TSDB_COMPACT_BUF(pComph) TSDB_READ_BUF(&((pComph)->readh))
#define TSDB_COMPACT_COMP_BUF(pComph) TSDB_READ_COMP_BUF(&((pComph)->readh))
#define TSDB_COMPACT_COMP_BUF(pComph) TSDB_READ_COMP_BUF(&((pComph)->readh))
#define TSDB_COMPACT_EXBUF(pComph) TSDB_READ_EXBUF(&((pComph)->readh))
#define TSDB_COMPACT_EXBUF(pComph) TSDB_READ_EXBUF(&((pComph)->readh))
...
@@ -523,8 +524,9 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
...
@@ -523,8 +524,9 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
isLast
=
false
;
isLast
=
false
;
}
}
if
(
tsdbWriteBlockImpl
(
pRepo
,
pTable
,
pDFile
,
TSDB_COMPACT_AGGR_FILE
(
pComph
),
pDataCols
,
&
block
,
isLast
,
true
,
if
(
tsdbWriteBlockImpl
(
pRepo
,
pTable
,
pDFile
,
ppBuf
,
ppCBuf
,
ppExBuf
)
<
0
)
{
isLast
?
TSDB_COMPACT_SMAL_FILE
(
pComph
)
:
TSDB_COMPACT_SMAD_FILE
(
pComph
),
pDataCols
,
&
block
,
isLast
,
true
,
ppBuf
,
ppCBuf
,
ppExBuf
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
d40f37b5
...
@@ -16,12 +16,13 @@
...
@@ -16,12 +16,13 @@
#include "tsdbint.h"
#include "tsdbint.h"
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
"head"
,
// TSDB_FILE_HEAD
"head"
,
// TSDB_FILE_HEAD
"data"
,
// TSDB_FILE_DATA
"data"
,
// TSDB_FILE_DATA
"last"
,
// TSDB_FILE_LAST
"last"
,
// TSDB_FILE_LAST
"sma"
,
// TSDB_FILE_SMA(Small Materialized Aggregate)
"smad"
,
// TSDB_FILE_SMA_DATA(Small Materialized Aggregate for .data File)
""
,
// TSDB_FILE_MAX
"smal"
,
// TSDB_FILE_SMA_LAST(Small Materialized Aggregate for .last File)
"meta"
,
// TSDB_FILE_META
""
,
// TSDB_FILE_MAX
"meta"
,
// TSDB_FILE_META
};
};
static
void
tsdbGetFilename
(
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
,
char
*
fname
);
static
void
tsdbGetFilename
(
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
,
char
*
fname
);
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
d40f37b5
...
@@ -450,7 +450,7 @@ static int tsdbLoadBlockStatisFromDFile(SReadH *pReadh, SBlock *pBlock) {
...
@@ -450,7 +450,7 @@ static int tsdbLoadBlockStatisFromDFile(SReadH *pReadh, SBlock *pBlock) {
static
int
tsdbLoadBlockStatisFromAggr
(
SReadH
*
pReadh
,
SBlock
*
pBlock
)
{
static
int
tsdbLoadBlockStatisFromAggr
(
SReadH
*
pReadh
,
SBlock
*
pBlock
)
{
ASSERT
((
pBlock
->
blkVer
>
TSDB_SBLK_VER_0
)
&&
(
pBlock
->
aggrStat
));
// TODO: remove after pass all the test
ASSERT
((
pBlock
->
blkVer
>
TSDB_SBLK_VER_0
)
&&
(
pBlock
->
aggrStat
));
// TODO: remove after pass all the test
SDFile
*
pDFileAggr
=
TSDB_READ_AGGR
_FILE
(
pReadh
);
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD
_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block statis part while seek file %s to offset %"
PRId64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block statis part while seek file %s to offset %"
PRId64
" since %s"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录