Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
37e11f9b
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37e11f9b
编写于
8月 13, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
try to solve sync problem
上级
6554a535
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
69 addition
and
12 deletion
+69
-12
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-0
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+29
-0
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+13
-12
src/util/inc/tkvstore.h
src/util/inc/tkvstore.h
+1
-0
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+25
-0
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
37e11f9b
...
...
@@ -475,6 +475,7 @@ int tsdbUpdateFileHeader(SFile* pFile);
int
tsdbEncodeSFileInfo
(
void
**
buf
,
const
STsdbFileInfo
*
pInfo
);
void
*
tsdbDecodeSFileInfo
(
void
*
buf
,
STsdbFileInfo
*
pInfo
);
void
tsdbRemoveFileGroup
(
STsdbRepo
*
pRepo
,
SFileGroup
*
pFGroup
);
void
tsdbGetFileInfoImpl
(
char
*
fname
,
uint32_t
*
magic
,
int32_t
*
size
);
void
tsdbGetFidKeyRange
(
int
daysPerFile
,
int8_t
precision
,
int
fileId
,
TSKEY
*
minKey
,
TSKEY
*
maxKey
);
// ------------------ tsdbRWHelper.c
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
37e11f9b
...
...
@@ -423,6 +423,35 @@ void tsdbRemoveFileGroup(STsdbRepo *pRepo, SFileGroup *pFGroup) {
}
}
void
tsdbGetFileInfoImpl
(
char
*
fname
,
uint32_t
*
magic
,
int32_t
*
size
)
{
char
buf
[
TSDB_FILE_HEAD_SIZE
]
=
"
\0
"
;
uint32_t
version
=
0
;
STsdbFileInfo
info
=
{
0
};
int
fd
=
open
(
fname
,
O_RDONLY
);
if
(
fd
<
0
)
goto
_err
;
if
(
taosTRead
(
fd
,
buf
,
TSDB_FILE_HEAD_SIZE
)
<
TSDB_FILE_HEAD_SIZE
)
goto
_err
;
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
buf
,
TSDB_FILE_HEAD_SIZE
))
goto
_err
;
void
*
pBuf
=
(
void
*
)
buf
;
pBuf
=
taosDecodeFixedU32
(
pBuf
,
&
version
);
pBuf
=
tsdbDecodeSFileInfo
(
pBuf
,
&
info
);
off_t
offset
=
lseek
(
fd
,
0
,
SEEK_END
);
if
(
offset
<
0
)
goto
_err
;
close
(
fd
);
*
magic
=
info
.
magic
;
*
size
=
(
int32_t
)
offset
;
_err:
if
(
fd
>=
0
)
close
(
fd
);
*
magic
=
TSDB_FILE_INIT_MAGIC
;
*
size
=
0
;
}
// ---------------- LOCAL FUNCTIONS ----------------
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
)
{
uint32_t
version
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
37e11f9b
...
...
@@ -216,9 +216,9 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
char
*
sdup
=
strdup
(
pRepo
->
rootDir
);
char
*
prefix
=
dirname
(
sdup
);
int
prefixLen
=
(
int
)
strlen
(
prefix
);
taosTFree
(
sdup
);
if
(
name
[
0
]
==
0
)
{
// get the file from index or after, but not larger than eindex
taosTFree
(
sdup
);
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
if
(
pFileH
->
nFGroups
==
0
||
fid
>
pFileH
->
pFGroup
[
pFileH
->
nFGroups
-
1
].
fileId
)
{
...
...
@@ -248,18 +248,19 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
strcpy
(
name
,
fname
+
prefixLen
);
}
else
{
// get the named file at the specified index. If not there, return 0
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
// get meta file
fname
=
tsdbGetMetaFileName
(
pRepo
->
rootDir
);
magic
=
TSDB_META_FILE_MAGIC
(
pRepo
->
tsdbMeta
);
fname
=
malloc
(
prefixLen
+
strlen
(
name
)
+
2
);
sprintf
(
fname
,
"%s/%s"
,
prefix
,
name
);
tsdbGetStoreInfo
(
fname
,
&
magic
,
size
);
taosFree
(
fname
);
taosFree
(
sdup
);
return
magic
;
}
else
{
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pFGroup
==
NULL
)
{
// not found
return
0
;
}
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
];
fname
=
strdup
(
pFile
->
fname
);
magic
=
pFile
->
info
.
magic
;
fname
=
malloc
(
prefixLen
+
strlen
(
name
)
+
2
);
sprintf
(
fname
,
"%s/%s"
,
prefix
,
name
);
tsdbGetFileInfoImpl
(
fname
,
&
magic
,
size
);
taosFree
(
fname
);
taosFree
(
sdup
);
return
magic
;
}
}
...
...
src/util/inc/tkvstore.h
浏览文件 @
37e11f9b
...
...
@@ -58,6 +58,7 @@ int tdKVStoreStartCommit(SKVStore *pStore);
int
tdUpdateKVStoreRecord
(
SKVStore
*
pStore
,
uint64_t
uid
,
void
*
cont
,
int
contLen
);
int
tdDropKVStoreRecord
(
SKVStore
*
pStore
,
uint64_t
uid
);
int
tdKVStoreEndCommit
(
SKVStore
*
pStore
);
void
tsdbGetStoreInfo
(
char
*
fname
,
uint32_t
*
magic
,
int32_t
*
size
);
#ifdef __cplusplus
}
...
...
src/util/src/tkvstore.c
浏览文件 @
37e11f9b
...
...
@@ -330,6 +330,31 @@ int tdKVStoreEndCommit(SKVStore *pStore) {
return
0
;
}
void
tsdbGetStoreInfo
(
char
*
fname
,
uint32_t
*
magic
,
int32_t
*
size
)
{
char
buf
[
TD_KVSTORE_HEADER_SIZE
]
=
"
\0
"
;
SStoreInfo
info
=
{
0
};
int
fd
=
open
(
fname
,
O_RDONLY
);
if
(
fd
<
0
)
goto
_err
;
if
(
taosTRead
(
fd
,
buf
,
TD_KVSTORE_HEADER_SIZE
)
<
TD_KVSTORE_HEADER_SIZE
)
goto
_err
;
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
buf
,
TD_KVSTORE_HEADER_SIZE
))
goto
_err
;
void
*
pBuf
=
(
void
*
)
buf
;
pBuf
=
tdDecodeStoreInfo
(
pBuf
,
&
info
);
off_t
offset
=
lseek
(
fd
,
0
,
SEEK_END
);
if
(
offset
<
0
)
goto
_err
;
close
(
fd
);
*
magic
=
info
.
magic
;
*
size
=
(
int32_t
)
offset
;
_err:
if
(
fd
>=
0
)
close
(
fd
);
*
magic
=
TD_KVSTORE_INIT_MAGIC
;
*
size
=
0
;
}
static
int
tdLoadKVStoreHeader
(
int
fd
,
char
*
fname
,
SStoreInfo
*
pInfo
,
uint32_t
*
version
)
{
char
buf
[
TD_KVSTORE_HEADER_SIZE
]
=
"
\0
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录