Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0b17e3fe
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看板
提交
0b17e3fe
编写于
5月 16, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
7cb10a2b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
73 deletion
+70
-73
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
+3
-5
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+16
-20
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
+50
-47
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
+1
-1
未找到文件。
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
浏览文件 @
0b17e3fe
...
...
@@ -35,11 +35,9 @@ typedef enum {
int32_t
tsdbFileSetToJson
(
const
STFileSet
*
fset
,
cJSON
*
json
);
int32_t
tsdbJsonToFileSet
(
const
cJSON
*
json
,
STFileSet
*
fset
);
int32_t
tsdbFileSetInit
(
STFileSet
*
pSet
);
int32_t
tsdbFileSetInit
(
STFileSet
*
pSet
,
int32_t
fid
);
int32_t
tsdbFileSetClear
(
STFileSet
*
pSet
);
int32_t
tsdbFSetEdit
(
STFileSet
*
pSet
,
const
STFileOp
*
pOp
);
int32_t
tsdbFileSetEdit
(
STFileSet
*
fset
,
const
STFileOp
*
op
);
int32_t
tsdbFSetCmprFn
(
const
STFileSet
*
pSet1
,
const
STFileSet
*
pSet2
);
...
...
@@ -51,7 +49,7 @@ struct STFileOp {
};
typedef
struct
SSttLvl
{
int32_t
l
vl
;
// level
int32_t
l
evel
;
// level
int32_t
nstt
;
// number of .stt files on this level
SRBTree
sttTree
;
// .stt file tree, sorted by cid
SRBTreeNode
rbtn
;
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
0b17e3fe
...
...
@@ -409,37 +409,33 @@ static int32_t fset_cmpr_fn(const struct STFileSet *pSet1, const struct STFileSe
}
static
int32_t
edit_fs
(
STFileSystem
*
pFS
,
const
SArray
*
aFileOp
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
STFileSet
*
pSet
=
NULL
;
for
(
int32_t
iop
=
0
;
iop
<
taosArrayGetSize
(
aFileOp
);
iop
++
)
{
struct
STFileOp
*
op
=
taosArrayGet
(
aFileOp
,
iop
);
if
(
pSet
==
NULL
||
pSet
->
fid
!=
op
->
fid
)
{
STFileSet
fset
=
{.
fid
=
op
->
fid
};
pSet
=
taosArraySearch
(
pFS
->
nstate
,
&
fset
,
(
__compar_fn_t
)
tsdbFSetCmprFn
,
TD_EQ
);
}
// create fset if need
if
(
pSet
==
NULL
)
{
ASSERT
(
op
->
oState
.
size
==
0
&&
op
->
nState
.
size
>
0
);
STFileSet
fset
=
{.
fid
=
op
->
fid
};
int32_t
idx
=
taosArraySearchIdx
(
pFS
->
nstate
,
&
fset
,
(
__compar_fn_t
)
tsdbFSetCmprFn
,
TD_GT
);
if
(
idx
<
0
)
idx
=
taosArrayGetSize
(
pFS
->
nstate
);
int32_t
idx
=
taosArraySearchIdx
(
pFS
->
nstate
,
&
fset
,
(
__compar_fn_t
)
tsdbFSetCmprFn
,
TD_GE
);
pSet
=
taosArrayInsert
(
pFS
->
nstate
,
idx
,
&
fset
);
if
(
pSet
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
pSet
=
NULL
;
if
(
idx
<
0
)
{
idx
=
taosArrayGetSize
(
pFS
->
nstate
);
}
else
{
pSet
=
taosArrayGet
(
pFS
->
nstate
,
idx
);
if
(
pSet
->
fid
!=
op
->
fid
)
pSet
=
NULL
;
}
tsdbFileSetInit
(
pSet
);
if
(
!
pSet
)
{
pSet
=
taosArrayInsert
(
pFS
->
nstate
,
idx
,
&
fset
);
if
(
!
pSet
)
TSDB_CHECK_CODE
(
code
=
TSDB_CODE_OUT_OF_MEMORY
,
lino
,
_exit
);
tsdbFileSetInit
(
pSet
,
op
->
fid
);
}
}
code
=
tsdbFSetEdit
(
pSet
,
op
);
code
=
tsdbF
ile
SetEdit
(
pSet
,
op
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
浏览文件 @
0b17e3fe
...
...
@@ -16,7 +16,7 @@
#include "inc/tsdbFSet.h"
static
int32_t
stt_lvl_to_json
(
const
SSttLvl
*
lvl
,
cJSON
*
json
)
{
if
(
cJSON_AddNumberToObject
(
json
,
"lvl"
,
lvl
->
l
v
l
)
==
NULL
)
{
if
(
cJSON_AddNumberToObject
(
json
,
"lvl"
,
lvl
->
l
eve
l
)
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -49,8 +49,8 @@ static int32_t stt_file_cmpr(const SRBTreeNode *n1, const SRBTreeNode *n2) {
return
0
;
}
static
int32_t
stt_lvl_init
(
SSttLvl
*
lvl
)
{
lvl
->
l
vl
=
0
;
static
int32_t
stt_lvl_init
(
SSttLvl
*
lvl
,
int32_t
level
)
{
lvl
->
l
evel
=
level
;
lvl
->
nstt
=
0
;
tRBTreeCreate
(
&
lvl
->
sttTree
,
stt_file_cmpr
);
return
0
;
...
...
@@ -63,17 +63,17 @@ static int32_t add_file_to_stt_lvl(SSttLvl *lvl, STFileObj *fobj) {
}
static
int32_t
json_to_stt_lvl
(
const
cJSON
*
json
,
SSttLvl
*
lvl
)
{
stt_lvl_init
(
lvl
);
const
cJSON
*
item1
,
*
item2
;
item1
=
cJSON_GetObjectItem
(
json
,
"lvl"
);
if
(
cJSON_IsNumber
(
item1
))
{
lvl
->
l
v
l
=
item1
->
valuedouble
;
lvl
->
l
eve
l
=
item1
->
valuedouble
;
}
else
{
return
TSDB_CODE_FILE_CORRUPTED
;
}
stt_lvl_init
(
lvl
,
lvl
->
level
);
item1
=
cJSON_GetObjectItem
(
json
,
"files"
);
if
(
cJSON_IsArray
(
item1
))
{
cJSON_ArrayForEach
(
item2
,
item1
)
{
...
...
@@ -94,38 +94,51 @@ static int32_t json_to_stt_lvl(const cJSON *json, SSttLvl *lvl) {
return
0
;
}
static
int32_t
add_file
(
STFileSet
*
fset
,
STFile
*
f
)
{
if
(
f
->
type
==
TSDB_FTYPE_STT
)
{
SSttLvl
*
lvl
=
NULL
;
// TODO
static
int32_t
add_stt_lvl
(
STFileSet
*
fset
,
SSttLvl
*
lvl
)
{
tRBTreePut
(
&
fset
->
lvlTree
,
&
lvl
->
rbtn
);
return
0
;
}
static
int32_t
add_file_to_fset
(
STFileSet
*
fset
,
STFileObj
*
fobj
)
{
if
(
fobj
->
f
.
type
==
TSDB_FTYPE_STT
)
{
SSttLvl
*
lvl
;
SSttLvl
tlvl
=
{.
level
=
fobj
->
f
.
stt
.
lvl
};
// lvl->nstt++;
// lvl->fstt = f;
SRBTreeNode
*
node
=
tRBTreeGet
(
&
fset
->
lvlTree
,
&
tlvl
.
rbtn
);
if
(
node
)
{
lvl
=
TCONTAINER_OF
(
node
,
SSttLvl
,
rbtn
);
}
else
{
lvl
=
taosMemoryMalloc
(
sizeof
(
*
lvl
));
if
(
!
lvl
)
return
TSDB_CODE_OUT_OF_MEMORY
;
stt_lvl_init
(
lvl
,
fobj
->
f
.
stt
.
lvl
);
add_stt_lvl
(
fset
,
lvl
);
}
add_file_to_stt_lvl
(
lvl
,
fobj
);
}
else
{
// fset->farr[f->type] = f
;
fset
->
farr
[
fobj
->
f
.
type
]
=
fobj
;
}
return
0
;
}
static
int32_t
add_stt_lvl
(
STFileSet
*
fset
,
SSttLvl
*
lvl
)
{
tRBTreePut
(
&
fset
->
lvlTree
,
&
lvl
->
rbtn
);
return
0
;
}
static
int32_t
stt_lvl_cmpr
(
const
SRBTreeNode
*
n1
,
const
SRBTreeNode
*
n2
)
{
SSttLvl
*
lvl1
=
TCONTAINER_OF
(
n1
,
SSttLvl
,
rbtn
);
SSttLvl
*
lvl2
=
TCONTAINER_OF
(
n2
,
SSttLvl
,
rbtn
);
if
(
lvl1
->
l
vl
<
lvl2
->
lv
l
)
{
if
(
lvl1
->
l
evel
<
lvl2
->
leve
l
)
{
return
-
1
;
}
else
if
(
lvl1
->
l
vl
>
lvl2
->
lv
l
)
{
}
else
if
(
lvl1
->
l
evel
>
lvl2
->
leve
l
)
{
return
1
;
}
return
0
;
}
static
int32_t
fset_init
(
STFileSet
*
fset
)
{
memset
(
fset
,
0
,
sizeof
(
*
fset
));
static
int32_t
fset_init
(
STFileSet
*
fset
,
int32_t
fid
)
{
fset
->
fid
=
fid
;
for
(
int32_t
ftype
=
TSDB_FTYPE_MIN
;
ftype
<
TSDB_FTYPE_MAX
;
++
ftype
)
{
fset
->
farr
[
ftype
]
=
NULL
;
}
tRBTreeCreate
(
&
fset
->
lvlTree
,
stt_lvl_cmpr
);
return
0
;
}
...
...
@@ -166,8 +179,8 @@ int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json) {
int32_t
tsdbJsonToFileSet
(
const
cJSON
*
json
,
STFileSet
*
fset
)
{
const
cJSON
*
item1
,
*
item2
;
fset_init
(
fset
)
;
int32_t
code
;
STFile
tf
;
/* fid */
item1
=
cJSON_GetObjectItem
(
json
,
"fid"
);
...
...
@@ -177,8 +190,7 @@ int32_t tsdbJsonToFileSet(const cJSON *json, STFileSet *fset) {
return
TSDB_CODE_FILE_CORRUPTED
;
}
int32_t
code
;
STFile
tf
;
fset_init
(
fset
,
fset
->
fid
);
for
(
int32_t
ftype
=
TSDB_FTYPE_MIN
;
ftype
<
TSDB_FTYPE_MAX
;
++
ftype
)
{
code
=
tsdbJsonToTFile
(
json
,
ftype
,
&
tf
);
if
(
code
==
TSDB_CODE_NOT_FOUND
)
{
...
...
@@ -220,37 +232,28 @@ int32_t tsdbFSetCmprFn(const STFileSet *pSet1, const STFileSet *pSet2) {
return
0
;
}
int32_t
tsdbFSetEdit
(
STFileSet
*
fset
,
const
STFileOp
*
op
)
{
int32_t
code
;
ASSERT
(
fset
->
fid
==
op
->
fid
);
if
(
op
->
oState
.
size
==
0
)
{
// create
// STFile *f;
// code = tsdbTFileCreate(&op->nState, &f);
// if (code) return code;
int32_t
tsdbFileSetEdit
(
STFileSet
*
fset
,
const
STFileOp
*
op
)
{
int32_t
code
=
0
;
// add_file(fset, f);
if
(
op
->
oState
.
size
==
0
//
||
0
/* TODO*/
)
{
STFileObj
*
fobj
;
code
=
tsdbTFileObjCreate
(
&
fobj
);
if
(
code
)
return
code
;
fobj
->
f
=
op
->
nState
;
add_file_to_fset
(
fset
,
fobj
);
}
else
if
(
op
->
nState
.
size
==
0
)
{
// delete
ASSERT
(
0
);
}
else
{
// modify
ASSERT
(
0
);
}
return
0
;
}
int32_t
tsdbFileSetInit
(
STFileSet
*
pSet
)
{
for
(
tsdb_ftype_t
ftype
=
TSDB_FTYPE_MIN
;
ftype
<
TSDB_FTYPE_MAX
;
ftype
++
)
{
pSet
->
farr
[
ftype
]
=
NULL
;
}
// LISTD_INIT(&pSet->lvl0, listNode);
// pSet->lvl0.lvl = 0;
// pSet->lvl0.nstt = 0;
// pSet->lvl0.fstt = NULL;
return
0
;
}
int32_t
tsdbFileSetInit
(
STFileSet
*
pSet
,
int32_t
fid
)
{
return
fset_init
(
pSet
,
fid
);
}
int32_t
tsdbFileSetClear
(
STFileSet
*
pSet
)
{
// TODO
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
浏览文件 @
0b17e3fe
...
...
@@ -234,7 +234,7 @@ int32_t tsdbJsonToTFile(const cJSON *json, tsdb_ftype_t ftype, STFile *f) {
int32_t
tsdbTFileObjCreate
(
STFileObj
**
fobj
)
{
fobj
[
0
]
=
taosMemoryMalloc
(
sizeof
(
STFileObj
));
if
(
fobj
[
0
]
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
!
fobj
[
0
]
)
return
TSDB_CODE_OUT_OF_MEMORY
;
fobj
[
0
]
->
ref
=
1
;
// TODO
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录