Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ca28c99f
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ca28c99f
编写于
5月 23, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
89eafa18
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
59 addition
and
25 deletion
+59
-25
include/util/tarray2.h
include/util/tarray2.h
+12
-3
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
+1
-0
source/dnode/vnode/src/tsdb/dev/inc/tsdbFile.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFile.h
+3
-3
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+6
-6
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
+22
-1
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
+14
-11
未找到文件。
include/util/tarray2.h
浏览文件 @
ca28c99f
...
...
@@ -114,9 +114,18 @@ static FORCE_INLINE int32_t tarray2_make_room( //
#define TARRAY2_APPEND(a, e) TARRAY2_INSERT(a, (a)->size, e)
#define TARRAY2_APPEND_P(a, ep) TARRAY2_APPEND(a, *(ep))
#define TARRAY2_SEARCH(a, ep, cmp, flag) \
(((a)->size == 0) ? NULL \
: taosbsearch(ep, (a)->data, (a)->size, sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp, flag))
// return (TYPE *)
#define TARRAY2_SEARCH(a, ep, cmp, flag) \
((typeof((a)->data))(((a)->size == 0) ? NULL \
: taosbsearch(ep, (a)->data, (a)->size, sizeof(typeof((a)->data[0])), \
(__compar_fn_t)cmp, flag)))
// return (TYPE)
#define TARRAY2_SEARCH_EX(a, ep, cmp, flag) \
({ \
typeof((a)->data) __p = TARRAY2_SEARCH(a, ep, cmp, flag); \
__p ? __p[0] : NULL; \
})
#define TARRAY2_SEARCH_IDX(a, ep, cmp, flag) \
({ \
...
...
source/dnode/vnode/src/tsdb/dev/inc/tsdbFSet.h
浏览文件 @
ca28c99f
...
...
@@ -41,6 +41,7 @@ typedef enum {
int32_t
tsdbTFileSetInit
(
int32_t
fid
,
STFileSet
**
fset
);
int32_t
tsdbTFileSetInitEx
(
STsdb
*
pTsdb
,
const
STFileSet
*
fset1
,
STFileSet
**
fset
);
int32_t
tsdbTFileSetClear
(
STFileSet
**
fset
);
int32_t
tsdbTFileSetRemove
(
STFileSet
**
fset
);
// to/from json
int32_t
tsdbTFileSetToJson
(
const
STFileSet
*
fset
,
cJSON
*
json
);
int32_t
tsdbJsonToTFileSet
(
STsdb
*
pTsdb
,
const
cJSON
*
json
,
STFileSet
**
fset
);
...
...
source/dnode/vnode/src/tsdb/dev/inc/tsdbFile.h
浏览文件 @
ca28c99f
...
...
@@ -34,8 +34,8 @@ typedef enum {
}
tsdb_ftype_t
;
enum
{
TSDB_FSTATE_
EXIST
=
1
,
TSDB_FSTATE_
REMOVE
D
,
TSDB_FSTATE_
LIVE
=
1
,
TSDB_FSTATE_
DEA
D
,
};
#define TSDB_FTYPE_MIN TSDB_FTYPE_HEAD
...
...
@@ -50,7 +50,7 @@ int32_t tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]);
int32_t
tsdbTFileObjInit
(
STsdb
*
pTsdb
,
const
STFile
*
f
,
STFileObj
**
fobj
);
int32_t
tsdbTFileObjRef
(
STFileObj
*
fobj
);
int32_t
tsdbTFileObjUnref
(
STFileObj
*
fobj
);
int32_t
tsdbTFileRemove
(
STFileObj
*
fobj
);
int32_t
tsdbTFile
Obj
Remove
(
STFileObj
*
fobj
);
int32_t
tsdbTFileObjCmpr
(
const
STFileObj
**
fobj1
,
const
STFileObj
**
fobj2
);
struct
STFile
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
ca28c99f
...
...
@@ -331,7 +331,7 @@ static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCom
pCommitter
->
minRow
=
pInfo
->
info
.
config
.
tsdbCfg
.
minRows
;
pCommitter
->
maxRow
=
pInfo
->
info
.
config
.
tsdbCfg
.
maxRows
;
pCommitter
->
cmprAlg
=
pInfo
->
info
.
config
.
tsdbCfg
.
compression
;
pCommitter
->
sttTrigger
=
1
;
// TODO
pCommitter
->
sttTrigger
=
4
;
// TODO
pCommitter
->
aTbDataP
=
tsdbMemTableGetTbDataArray
(
pTsdb
->
imem
);
if
(
pCommitter
->
aTbDataP
==
NULL
)
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
ca28c99f
...
...
@@ -252,8 +252,8 @@ static int32_t apply_commit(STFileSystem *fs) {
if
(
fset1
&&
fset2
)
{
if
(
fset1
->
fid
<
fset2
->
fid
)
{
// delete fset1
(TODO: should set file remove)
TARRAY2_REMOVE
(
fsetArray1
,
i1
,
tsdbTFileSet
Clear
);
// delete fset1
TARRAY2_REMOVE
(
fsetArray1
,
i1
,
tsdbTFileSet
Remove
);
}
else
if
(
fset1
->
fid
>
fset2
->
fid
)
{
// create new file set with fid of fset2->fid
code
=
tsdbTFileSetInitEx
(
fs
->
pTsdb
,
fset2
,
&
fset1
);
...
...
@@ -270,8 +270,8 @@ static int32_t apply_commit(STFileSystem *fs) {
i2
++
;
}
}
else
if
(
fset1
)
{
// delete fset1
(TODO: should set file remove)
TARRAY2_REMOVE
(
fsetArray1
,
i1
,
tsdbTFileSet
Clear
);
// delete fset1
TARRAY2_REMOVE
(
fsetArray1
,
i1
,
tsdbTFileSet
Remove
);
}
else
{
// create new file set with fid of fset2->fid
code
=
tsdbTFileSetInitEx
(
fs
->
pTsdb
,
fset2
,
&
fset1
);
...
...
@@ -481,7 +481,7 @@ static int32_t edit_fs(STFileSystem *fs, const TFileOpArray *opArray) {
if
(
!
fset
||
fset
->
fid
!=
op
->
fid
)
{
STFileSet
tfset
=
{.
fid
=
op
->
fid
};
fset
=
&
tfset
;
fset
=
TARRAY2_SEARCH
(
fsetArray
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
fset
=
TARRAY2_SEARCH
_EX
(
fsetArray
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
if
(
!
fset
)
{
code
=
tsdbTFileSetInit
(
op
->
fid
,
&
fset
);
...
...
@@ -589,6 +589,6 @@ int32_t tsdbFSEditAbort(STFileSystem *fs) {
int32_t
tsdbFSGetFSet
(
STFileSystem
*
fs
,
int32_t
fid
,
const
STFileSet
**
fset
)
{
STFileSet
tfset
=
{.
fid
=
fid
};
fset
[
0
]
=
&
tfset
;
fset
[
0
]
=
TARRAY2_SEARCH
(
&
fs
->
cstate
,
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
fset
[
0
]
=
TARRAY2_SEARCH
_EX
(
&
fs
->
cstate
,
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbFSet.c
浏览文件 @
ca28c99f
...
...
@@ -21,6 +21,7 @@ static int32_t tsdbSttLvlInit(int32_t level, SSttLvl **lvl) {
TARRAY2_INIT
(
&
lvl
[
0
]
->
farr
);
return
0
;
}
static
void
tsdbSttLvlClearFObj
(
void
*
data
)
{
tsdbTFileObjUnref
(
*
(
STFileObj
**
)
data
);
}
static
int32_t
tsdbSttLvlClear
(
SSttLvl
**
lvl
)
{
TARRAY2_CLEAR_FREE
(
&
lvl
[
0
]
->
farr
,
tsdbSttLvlClearFObj
);
...
...
@@ -28,6 +29,7 @@ static int32_t tsdbSttLvlClear(SSttLvl **lvl) {
lvl
[
0
]
=
NULL
;
return
0
;
}
static
int32_t
tsdbSttLvlInitEx
(
STsdb
*
pTsdb
,
const
SSttLvl
*
lvl1
,
SSttLvl
**
lvl
)
{
int32_t
code
=
tsdbSttLvlInit
(
lvl1
->
level
,
lvl
);
if
(
code
)
return
code
;
...
...
@@ -46,6 +48,13 @@ static int32_t tsdbSttLvlInitEx(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl
return
0
;
}
static
void
tsdbSttLvlRemoveFObj
(
void
*
data
)
{
tsdbTFileObjRemove
(
*
(
STFileObj
**
)
data
);
}
static
void
tsdbSttLvlRemove
(
SSttLvl
**
lvl
)
{
TARRAY2_CLEAR_FREE
(
&
lvl
[
0
]
->
farr
,
tsdbSttLvlRemoveFObj
);
taosMemoryFree
(
lvl
[
0
]);
lvl
[
0
]
=
NULL
;
}
static
int32_t
tsdbSttLvlCmprFn
(
const
SSttLvl
**
lvl1
,
const
SSttLvl
**
lvl2
)
{
if
(
lvl1
[
0
]
->
level
<
lvl2
[
0
]
->
level
)
return
-
1
;
if
(
lvl1
[
0
]
->
level
>
lvl2
[
0
]
->
level
)
return
1
;
...
...
@@ -291,10 +300,22 @@ int32_t tsdbTFileSetClear(STFileSet **fset) {
return
0
;
}
int32_t
tsdbTFileSetRemove
(
STFileSet
**
fset
)
{
for
(
tsdb_ftype_t
ftype
=
TSDB_FTYPE_MIN
;
ftype
<
TSDB_FTYPE_MAX
;
++
ftype
)
{
if
(
fset
[
0
]
->
farr
[
ftype
]
==
NULL
)
continue
;
tsdbTFileObjRemove
(
fset
[
0
]
->
farr
[
ftype
]);
}
TARRAY2_CLEAR_FREE
(
&
fset
[
0
]
->
lvlArr
,
tsdbSttLvlRemove
);
taosMemoryFree
(
fset
[
0
]);
fset
[
0
]
=
NULL
;
return
0
;
}
SSttLvl
*
tsdbTFileSetGetLvl
(
const
STFileSet
*
fset
,
int32_t
level
)
{
SSttLvl
tlvl
=
{.
level
=
level
};
SSttLvl
*
lvl
=
&
tlvl
;
return
TARRAY2_SEARCH
(
&
fset
->
lvlArr
,
&
lvl
,
tsdbSttLvlCmprFn
,
TD_EQ
);
return
TARRAY2_SEARCH
_EX
(
&
fset
->
lvlArr
,
lvl
,
tsdbSttLvlCmprFn
,
TD_EQ
);
}
int32_t
tsdbTFileSetCmprFn
(
const
STFileSet
**
fset1
,
const
STFileSet
**
fset2
)
{
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFile.c
浏览文件 @
ca28c99f
...
...
@@ -41,6 +41,11 @@ static const struct {
[
TSDB_FTYPE_STT
]
=
{
"stt"
,
stt_to_json
,
stt_from_json
},
};
static
void
remove_file
(
const
char
*
fname
)
{
taosRemoveFile
(
fname
);
tsdbInfo
(
"file:%s is removed"
,
fname
);
}
static
int32_t
tfile_to_json
(
const
STFile
*
file
,
cJSON
*
json
)
{
/* did.level */
if
(
cJSON_AddNumberToObject
(
json
,
"did.level"
,
file
->
did
.
level
)
==
NULL
)
{
...
...
@@ -201,7 +206,7 @@ int32_t tsdbTFileObjInit(STsdb *pTsdb, const STFile *f, STFileObj **fobj) {
taosThreadMutexInit
(
&
fobj
[
0
]
->
mutex
,
NULL
);
fobj
[
0
]
->
f
=
*
f
;
fobj
[
0
]
->
state
=
TSDB_FSTATE_
EXIST
;
fobj
[
0
]
->
state
=
TSDB_FSTATE_
LIVE
;
fobj
[
0
]
->
ref
=
1
;
tsdbTFileName
(
pTsdb
,
f
,
fobj
[
0
]
->
fname
);
return
0
;
...
...
@@ -210,23 +215,20 @@ int32_t tsdbTFileObjInit(STsdb *pTsdb, const STFile *f, STFileObj **fobj) {
int32_t
tsdbTFileObjRef
(
STFileObj
*
fobj
)
{
int32_t
nRef
;
taosThreadMutexLock
(
&
fobj
->
mutex
);
ASSERT
(
fobj
->
ref
>
0
&&
fobj
->
state
==
TSDB_FSTATE_LIVE
);
nRef
=
fobj
->
ref
++
;
taosThreadMutexUnlock
(
&
fobj
->
mutex
);
ASSERT
(
nRef
>
0
);
return
0
;
}
int32_t
tsdbTFileObjUnref
(
STFileObj
*
fobj
)
{
int32_t
nRef
;
taosThreadMutexLock
(
&
fobj
->
mutex
);
nRef
=
--
fobj
->
ref
;
int32_t
nRef
=
--
fobj
->
ref
;
taosThreadMutexUnlock
(
&
fobj
->
mutex
);
ASSERT
(
nRef
>=
0
);
if
(
nRef
==
0
)
{
if
(
fobj
->
state
==
TSDB_FSTATE_REMOVED
)
{
// TODO: add the file name
taosRemoveFile
(
fobj
->
fname
);
if
(
fobj
->
state
==
TSDB_FSTATE_DEAD
)
{
remove_file
(
fobj
->
fname
);
}
taosMemoryFree
(
fobj
);
}
...
...
@@ -234,13 +236,14 @@ int32_t tsdbTFileObjUnref(STFileObj *fobj) {
return
0
;
}
int32_t
tsdbTFileRemove
(
STFileObj
*
fobj
)
{
int32_t
tsdbTFile
Obj
Remove
(
STFileObj
*
fobj
)
{
taosThreadMutexLock
(
&
fobj
->
mutex
);
fobj
->
state
=
TSDB_FSTATE_REMOVED
;
ASSERT
(
fobj
->
state
==
TSDB_FSTATE_LIVE
&&
fobj
->
ref
>
0
);
fobj
->
state
=
TSDB_FSTATE_DEAD
;
int32_t
nRef
=
--
fobj
->
ref
;
taosThreadMutexUnlock
(
&
fobj
->
mutex
);
if
(
nRef
==
0
)
{
taosRemoveF
ile
(
fobj
->
fname
);
remove_f
ile
(
fobj
->
fname
);
taosMemoryFree
(
fobj
);
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录