Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f9e1415
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看板
提交
2f9e1415
编写于
6月 18, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
131be7b0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
16 addition
and
46 deletion
+16
-46
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-3
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+3
-20
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+2
-11
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+4
-1
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+5
-11
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
2f9e1415
...
...
@@ -142,7 +142,7 @@ typedef struct {
}
STsdbFileInfo
;
typedef
struct
{
char
*
fname
;
char
fname
[
TSDB_FILENAME_LEN
]
;
int
fd
;
STsdbFileInfo
info
;
...
...
@@ -345,7 +345,6 @@ void tsdbFitRetention(STsdbRepo* pRepo);
int
tsdbUpdateFileHeader
(
SFile
*
pFile
,
uint32_t
version
);
int
tsdbEncodeSFileInfo
(
void
**
buf
,
const
STsdbFileInfo
*
pInfo
);
void
*
tsdbDecodeSFileInfo
(
void
*
buf
,
STsdbFileInfo
*
pInfo
);
int
tsdbCpySFile
(
SFile
*
src
,
SFile
*
dst
);
void
tsdbRemoveFileGroup
(
STsdbRepo
*
pRepo
,
SFileGroup
*
pFGroup
);
// ------------------ tsdbRWHelper.c
...
...
@@ -389,7 +388,7 @@ int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock, SDataCols* t
#define TSDB_SUBMIT_MSG_HEAD_SIZE sizeof(SSubmitMsg)
char
*
tsdbGetMetaFileName
(
char
*
rootDir
);
char
*
tsdbGetDataFileName
(
STsdbRepo
*
pRepo
,
int
fid
,
int
typ
e
);
void
tsdbGetDataFileName
(
STsdbRepo
*
pRepo
,
int
fid
,
int
type
,
char
*
fnam
e
);
int
tsdbLockRepo
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepo
(
STsdbRepo
*
pRepo
);
char
*
tsdbGetDataDirName
(
char
*
rootDir
);
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
2f9e1415
...
...
@@ -245,8 +245,7 @@ int tsdbCreateFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type) {
memset
((
void
*
)
pFile
,
0
,
sizeof
(
SFile
));
pFile
->
fd
=
-
1
;
pFile
->
fname
=
tsdbGetDataFileName
(
pRepo
,
fid
,
type
);
if
(
pFile
->
fname
==
NULL
)
return
-
1
;
tsdbGetDataFileName
(
pRepo
,
fid
,
type
,
pFile
->
fname
);
if
(
access
(
pFile
->
fname
,
F_OK
)
==
0
)
{
tsdbError
(
"vgId:%d file %s already exists"
,
REPO_ID
(
pRepo
),
fid
);
...
...
@@ -343,18 +342,6 @@ void *tsdbDecodeSFileInfo(void *buf, STsdbFileInfo *pInfo) {
return
buf
;
}
int
tsdbCpySFile
(
SFile
*
src
,
SFile
*
dst
)
{
*
dst
=
*
src
;
dst
->
fname
=
strdup
(
dst
->
fname
);
if
(
dst
->
fname
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
void
tsdbRemoveFileGroup
(
STsdbRepo
*
pRepo
,
SFileGroup
*
pFGroup
)
{
ASSERT
(
pFGroup
!=
NULL
);
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
...
...
@@ -380,8 +367,7 @@ static int tsdbInitFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type) {
uint32_t
version
;
char
buf
[
512
]
=
"
\0
"
;
pFile
->
fname
=
tsdbGetDataFileName
(
pRepo
,
fid
,
type
);
if
(
pFile
->
fname
==
NULL
)
return
-
1
;
tsdbGetDataFileName
(
pRepo
,
fid
,
type
,
pFile
->
fname
);
pFile
->
fd
=
-
1
;
if
(
tsdbOpenFile
(
pFile
,
O_RDONLY
)
<
0
)
goto
_err
;
...
...
@@ -410,10 +396,7 @@ _err:
return
-
1
;
}
static
void
tsdbDestroyFile
(
SFile
*
pFile
)
{
tsdbCloseFile
(
pFile
);
tfree
(
pFile
->
fname
);
}
static
void
tsdbDestroyFile
(
SFile
*
pFile
)
{
tsdbCloseFile
(
pFile
);
}
static
int
compFGroup
(
const
void
*
arg1
,
const
void
*
arg2
)
{
int
val1
=
((
SFileGroup
*
)
arg1
)
->
fileId
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
2f9e1415
...
...
@@ -337,17 +337,8 @@ char *tsdbGetMetaFileName(char *rootDir) {
return
fname
;
}
char
*
tsdbGetDataFileName
(
STsdbRepo
*
pRepo
,
int
fid
,
int
type
)
{
int
tlen
=
strlen
(
pRepo
->
rootDir
)
+
strlen
(
tsdbFileSuffix
[
type
])
+
24
;
char
*
fname
=
malloc
(
tlen
);
if
(
fname
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
NULL
;
}
sprintf
(
fname
,
"%s/%s/v%df%d.%s"
,
pRepo
->
rootDir
,
TSDB_DATA_DIR_NAME
,
REPO_ID
(
pRepo
),
fid
,
tsdbFileSuffix
[
type
]);
return
fname
;
void
tsdbGetDataFileName
(
STsdbRepo
*
pRepo
,
int
fid
,
int
type
,
char
*
fname
)
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s/%s/v%df%d.%s"
,
pRepo
->
rootDir
,
TSDB_DATA_DIR_NAME
,
REPO_ID
(
pRepo
),
fid
,
tsdbFileSuffix
[
type
]);
}
int
tsdbLockRepo
(
STsdbRepo
*
pRepo
)
{
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
2f9e1415
...
...
@@ -499,6 +499,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
char
*
dataDir
=
NULL
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbCfg
*
pCfg
=
&
pRepo
->
config
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
SFileGroup
*
pGroup
=
NULL
;
TSKEY
minKey
=
0
,
maxKey
=
0
;
...
...
@@ -588,10 +589,12 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
}
tsdbCloseHelperFile
(
pHelper
,
0
);
// TODO: make it atomic with some methods
pthread_rwlock_wrlock
(
&
(
pFileH
->
fhlock
));
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
=
pHelper
->
files
.
headF
;
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
=
pHelper
->
files
.
dataF
;
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
=
pHelper
->
files
.
lastF
;
pthread_rwlock_unlock
(
&
(
pFileH
->
fhlock
));
return
0
;
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
2f9e1415
...
...
@@ -100,13 +100,12 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
// Set the files
pHelper
->
files
.
fid
=
pGroup
->
fileId
;
tsdbCpySFile
(
&
pHelper
->
files
.
headF
,
&
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
])
;
tsdbCpySFile
(
&
pHelper
->
files
.
dataF
,
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
])
;
tsdbCpySFile
(
&
pHelper
->
files
.
lastF
,
&
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
])
;
pHelper
->
files
.
headF
=
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
;
pHelper
->
files
.
dataF
=
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
;
pHelper
->
files
.
lastF
=
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
;
if
(
helperType
(
pHelper
)
==
TSDB_WRITE_HELPER
)
{
pHelper
->
files
.
nHeadF
.
fname
=
tsdbGetDataFileName
(
pHelper
->
pRepo
,
pGroup
->
fileId
,
TSDB_FILE_TYPE_NHEAD
);
pHelper
->
files
.
nLastF
.
fname
=
tsdbGetDataFileName
(
pHelper
->
pRepo
,
pGroup
->
fileId
,
TSDB_FILE_TYPE_NLAST
);
tsdbGetDataFileName
(
pHelper
->
pRepo
,
pGroup
->
fileId
,
TSDB_FILE_TYPE_NHEAD
,
pHelper
->
files
.
nHeadF
.
fname
);
tsdbGetDataFileName
(
pHelper
->
pRepo
,
pGroup
->
fileId
,
TSDB_FILE_TYPE_NLAST
,
pHelper
->
files
.
nLastF
.
fname
);
}
// Open the files
...
...
@@ -1036,15 +1035,10 @@ static int tsdbGetRowsInRange(SDataCols *pDataCols, TSKEY minKey, TSKEY maxKey)
static
void
tsdbResetHelperFileImpl
(
SRWHelper
*
pHelper
)
{
memset
((
void
*
)
&
pHelper
->
files
,
0
,
sizeof
(
pHelper
->
files
));
pHelper
->
files
.
fid
=
-
1
;
tfree
(
pHelper
->
files
.
headF
.
fname
);
pHelper
->
files
.
headF
.
fd
=
-
1
;
tfree
(
pHelper
->
files
.
dataF
.
fname
);
pHelper
->
files
.
dataF
.
fd
=
-
1
;
tfree
(
pHelper
->
files
.
lastF
.
fname
);
pHelper
->
files
.
lastF
.
fd
=
-
1
;
tfree
(
pHelper
->
files
.
nHeadF
.
fname
);
pHelper
->
files
.
nHeadF
.
fd
=
-
1
;
tfree
(
pHelper
->
files
.
nLastF
.
fname
);
pHelper
->
files
.
nLastF
.
fd
=
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录