Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
222ebe36
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看板
提交
222ebe36
编写于
8月 08, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add file size statistics
上级
bd7cb46a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
42 addition
and
14 deletion
+42
-14
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+11
-3
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+1
-1
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+2
-2
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+28
-8
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
222ebe36
...
...
@@ -154,11 +154,19 @@ typedef enum {
TSDB_FILE_TYPE_HEAD
=
0
,
TSDB_FILE_TYPE_DATA
,
TSDB_FILE_TYPE_LAST
,
TSDB_FILE_TYPE_
MAX
,
TSDB_FILE_TYPE_
STAT
,
TSDB_FILE_TYPE_NHEAD
,
TSDB_FILE_TYPE_NLAST
TSDB_FILE_TYPE_NDATA
,
TSDB_FILE_TYPE_NLAST
,
TSDB_FILE_TYPE_NSTAT
}
TSDB_FILE_TYPE
;
#ifndef TDINTERNAL
#define TSDB_FILE_TYPE_MAX (TSDB_FILE_TYPE_LAST+1)
#else
#define TSDB_FILE_TYPE_MAX (TSDB_FILE_TYPE_STAT+1)
#endif
typedef
struct
{
uint32_t
magic
;
uint32_t
len
;
...
...
@@ -497,7 +505,7 @@ int tsdbInitWriteHelper(SRWHelper* pHelper, STsdbRepo* pRepo);
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
);
void
tsdbResetHelper
(
SRWHelper
*
pHelper
);
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
);
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
,
SFileGroup
*
pGroup
);
int
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
STable
*
pTable
,
STsdbRepo
*
pRepo
);
int
tsdbCommitTableData
(
SRWHelper
*
pHelper
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pDataCols
,
TSKEY
maxKey
);
int
tsdbMoveLastBlockIfNeccessary
(
SRWHelper
*
pHelper
);
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
222ebe36
...
...
@@ -20,7 +20,7 @@
#include "tutil.h"
#define TAOS_RANDOM_FILE_FAIL_TEST
const
char
*
tsdbFileSuffix
[]
=
{
".head"
,
".data"
,
".last"
,
"
"
,
".h"
,
".l
"
};
const
char
*
tsdbFileSuffix
[]
=
{
".head"
,
".data"
,
".last"
,
"
.stat"
,
".h"
,
".d"
,
".l"
,
".s
"
};
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
);
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
222ebe36
...
...
@@ -679,7 +679,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
}
taosTFree
(
dataDir
);
tsdbCloseHelperFile
(
pHelper
,
0
);
tsdbCloseHelperFile
(
pHelper
,
0
,
pGroup
);
pthread_rwlock_wrlock
(
&
(
pFileH
->
fhlock
));
...
...
@@ -701,7 +701,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
_err:
taosTFree
(
dataDir
);
tsdbCloseHelperFile
(
pHelper
,
1
);
tsdbCloseHelperFile
(
pHelper
,
1
,
NULL
);
return
-
1
;
}
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
222ebe36
...
...
@@ -91,7 +91,7 @@ void tsdbResetHelper(SRWHelper *pHelper) {
tsdbResetHelperTableImpl
(
pHelper
);
// Reset the file part
tsdbCloseHelperFile
(
pHelper
,
false
);
tsdbCloseHelperFile
(
pHelper
,
false
,
NULL
);
tsdbResetHelperFileImpl
(
pHelper
);
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
...
...
@@ -120,6 +120,14 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
if
(
tsdbOpenFile
(
helperDataF
(
pHelper
),
O_RDWR
)
<
0
)
return
-
1
;
if
(
tsdbOpenFile
(
helperLastF
(
pHelper
),
O_RDWR
)
<
0
)
return
-
1
;
// NOTE: For data file compatibility
if
(
helperDataF
(
pHelper
)
->
info
.
size
==
TSDB_FILE_HEAD_SIZE
)
{
helperDataF
(
pHelper
)
->
info
.
size
=
(
uint64_t
)
lseek
(
helperDataF
(
pHelper
)
->
fd
,
0
,
SEEK_END
);
}
if
(
helperLastF
(
pHelper
)
->
info
.
size
==
TSDB_FILE_HEAD_SIZE
)
{
helperLastF
(
pHelper
)
->
info
.
size
=
(
uint64_t
)
lseek
(
helperLastF
(
pHelper
)
->
fd
,
0
,
SEEK_END
);
}
// Create and open .h
pFile
=
helperNewHeadF
(
pHelper
);
if
(
tsdbOpenFile
(
pFile
,
O_WRONLY
|
O_CREAT
)
<
0
)
return
-
1
;
...
...
@@ -146,7 +154,7 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
return
0
;
}
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
)
{
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
,
SFileGroup
*
pGroup
)
{
SFile
*
pFile
=
NULL
;
pFile
=
helperHeadF
(
pHelper
);
...
...
@@ -157,10 +165,11 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
if
(
helperType
(
pHelper
)
==
TSDB_WRITE_HELPER
)
{
if
(
!
hasError
)
{
tsdbUpdateFileHeader
(
pFile
);
fsync
(
pFile
->
fd
);
}
else
{
// TODO: shrink back to origin
ASSERT
(
pGroup
!=
NULL
);
taosFtruncate
(
pFile
->
fd
,
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
].
info
.
size
);
}
fsync
(
pFile
->
fd
);
}
tsdbCloseFile
(
pFile
);
}
...
...
@@ -170,10 +179,11 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
if
(
helperType
(
pHelper
)
==
TSDB_WRITE_HELPER
&&
!
TSDB_NLAST_FILE_OPENED
(
pHelper
))
{
if
(
!
hasError
)
{
tsdbUpdateFileHeader
(
pFile
);
fsync
(
pFile
->
fd
);
}
else
{
// TODO: shrink back to origin
ASSERT
(
pGroup
!=
NULL
);
taosFtruncate
(
pFile
->
fd
,
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
].
info
.
size
);
}
fsync
(
pFile
->
fd
);
}
tsdbCloseFile
(
pFile
);
}
...
...
@@ -390,6 +400,9 @@ int tsdbWriteCompInfo(SRWHelper *pHelper) {
void
*
pBuf
=
POINTER_SHIFT
(
pHelper
->
pWIdx
,
pFile
->
info
.
len
);
pFile
->
info
.
len
+=
tsdbEncodeSCompIdx
(
&
pBuf
,
&
(
pHelper
->
curCompIdx
));
pFile
->
info
.
size
+=
pIdx
->
len
;
ASSERT
(
pFile
->
info
.
size
==
lseek
(
pFile
->
fd
,
0
,
SEEK_CUR
));
}
return
0
;
...
...
@@ -420,7 +433,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
return
-
1
;
}
pFile
->
info
.
offset
=
offset
;
ASSERT
(
offset
==
pFile
->
info
.
size
)
;
if
(
taosTWrite
(
pFile
->
fd
,
(
void
*
)
pHelper
->
pWIdx
,
pFile
->
info
.
len
)
<
pFile
->
info
.
len
)
{
tsdbError
(
"vgId:%d failed to write %d bytes to file %s since %s"
,
REPO_ID
(
pHelper
->
pRepo
),
pFile
->
info
.
len
,
...
...
@@ -429,6 +442,10 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
return
-
1
;
}
pFile
->
info
.
offset
=
offset
;
pFile
->
info
.
size
+=
pFile
->
info
.
len
;
ASSERT
(
pFile
->
info
.
size
==
lseek
(
pFile
->
fd
,
0
,
SEEK_CUR
));
return
0
;
}
...
...
@@ -803,6 +820,9 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
(
int
)(
pCompBlock
->
numOfRows
),
pCompBlock
->
len
,
pCompBlock
->
numOfCols
,
pCompBlock
->
keyFirst
,
pCompBlock
->
keyLast
);
pFile
->
info
.
size
+=
pCompBlock
->
len
;
ASSERT
(
pFile
->
info
.
size
==
lseek
(
pFile
->
fd
,
0
,
SEEK_CUR
));
return
0
;
_err:
...
...
@@ -1016,7 +1036,7 @@ static int tsdbInitHelperFile(SRWHelper *pHelper) {
}
static
void
tsdbDestroyHelperFile
(
SRWHelper
*
pHelper
)
{
tsdbCloseHelperFile
(
pHelper
,
false
);
tsdbCloseHelperFile
(
pHelper
,
false
,
NULL
);
tsdbResetHelperFileImpl
(
pHelper
);
taosTZfree
(
pHelper
->
idxH
.
pIdxArray
);
taosTZfree
(
pHelper
->
pWIdx
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录