Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d2390287
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看板
提交
d2390287
编写于
6月 27, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make it compile on win
上级
1ad05a06
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
75 addition
and
83 deletion
+75
-83
include/util/tarray2.h
include/util/tarray2.h
+58
-72
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+2
-1
source/dnode/vnode/src/tsdb/tsdbFS2.c
source/dnode/vnode/src/tsdb/tsdbFS2.c
+6
-4
source/dnode/vnode/src/tsdb/tsdbFSet2.c
source/dnode/vnode/src/tsdb/tsdbFSet2.c
+7
-5
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+2
-1
未找到文件。
include/util/tarray2.h
浏览文件 @
d2390287
...
...
@@ -47,23 +47,61 @@ typedef void (*TArray2Cb)(void *);
#define TARRAY2_LAST(a) ((a)->data[(a)->size - 1])
#define TARRAY2_DATA_LEN(a) ((a)->size * sizeof(typeof((a)->data[0])))
static
FORCE_INLINE
int32_t
tarray2_make_room
(
//
void
*
arg
,
// array
int32_t
es
,
// expected size
int32_t
sz
// size of element
)
{
TARRAY2
(
void
)
*
a
=
arg
;
static
FORCE_INLINE
int32_t
tarray2_make_room
(
void
*
arr
,
int32_t
expSize
,
int32_t
eleSize
)
{
TARRAY2
(
void
)
*
a
=
arr
;
int32_t
capacity
=
(
a
->
capacity
>
0
)
?
(
a
->
capacity
<<
1
)
:
32
;
while
(
capacity
<
e
s
)
{
while
(
capacity
<
e
xpSize
)
{
capacity
<<=
1
;
}
void
*
p
=
taosMemoryRealloc
(
a
->
data
,
capacity
*
sz
);
void
*
p
=
taosMemoryRealloc
(
a
->
data
,
capacity
*
eleSize
);
if
(
p
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
a
->
capacity
=
capacity
;
a
->
data
=
p
;
return
0
;
}
static
FORCE_INLINE
int32_t
tarray2InsertBatch
(
void
*
arr
,
int32_t
idx
,
const
void
*
elePtr
,
int32_t
numEle
,
int32_t
eleSize
)
{
TARRAY2
(
uint8_t
)
*
a
=
arr
;
int32_t
ret
=
0
;
if
(
a
->
size
+
numEle
>
a
->
capacity
)
{
ret
=
tarray2_make_room
(
a
,
a
->
size
+
numEle
,
eleSize
);
}
if
(
ret
==
0
)
{
if
(
idx
<
a
->
size
)
{
memmove
(
a
->
data
+
(
idx
+
numEle
)
*
eleSize
,
a
->
data
+
idx
*
eleSize
,
(
a
->
size
-
idx
)
*
eleSize
);
}
memcpy
(
a
->
data
+
idx
*
eleSize
,
elePtr
,
numEle
*
eleSize
);
a
->
size
+=
numEle
;
}
return
ret
;
}
static
FORCE_INLINE
void
*
tarray2Search
(
void
*
arr
,
const
void
*
elePtr
,
int32_t
eleSize
,
__compar_fn_t
compar
,
int32_t
flag
)
{
TARRAY2
(
void
)
*
a
=
arr
;
return
taosbsearch
(
elePtr
,
a
->
data
,
a
->
size
,
eleSize
,
compar
,
flag
);
}
static
FORCE_INLINE
int32_t
tarray2SearchIdx
(
void
*
arr
,
const
void
*
elePtr
,
int32_t
eleSize
,
__compar_fn_t
compar
,
int32_t
flag
)
{
TARRAY2
(
void
)
*
a
=
arr
;
void
*
p
=
taosbsearch
(
elePtr
,
a
->
data
,
a
->
size
,
eleSize
,
compar
,
flag
);
if
(
p
==
NULL
)
{
return
-
1
;
}
else
{
return
(
int32_t
)(((
uint8_t
*
)
p
-
(
uint8_t
*
)
a
->
data
)
/
eleSize
);
}
}
static
FORCE_INLINE
int32_t
tarray2SortInsert
(
void
*
arr
,
const
void
*
elePtr
,
int32_t
eleSize
,
__compar_fn_t
compar
)
{
TARRAY2
(
void
)
*
a
=
arr
;
int32_t
idx
=
tarray2SearchIdx
(
arr
,
elePtr
,
eleSize
,
compar
,
TD_GT
);
return
tarray2InsertBatch
(
arr
,
idx
<
0
?
a
->
size
:
idx
,
elePtr
,
1
,
eleSize
);
}
#define TARRAY2_INIT_EX(a, size_, capacity_, data_) \
do { \
(a)->size = (size_); \
...
...
@@ -94,72 +132,20 @@ static FORCE_INLINE int32_t tarray2_make_room( //
(a)->capacity = 0; \
} while (0)
#define TARRAY2_INSERT(a, idx, e) \
({ \
int32_t __ret = 0; \
if ((a)->size >= (a)->capacity) { \
__ret = tarray2_make_room((a), (a)->size + 1, sizeof(typeof((a)->data[0]))); \
} \
if (!__ret) { \
if ((a)->size > (idx)) { \
memmove((a)->data + (idx) + 1, (a)->data + (idx), sizeof(typeof((a)->data[0])) * ((a)->size - (idx))); \
} \
(a)->data[(idx)] = (e); \
(a)->size++; \
} \
__ret; \
})
#define TARRAY2_INSERT_PTR(a, idx, ep) TARRAY2_INSERT(a, idx, *(ep))
#define TARRAY2_APPEND(a, e) TARRAY2_INSERT(a, (a)->size, e)
#define TARRAY2_APPEND_PTR(a, ep) TARRAY2_APPEND(a, *(ep))
#define TARRAY2_APPEND_BATCH(a, ep, n) \
({ \
int32_t __ret = 0; \
if ((a)->size + (n) > (a)->capacity) { \
__ret = tarray2_make_room((a), (a)->size + (n), sizeof(typeof((a)->data[0]))); \
} \
if (!__ret) { \
memcpy((a)->data + (a)->size, (ep), sizeof(typeof((a)->data[0])) * (n)); \
(a)->size += (n); \
} \
__ret; \
})
#define TARRAY2_INSERT_PTR(a, idx, ep) tarray2InsertBatch(a, idx, ep, 1, sizeof(typeof((a)->data[0])))
#define TARRAY2_APPEND_PTR(a, ep) tarray2InsertBatch(a, (a)->size, ep, 1, sizeof(typeof((a)->data[0])))
#define TARRAY2_APPEND_BATCH(a, ep, n) tarray2InsertBatch(a, (a)->size, ep, n, sizeof(typeof((a)->data[0])))
#define TARRAY2_APPEND(a, e) TARRAY2_APPEND_PTR(a, &(e))
// return (TYPE *)
#define TARRAY2_SEARCH(a, ep, cmp, flag) \
({ \
typeof((a)->data) __ep = (ep); \
typeof((a)->data) __p; \
if ((a)->size > 0) { \
__p = taosbsearch(__ep, (a)->data, (a)->size, sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp, flag); \
} else { \
__p = NULL; \
} \
__p; \
})
// 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) \
({ \
typeof((a)->data) __p = TARRAY2_SEARCH(a, ep, cmp, flag); \
__p ? __p - (a)->data : -1; \
})
#define TARRAY2_SORT_INSERT(a, e, cmp) \
({ \
int32_t __idx = TARRAY2_SEARCH_IDX(a, &(e), cmp, TD_GT); \
TARRAY2_INSERT(a, __idx < 0 ? (a)->size : __idx, e); \
})
#define TARRAY2_SORT_INSERT_P(a, ep, cmp) TARRAY2_SORT_INSERT(a, *(ep), cmp)
#define TARRAY2_SEARCH(a, ep, cmp, flag) \
(typeof((a)->data))tarray2Search(a, ep, sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp, flag)
#define TARRAY2_SEARCH_IDX(a, ep, cmp, flag) \
tarray2SearchIdx(a, ep, sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp, flag)
#define TARRAY2_SORT_INSERT(a, e, cmp) tarray2SortInsert(a, &(e), sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp)
#define TARRAY2_SORT_INSERT_P(a, ep, cmp) tarray2SortInsert(a, ep, sizeof(typeof((a)->data[0])), (__compar_fn_t)cmp)
#define TARRAY2_REMOVE(a, idx, cb) \
do { \
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
浏览文件 @
d2390287
...
...
@@ -331,7 +331,8 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
STFileSet
fset
=
{.
fid
=
committer
->
ctx
->
fid
};
committer
->
ctx
->
fset
=
&
fset
;
committer
->
ctx
->
fset
=
TARRAY2_SEARCH_EX
(
committer
->
fsetArr
,
&
committer
->
ctx
->
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
STFileSet
**
fsetPtr
=
TARRAY2_SEARCH
(
committer
->
fsetArr
,
&
committer
->
ctx
->
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
committer
->
ctx
->
fset
=
(
fsetPtr
==
NULL
)
?
NULL
:
*
fsetPtr
;
committer
->
ctx
->
tbid
->
suid
=
0
;
committer
->
ctx
->
tbid
->
uid
=
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS2.c
浏览文件 @
d2390287
...
...
@@ -483,7 +483,8 @@ 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_EX
(
fsetArray
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
STFileSet
**
fsetPtr
=
TARRAY2_SEARCH
(
fsetArray
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
fset
=
(
fsetPtr
==
NULL
)
?
NULL
:
*
fsetPtr
;
if
(
!
fset
)
{
code
=
tsdbTFileSetInit
(
op
->
fid
,
&
fset
);
...
...
@@ -657,9 +658,10 @@ int32_t tsdbFSEditAbort(STFileSystem *fs) {
}
int32_t
tsdbFSGetFSet
(
STFileSystem
*
fs
,
int32_t
fid
,
STFileSet
**
fset
)
{
STFileSet
tfset
=
{.
fid
=
fid
};
STFileSet
*
pset
=
&
tfset
;
fset
[
0
]
=
TARRAY2_SEARCH_EX
(
fs
->
fSetArr
,
&
pset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
STFileSet
tfset
=
{.
fid
=
fid
};
STFileSet
*
pset
=
&
tfset
;
STFileSet
**
fsetPtr
=
TARRAY2_SEARCH
(
fs
->
fSetArr
,
&
pset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
fset
[
0
]
=
(
fsetPtr
==
NULL
)
?
NULL
:
fsetPtr
[
0
];
return
0
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbFSet2.c
浏览文件 @
d2390287
...
...
@@ -321,8 +321,9 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) {
SSttLvl
*
lvl
=
tsdbTFileSetGetSttLvl
(
fset
,
op
->
of
.
stt
->
level
);
ASSERT
(
lvl
);
STFileObj
tfobj
=
{.
f
[
0
]
=
{.
cid
=
op
->
of
.
cid
}},
*
tfobjp
=
&
tfobj
;
tfobjp
=
TARRAY2_SEARCH_EX
(
lvl
->
fobjArr
,
&
tfobjp
,
tsdbTFileObjCmpr
,
TD_EQ
);
STFileObj
tfobj
=
{.
f
[
0
]
=
{.
cid
=
op
->
of
.
cid
}},
*
tfobjp
=
&
tfobj
;
STFileObj
**
fobjPtr
=
TARRAY2_SEARCH
(
lvl
->
fobjArr
,
&
tfobjp
,
tsdbTFileObjCmpr
,
TD_EQ
);
tfobjp
=
(
fobjPtr
?
*
fobjPtr
:
NULL
);
ASSERT
(
tfobjp
);
...
...
@@ -504,9 +505,10 @@ int32_t tsdbTFileSetRemove(STFileSet **fset) {
}
SSttLvl
*
tsdbTFileSetGetSttLvl
(
STFileSet
*
fset
,
int32_t
level
)
{
SSttLvl
sttLvl
=
{.
level
=
level
};
SSttLvl
*
lvl
=
&
sttLvl
;
return
TARRAY2_SEARCH_EX
(
fset
->
lvlArr
,
&
lvl
,
tsdbSttLvlCmprFn
,
TD_EQ
);
SSttLvl
sttLvl
=
{.
level
=
level
};
SSttLvl
*
lvl
=
&
sttLvl
;
SSttLvl
**
lvlPtr
=
TARRAY2_SEARCH
(
fset
->
lvlArr
,
&
lvl
,
tsdbSttLvlCmprFn
,
TD_EQ
);
return
lvlPtr
?
lvlPtr
[
0
]
:
NULL
;
}
int32_t
tsdbTFileSetCmprFn
(
const
STFileSet
**
fset1
,
const
STFileSet
**
fset2
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
d2390287
...
...
@@ -764,7 +764,8 @@ static int32_t tsdbSnapWriteFileSetBegin(STsdbSnapWriter* writer, int32_t fid) {
STFileSet
*
fset
=
&
(
STFileSet
){.
fid
=
fid
};
writer
->
ctx
->
fid
=
fid
;
writer
->
ctx
->
fset
=
TARRAY2_SEARCH_EX
(
writer
->
fsetArr
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
STFileSet
**
fsetPtr
=
TARRAY2_SEARCH
(
writer
->
fsetArr
,
&
fset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
writer
->
ctx
->
fset
=
(
fsetPtr
==
NULL
)
?
NULL
:
*
fsetPtr
;
int32_t
level
=
tsdbFidLevel
(
fid
,
&
writer
->
tsdb
->
keepCfg
,
taosGetTimestampSec
());
if
(
tfsAllocDisk
(
writer
->
tsdb
->
pVnode
->
pTfs
,
level
,
&
writer
->
ctx
->
did
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录