Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
15d9a466
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
15d9a466
编写于
11月 12, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
72777848
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
274 addition
and
89 deletion
+274
-89
include/server/vnode/meta/meta.h
include/server/vnode/meta/meta.h
+10
-10
include/server/vnode/vnode.h
include/server/vnode/vnode.h
+1
-0
include/util/mallocator.h
include/util/mallocator.h
+1
-7
include/util/tlist.h
include/util/tlist.h
+2
-1
source/dnode/vnode/impl/inc/vnodeBufferPool.h
source/dnode/vnode/impl/inc/vnodeBufferPool.h
+11
-11
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+11
-12
source/dnode/vnode/impl/inc/vnodeRequest.h
source/dnode/vnode/impl/inc/vnodeRequest.h
+14
-0
source/dnode/vnode/impl/src/vnodeAllocatorPool.c
source/dnode/vnode/impl/src/vnodeAllocatorPool.c
+0
-37
source/dnode/vnode/impl/src/vnodeBufferPool.c
source/dnode/vnode/impl/src/vnodeBufferPool.c
+211
-0
source/dnode/vnode/impl/src/vnodeMain.c
source/dnode/vnode/impl/src/vnodeMain.c
+0
-7
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+5
-0
source/util/src/tlist.c
source/util/src/tlist.c
+8
-4
未找到文件。
include/server/vnode/meta/meta.h
浏览文件 @
15d9a466
...
...
@@ -28,24 +28,24 @@ typedef struct SMetaOptions SMetaOptions;
typedef
struct
STbOptions
STbOptions
;
// SMeta operations
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaOptions
*
);
void
metaClose
(
SMeta
*
);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaOptions
*
pOptions
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STbOptions
*
);
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STbOptions
*
pTbOptions
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
);
int
metaCommit
(
SMeta
*
pMeta
);
// Options
void
metaOptionsInit
(
SMetaOptions
*
);
void
metaOptionsClear
(
SMetaOptions
*
);
void
metaOptionsInit
(
SMetaOptions
*
pOptions
);
void
metaOptionsClear
(
SMetaOptions
*
pOptions
);
// STableOpts
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
void
metaNormalTableOptsInit
(
STbOptions
*
,
const
char
*
name
,
const
STSchema
*
pSchema
);
void
metaSuperTableOptsInit
(
STbOptions
*
,
const
char
*
name
,
tb_uid_t
uid
,
const
STSchema
*
pSchema
,
void
metaNormalTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
const
STSchema
*
pSchema
);
void
metaSuperTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
tb_uid_t
uid
,
const
STSchema
*
pSchema
,
const
STSchema
*
pTagSchema
);
void
metaChildTableOptsInit
(
STbOptions
*
,
const
char
*
name
,
tb_uid_t
suid
,
const
SKVRow
tags
);
void
metaTableOptsClear
(
STbOptions
*
);
void
metaChildTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
tb_uid_t
suid
,
const
SKVRow
tags
);
void
metaTableOptsClear
(
STbOptions
*
pTbOptions
);
#ifdef __cplusplus
}
...
...
include/server/vnode/vnode.h
浏览文件 @
15d9a466
...
...
@@ -70,6 +70,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs);
*
* @param pVnode The vnode object.
* @param pMsg The request message
* @param pRsp The response message
* @return int 0 for success, -1 for failure
*/
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
...
...
include/util/mallocator.h
浏览文件 @
15d9a466
...
...
@@ -25,20 +25,14 @@ extern "C" {
typedef
struct
SMemAllocator
SMemAllocator
;
#define MALLOCATOR_APIS \
void *impl; \
void *(*malloc)(SMemAllocator *, size_t size); \
void *(*calloc)(SMemAllocator *, size_t nmemb, size_t size); \
void *(*realloc)(SMemAllocator *, void *ptr, size_t size); \
void (*free)(SMemAllocator *, void *ptr); \
size_t (*usage)(SMemAllocator *);
// Interfaces to implement
typedef
struct
{
MALLOCATOR_APIS
}
SMemAllocatorIf
;
struct
SMemAllocator
{
void
*
impl
;
size_t
usize
;
MALLOCATOR_APIS
};
...
...
include/util/tlist.h
浏览文件 @
15d9a466
...
...
@@ -46,9 +46,10 @@ typedef struct {
#define isListEmpty(l) ((l)->numOfEles == 0)
#define listNodeFree(n) free(n)
void
tdListInit
(
SList
*
list
,
int
eleSize
);
void
tdListEmpty
(
SList
*
list
);
SList
*
tdListNew
(
int
eleSize
);
void
*
tdListFree
(
SList
*
list
);
void
tdListEmpty
(
SList
*
list
);
void
tdListPrependNode
(
SList
*
list
,
SListNode
*
node
);
void
tdListAppendNode
(
SList
*
list
,
SListNode
*
node
);
int
tdListPrepend
(
SList
*
list
,
void
*
data
);
...
...
source/dnode/vnode/impl/inc/vnode
Allocato
rPool.h
→
source/dnode/vnode/impl/inc/vnode
Buffe
rPool.h
浏览文件 @
15d9a466
...
...
@@ -13,27 +13,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_
ALLOCATO
R_POOL_H_
#define _TD_VNODE_
ALLOCATO
R_POOL_H_
#ifndef _TD_VNODE_
BUFFE
R_POOL_H_
#define _TD_VNODE_
BUFFE
R_POOL_H_
#include "tlist.h"
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int
nexta
;
int
enda
;
SMemAllocator
*
free
[
3
];
SMemAllocator
*
used
[
3
];
}
SVAllocatorPool
;
typedef
struct
SVBufPool
SVBufPool
;
int
vnodeOpenAllocatorPool
(
SVnode
*
pVnode
);
void
vnodeCloseAllocatorPool
(
SVnode
*
pVnode
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
SMemAllocator
*
vnodeCreateMemAllocator
(
SVnode
*
pVnode
);
void
vnodeDestroyMemAllocator
(
SMemAllocator
*
pma
);
void
vnodeRefMemAllocator
(
SMemAllocator
*
pma
);
void
vnodeUnrefMemAllocator
(
SMemAllocator
*
pma
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_ALLOCATOR_POOL_H_*/
\ No newline at end of file
#endif
/*_TD_VNODE_BUFFER_POOL_H_*/
\ No newline at end of file
source/dnode/vnode/impl/inc/vnodeDef.h
浏览文件 @
15d9a466
...
...
@@ -22,7 +22,7 @@
#include "wal.h"
#include "vnode.h"
#include "vnode
Allocato
rPool.h"
#include "vnode
Buffe
rPool.h"
#include "vnodeCommit.h"
#include "vnodeFileSystem.h"
#include "vnodeOptions.h"
...
...
@@ -34,17 +34,16 @@ extern "C" {
#endif
struct
SVnode
{
char
*
path
;
SVnodeOptions
options
;
SVState
state
;
SVAllocatorPool
*
pool
;
SMemAllocator
*
inuse
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
char
*
path
;
SVnodeOptions
options
;
SVState
state
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
};
#ifdef __cplusplus
...
...
source/dnode/vnode/impl/inc/vnodeRequest.h
浏览文件 @
15d9a466
...
...
@@ -20,6 +20,20 @@
extern
"C"
{
#endif
typedef
struct
SVnodeReq
SVnodeReq
;
typedef
struct
SVnodeRsp
SVnodeRsp
;
typedef
enum
{
}
EVReqT
;
struct
SVnodeReq
{
/* TODO */
};
struct
SVnodeRsp
{
/* TODO */
};
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/impl/src/vnodeAllocatorPool.c
已删除
100644 → 0
浏览文件 @
72777848
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeDef.h"
int
vnodeOpenAllocatorPool
(
SVnode
*
pVnode
)
{
// TODO
return
0
;
}
void
vnodeCloseAllocatorPool
(
SVnode
*
pVnode
)
{
if
(
pVnode
->
pool
)
{
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SVAllocatorPool
*
vapCreate
()
{
SVAllocatorPool
*
pPool
=
NULL
;
/* TODO */
return
pPool
;
}
static
void
vapDestroy
()
{
// TODO
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeBufferPool.c
0 → 100644
浏览文件 @
15d9a466
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeDef.h"
/* ------------------------ STRUCTURES ------------------------ */
struct
SVBufPool
{
SList
free
;
SList
incycle
;
SListNode
*
inuse
;
};
typedef
enum
{
E_V_HEAP_ALLOCATOR
=
0
,
E_V_ARENA_ALLOCATOR
}
EVMemAllocatorT
;
typedef
struct
{
}
SVHeapAllocator
;
typedef
struct
SVArenaNode
{
struct
SVArenaNode
*
prev
;
uint64_t
size
;
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
{
SVArenaNode
*
inuse
;
SVArenaNode
node
;
}
SVArenaAllocator
;
typedef
struct
{
uint64_t
capacity
;
EVMemAllocatorT
type
;
T_REF_DECLARE
()
union
{
SVHeapAllocator
vha
;
SVArenaAllocator
vaa
;
};
}
SVMemAllocator
;
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
);
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
);
static
int
vArenaAllocatorInit
(
SVArenaAllocator
*
pvaa
);
static
void
vArenaAllocatorClear
(
SVArenaAllocator
*
pvaa
);
static
int
vHeapAllocatorInit
(
SVHeapAllocator
*
pvha
);
static
void
vHeapAllocatorClear
(
SVHeapAllocator
*
pvha
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
)
{
uint64_t
capacity
;
EVMemAllocatorT
type
=
E_V_ARENA_ALLOCATOR
;
if
((
pVnode
->
pBufPool
=
(
SVBufPool
*
)
calloc
(
1
,
sizeof
(
SVBufPool
)))
==
NULL
)
{
/* TODO */
return
-
1
;
}
tdListInit
(
&
(
pVnode
->
pBufPool
->
free
),
0
);
tdListInit
(
&
(
pVnode
->
pBufPool
->
incycle
),
0
);
capacity
=
pVnode
->
options
.
wsize
/
3
;
if
(
pVnode
->
options
.
isHeapAllocator
)
{
type
=
E_V_HEAP_ALLOCATOR
;
}
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
SListNode
*
pNode
=
vBufPoolNewNode
(
capacity
,
type
);
if
(
pNode
==
NULL
)
{
vnodeCloseBufPool
(
pVnode
);
return
-
1
;
}
tdListAppendNode
(
&
(
pVnode
->
pBufPool
->
free
),
pNode
);
}
pVnode
->
pBufPool
->
inuse
=
tdListPopHead
(
&
(
pVnode
->
pBufPool
->
free
));
return
0
;
}
void
vnodeCloseBufPool
(
SVnode
*
pVnode
)
{
SListNode
*
pNode
;
if
(
pVnode
->
pBufPool
)
{
// Clear free list
while
((
pNode
=
tdListPopHead
(
&
(
pVnode
->
pBufPool
->
free
)))
!=
NULL
)
{
vBufPoolFreeNode
(
pNode
);
}
// Clear incycle list
while
((
pNode
=
tdListPopHead
(
&
(
pVnode
->
pBufPool
->
incycle
)))
!=
NULL
)
{
vBufPoolFreeNode
(
pNode
);
}
// Free inuse node
vBufPoolFreeNode
(
pVnode
->
pBufPool
->
inuse
);
free
(
pVnode
->
pBufPool
);
pVnode
->
pBufPool
=
NULL
;
}
}
SMemAllocator
*
vnodeCreateMemAllocator
(
SVnode
*
pVnode
)
{
SMemAllocator
*
pma
;
pma
=
(
SMemAllocator
*
)
calloc
(
1
,
sizeof
(
*
pma
));
if
(
pma
==
NULL
)
{
/* TODO */
return
NULL
;
}
pma
->
impl
=
pVnode
;
if
(
pVnode
->
options
.
isHeapAllocator
)
{
/* TODO */
pma
->
malloc
=
NULL
;
pma
->
calloc
=
NULL
;
pma
->
realloc
=
NULL
;
pma
->
free
=
NULL
;
pma
->
usage
=
NULL
;
}
else
{
/* TODO */
pma
->
malloc
=
NULL
;
pma
->
calloc
=
NULL
;
pma
->
realloc
=
NULL
;
pma
->
free
=
NULL
;
pma
->
usage
=
NULL
;
}
return
pma
;
}
void
vnodeDestroyMemAllocator
(
SMemAllocator
*
pma
)
{
tfree
(
pma
);
}
void
vnodeRefMemAllocator
(
SMemAllocator
*
pma
)
{
SVnode
*
pVnode
=
(
SVnode
*
)
pma
->
impl
;
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pVnode
->
pBufPool
->
inuse
->
data
);
T_REF_INC
(
pvma
);
}
void
vnodeUnrefMemAllocator
(
SMemAllocator
*
pma
)
{
SVnode
*
pVnode
=
(
SVnode
*
)
pma
->
impl
;
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pVnode
->
pBufPool
->
inuse
->
data
);
if
(
T_REF_DEC
(
pvma
)
==
0
)
{
/* TODO */
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
)
{
SListNode
*
pNode
;
SVMemAllocator
*
pvma
;
pNode
=
(
SListNode
*
)
calloc
(
1
,
sizeof
(
*
pNode
)
+
sizeof
(
SVMemAllocator
));
if
(
pNode
==
NULL
)
{
return
NULL
;
}
pvma
=
(
SVMemAllocator
*
)(
pNode
->
data
);
pvma
->
capacity
=
capacity
;
pvma
->
type
=
type
;
switch
(
type
)
{
case
E_V_HEAP_ALLOCATOR
:
vHeapAllocatorInit
(
&
(
pvma
->
vha
));
break
;
case
E_V_ARENA_ALLOCATOR
:
vArenaAllocatorInit
(
&
(
pvma
->
vaa
));
break
;
default:
ASSERT
(
0
);
}
return
pNode
;
}
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
)
{
if
(
pNode
)
{
free
(
pNode
);
}
}
// --------------- For arena allocator
static
int
vArenaAllocatorInit
(
SVArenaAllocator
*
pvaa
)
{
// TODO
return
0
;
}
static
void
vArenaAllocatorClear
(
SVArenaAllocator
*
pvaa
)
{
// TODO
}
// --------------- For heap allocator
static
int
vHeapAllocatorInit
(
SVHeapAllocator
*
pvha
)
{
// TODO
return
0
;
}
static
void
vHeapAllocatorClear
(
SVHeapAllocator
*
pvha
)
{
// TODO
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeMain.c
浏览文件 @
15d9a466
...
...
@@ -87,12 +87,6 @@ static void vnodeFree(SVnode *pVnode) {
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
)
{
char
dir
[
TSDB_FILENAME_LEN
];
// Open allocator pool
if
(
vnodeOpenAllocatorPool
(
pVnode
)
<
0
)
{
// TODO: handle error
return
-
1
;
}
// Open meta
sprintf
(
dir
,
"%s/meta"
,
pVnode
->
path
);
pVnode
->
pMeta
=
metaOpen
(
dir
,
&
(
pVnode
->
options
.
metaOptions
));
...
...
@@ -117,7 +111,6 @@ static int vnodeOpenImpl(SVnode *pVnode) {
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
)
{
if
(
pVnode
)
{
vnodeCloseAllocatorPool
(
pVnode
);
// TODO: Close TQ
tsdbClose
(
pVnode
->
pTsdb
);
metaClose
(
pVnode
->
pMeta
);
...
...
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
15d9a466
...
...
@@ -21,6 +21,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
}
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
#if 0
int reqType; /* TODO */
size_t reqSize; /* TODO */
uint64_t reqVersion = 0; /* TODO */
...
...
@@ -45,7 +46,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
case TSDB_MSG_TYPE_DROP_TABLE:
code = metaDropTable(pVnode->pMeta, 0 /* TODO */);
break;
case TSDB_MSG_TYPE_SUBMIT:
/* TODO */
break;
default:
break;
}
...
...
@@ -57,6 +60,8 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
return code;
#endif
return
0
;
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/util/src/tlist.c
浏览文件 @
15d9a466
...
...
@@ -13,16 +13,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tlist.h"
#include "os.h"
void
tdListInit
(
SList
*
list
,
int
eleSize
)
{
list
->
eleSize
=
eleSize
;
list
->
numOfEles
=
0
;
list
->
head
=
list
->
tail
=
NULL
;
}
SList
*
tdListNew
(
int
eleSize
)
{
SList
*
list
=
(
SList
*
)
malloc
(
sizeof
(
SList
));
if
(
list
==
NULL
)
return
NULL
;
list
->
eleSize
=
eleSize
;
list
->
numOfEles
=
0
;
list
->
head
=
list
->
tail
=
NULL
;
tdListInit
(
list
,
eleSize
);
return
list
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录