Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
300c0475
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
300c0475
编写于
5月 31, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish tsdbGetFileInfo function
上级
095d5f8d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
25 deletion
+66
-25
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-0
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+1
-2
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+63
-23
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
300c0475
...
...
@@ -515,6 +515,8 @@ void tsdbAdjustCacheBlocks(STsdbCache *pCache);
int32_t
tsdbGetMetaFileName
(
char
*
rootDir
,
char
*
fname
);
int
tsdbUpdateFileHeader
(
SFile
*
pFile
,
uint32_t
version
);
int
compFGroupKey
(
const
void
*
key
,
const
void
*
fgroup
);
#ifdef __cplusplus
}
#endif
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
300c0475
...
...
@@ -35,7 +35,6 @@ const char *tsdbFileSuffix[] = {
".last"
// TSDB_FILE_TYPE_LAST
};
static
int
compFGroupKey
(
const
void
*
key
,
const
void
*
fgroup
);
static
int
compFGroup
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbOpenFGroup
(
STsdbFileH
*
pFileH
,
char
*
dataDir
,
int
fid
);
...
...
@@ -285,7 +284,7 @@ int tsdbCopyBlockDataInFile(SFile *pOutFile, SFile *pInFile, SCompInfo *pCompInf
return
0
;
}
static
int
compFGroupKey
(
const
void
*
key
,
const
void
*
fgroup
)
{
int
compFGroupKey
(
const
void
*
key
,
const
void
*
fgroup
)
{
int
fid
=
*
(
int
*
)
key
;
SFileGroup
*
pFGroup
=
(
SFileGroup
*
)
fgroup
;
return
(
fid
-
pFGroup
->
fileId
);
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
300c0475
...
...
@@ -1179,43 +1179,83 @@ static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) {
tsdbTrace
(
"vgId:%d, tsdb maxTables is changed from %d to %d!"
,
pRepo
->
config
.
tsdbId
,
oldMaxTables
,
maxTables
);
}
#define TSDB_META_FILE_INDEX 10000000
uint32_t
tsdbGetFileInfo
(
TsdbRepoT
*
repo
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int32_t
*
size
)
{
// TODO: need to refactor this function
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
// STsdbMeta *pMeta = pRepo->tsdbMeta;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
uint32_t
magic
=
0
;
char
fname
[
256
]
=
"
\0
"
;
uint32_t
magic
=
0
;
char
fname
[
256
]
=
"
\0
"
;
struct
stat
fState
;
char
*
spath
=
strdup
(
pRepo
->
rootDir
);
char
*
prefixDir
=
dirname
(
spath
);
if
(
name
[
0
]
==
0
)
{
// Map index to the file name
int
fid
=
(
*
index
)
/
3
;
if
(
fid
>=
pFileH
->
numOfFGroups
)
{
// return meta data file
if
((
*
index
)
%
3
>
0
)
{
// it is finished
tfree
(
spath
);
return
0
;
tsdbTrace
(
"vgId:%d name:%s index:%d eindex:%d"
,
pRepo
->
config
.
tsdbId
,
name
,
*
index
,
eindex
);
ASSERT
(
*
index
<=
eindex
);
if
(
name
[
0
]
==
0
)
{
// get the file from index or after, but not larger than eindex
if
(
*
index
==
0
)
{
// need to return the first file and set the *index
if
(
pFileH
->
numOfFGroups
>
0
)
{
int
fid
=
TSDB_MIN_FILE_ID
(
pFileH
);
if
(
fid
*
3
<=
eindex
)
{
strcpy
(
fname
,
pFileH
->
fGroup
[
fid
].
files
[
0
].
fname
);
*
index
=
fid
*
3
;
strcpy
(
name
,
fname
+
strlen
(
pRepo
->
rootDir
));
}
else
{
// no file found
return
0
;
}
}
else
{
if
(
TSDB_META_FILE_INDEX
<=
eindex
)
{
*
index
=
TSDB_META_FILE_INDEX
;
tsdbGetMetaFileName
(
pRepo
->
rootDir
,
fname
);
strcpy
(
name
,
fname
+
strlen
(
pRepo
->
rootDir
));
}
else
{
// no file found
return
0
;
}
}
}
else
{
// return a file name at *index
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
tsdbGetMetaFileName
(
pRepo
->
rootDir
,
fname
);
}
else
{
// to get a file in index or larger than index but
if
(
pFileH
->
numOfFGroups
==
0
)
{
// not found
return
0
;
}
else
{
int
fid
=
(
*
index
)
/
3
;
SFileGroup
*
pFGroup
=
taosbsearch
(
&
fid
,
pFileH
->
fGroup
,
pFileH
->
numOfFGroups
,
sizeof
(
SFileGroup
),
compFGroupKey
,
TD_GE
);
if
(
pFGroup
==
NULL
)
{
return
0
;
}
else
{
if
(
pFGroup
->
fileId
==
fid
)
{
strcpy
(
fname
,
pFGroup
->
files
[(
*
index
)
%
3
].
fname
);
}
else
{
if
(
pFGroup
->
fileId
*
3
+
2
<
eindex
)
{
strcpy
(
fname
,
pFGroup
->
files
[(
*
index
)
%
3
].
fname
);
*
index
=
pFGroup
->
fileId
*
3
+
(
*
index
)
%
3
;
}
else
{
return
0
;
}
}
}
}
}
}
else
{
// return data file name
strcpy
(
fname
,
pFileH
->
fGroup
[
fid
].
files
[(
*
index
)
%
3
].
fname
);
strcpy
(
name
,
fname
);
}
}
else
{
// get the named file at the specified index. If not there, return 0
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
// get meta file
tsdbGetMetaFileName
(
pRepo
->
rootDir
,
fname
);
}
else
{
int
fid
=
(
*
index
)
/
3
;
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
);
if
(
pFGroup
==
NULL
)
{
// not found
return
0
;
}
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
3
];
strcpy
(
fname
,
pFile
->
fname
);
}
strcpy
(
name
,
fname
+
strlen
(
spath
));
}
else
{
// Name is provided, need to get the file info
sprintf
(
fname
,
"%s/%s"
,
prefixDir
,
name
);
}
if
(
stat
(
fname
,
&
fState
)
<
0
)
{
tfree
(
spath
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录