Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
768ea68c
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看板
提交
768ea68c
编写于
11月 17, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
fed05bb6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
119 addition
and
37 deletion
+119
-37
include/dnode/vnode/tsdb/tsdb.h
include/dnode/vnode/tsdb/tsdb.h
+1
-0
include/util/mallocator.h
include/util/mallocator.h
+6
-6
source/dnode/vnode/impl/inc/vnodeStateMgr.h
source/dnode/vnode/impl/inc/vnodeStateMgr.h
+3
-0
source/dnode/vnode/impl/src/vnodeBufferPool.c
source/dnode/vnode/impl/src/vnodeBufferPool.c
+94
-2
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+15
-29
未找到文件。
include/dnode/vnode/tsdb/tsdb.h
浏览文件 @
768ea68c
...
...
@@ -29,6 +29,7 @@ typedef struct STsdbMemAllocator STsdbMemAllocator;
STsdb
*
tsdbOpen
(
const
char
*
path
,
const
STsdbOptions
*
);
void
tsdbClose
(
STsdb
*
);
void
tsdbRemove
(
const
char
*
path
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
void
*
);
// STsdbOptions
int
tsdbOptionsInit
(
STsdbOptions
*
);
...
...
include/util/mallocator.h
浏览文件 @
768ea68c
...
...
@@ -22,10 +22,10 @@
extern
"C"
{
#endif
typedef
struct
SMemAllocator
SMemAllocator
;
typedef
struct
SMemAllocator
SMemAllocator
;
typedef
struct
SMemAllocatorFactory
SMemAllocatorFactory
;
struct
SMemAllocator
{
char
name
[
16
];
void
*
impl
;
void
*
(
*
malloc
)(
SMemAllocator
*
,
uint64_t
size
);
void
*
(
*
calloc
)(
SMemAllocator
*
,
uint64_t
nmemb
,
uint64_t
size
);
...
...
@@ -34,11 +34,11 @@ struct SMemAllocator {
uint64_t
(
*
usage
)(
SMemAllocator
*
);
};
typedef
struct
{
struct
SMemAllocatorFactory
{
void
*
impl
;
SMemAllocator
*
(
*
create
)();
void
(
*
destroy
)(
SMemAllocator
*
);
}
SMemAllocatorFactory
;
SMemAllocator
*
(
*
create
)(
SMemAllocatorFactory
*
);
void
(
*
destroy
)(
SMemAllocator
Factory
*
,
SMemAllocator
*
);
};
#ifdef __cplusplus
}
...
...
source/dnode/vnode/impl/inc/vnodeStateMgr.h
浏览文件 @
768ea68c
...
...
@@ -21,6 +21,9 @@ extern "C" {
#endif
typedef
struct
{
uint64_t
processed
;
uint64_t
committed
;
uint64_t
applied
;
}
SVState
;
#ifdef __cplusplus
...
...
source/dnode/vnode/impl/src/vnodeBufferPool.c
浏览文件 @
768ea68c
...
...
@@ -19,9 +19,12 @@
#define VNODE_BUF_POOL_SHARDS 3
struct
SVBufPool
{
// buffer pool impl
SList
free
;
SList
incycle
;
SListNode
*
inuse
;
// MAF for submodules
SMemAllocatorFactory
maf
;
};
typedef
enum
{
...
...
@@ -49,6 +52,11 @@ typedef struct {
SVArenaNode
node
;
}
SVArenaAllocator
;
typedef
struct
{
SVnode
*
pVnode
;
SListNode
*
pNode
;
}
SVMAWrapper
;
typedef
struct
{
T_REF_DECLARE
()
uint64_t
capacity
;
...
...
@@ -59,8 +67,10 @@ typedef struct {
};
}
SVMemAllocator
;
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
);
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
);
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
);
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
);
static
SMemAllocator
*
vBufPoolCreateMA
(
SMemAllocatorFactory
*
pmaf
);
static
void
vBufPoolDestroyMA
(
SMemAllocatorFactory
*
pmaf
,
SMemAllocator
*
pma
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
)
{
uint64_t
capacity
;
...
...
@@ -89,6 +99,10 @@ int vnodeOpenBufPool(SVnode *pVnode) {
tdListAppendNode
(
&
(
pVnode
->
pBufPool
->
free
),
pNode
);
}
pVnode
->
pBufPool
->
maf
.
impl
=
pVnode
;
pVnode
->
pBufPool
->
maf
.
create
=
vBufPoolCreateMA
;
pVnode
->
pBufPool
->
maf
.
destroy
=
vBufPoolDestroyMA
;
return
0
;
}
...
...
@@ -185,4 +199,82 @@ static void vBufPoolFreeNode(SListNode *pNode) {
}
free
(
pNode
);
}
static
void
*
vBufPoolMalloc
(
SMemAllocator
*
pma
,
uint64_t
size
)
{
SVMAWrapper
*
pvmaw
=
(
SVMAWrapper
*
)(
pma
->
impl
);
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pvmaw
->
pNode
->
data
);
void
*
ptr
=
NULL
;
if
(
pvma
->
type
==
E_V_ARENA_ALLOCATOR
)
{
SVArenaAllocator
*
pvaa
=
&
(
pvma
->
vaa
);
if
(
POINTER_DISTANCE
(
pvaa
->
inuse
->
ptr
,
pvaa
->
inuse
->
data
)
+
size
>
pvaa
->
inuse
->
size
)
{
SVArenaNode
*
pNode
=
(
SVArenaNode
*
)
malloc
(
sizeof
(
*
pNode
)
+
MAX
(
size
,
pvaa
->
ssize
));
if
(
pNode
==
NULL
)
{
// TODO: handle error
return
NULL
;
}
pNode
->
prev
=
pvaa
->
inuse
;
pNode
->
size
=
MAX
(
size
,
pvaa
->
ssize
);
pNode
->
ptr
=
pNode
->
data
;
pvaa
->
inuse
=
pNode
;
}
ptr
=
pvaa
->
inuse
->
ptr
;
pvaa
->
inuse
->
ptr
=
POINTER_SHIFT
(
ptr
,
size
);
}
else
if
(
pvma
->
type
==
E_V_HEAP_ALLOCATOR
)
{
/* TODO */
}
return
NULL
;
}
static
SMemAllocator
*
vBufPoolCreateMA
(
SMemAllocatorFactory
*
pmaf
)
{
SVnode
*
pVnode
;
SMemAllocator
*
pma
;
SVMemAllocator
*
pvma
;
SVMAWrapper
*
pvmaw
;
pVnode
=
(
SVnode
*
)(
pmaf
->
impl
);
pma
=
(
SMemAllocator
*
)
calloc
(
1
,
sizeof
(
*
pma
)
+
sizeof
(
SVMAWrapper
));
if
(
pma
==
NULL
)
{
// TODO: handle error
return
NULL
;
}
pvmaw
=
(
SVMAWrapper
*
)
POINTER_SHIFT
(
pma
,
sizeof
(
*
pma
));
// No allocator used currently
if
(
pVnode
->
pBufPool
->
inuse
==
NULL
)
{
while
(
listNEles
(
&
(
pVnode
->
pBufPool
->
free
))
==
0
)
{
// TODO: wait until all released ro kill query
// tsem_wait();
ASSERT
(
0
);
}
pVnode
->
pBufPool
->
inuse
=
tdListPopHead
(
&
(
pVnode
->
pBufPool
->
free
));
pvma
=
(
SVMemAllocator
*
)(
pVnode
->
pBufPool
->
inuse
->
data
);
T_REF_INIT_VAL
(
pvma
,
1
);
}
else
{
pvma
=
(
SVMemAllocator
*
)(
pVnode
->
pBufPool
->
inuse
->
data
);
}
T_REF_INC
(
pvma
);
pvmaw
->
pVnode
=
pVnode
;
pvmaw
->
pNode
=
pVnode
->
pBufPool
->
inuse
;
pma
->
impl
=
pvmaw
;
pma
->
malloc
=
vBufPoolMalloc
;
pma
->
calloc
=
NULL
;
/* TODO */
pma
->
realloc
=
NULL
;
/* TODO */
pma
->
free
=
NULL
;
/* TODO */
pma
->
usage
=
NULL
;
/* TODO */
return
pma
;
}
static
void
vBufPoolDestroyMA
(
SMemAllocatorFactory
*
pmaf
,
SMemAllocator
*
pma
)
{
/* TODO */
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
768ea68c
...
...
@@ -21,46 +21,32 @@ 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 */
int code = 0;
// TODO
int
code
=
0
;
// Copy the request to vnode buffer
void *pReq = mMalloc(pVnode->inuse, reqSize);
if (pReq == NULL) {
// TODO: handle error
}
memcpy(pReq, pMsg, reqSize);
// Push the request to TQ so consumers can consume
tqPushMsg(pVnode->pTq, pReq, 0);
// Process the request
switch (reqType) {
switch
(
pMsg
->
msgType
)
{
case
TSDB_MSG_TYPE_CREATE_TABLE
:
code = metaCreateTable(pVnode->pMeta, NULL /* TODO */);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pMsg
->
pCont
)
<
0
)
{
/* TODO */
return
-
1
;
}
break
;
case
TSDB_MSG_TYPE_DROP_TABLE
:
code = metaDropTable(pVnode->pMeta, 0 /* TODO */);
if
(
metaDropTable
(
pVnode
->
pMeta
,
pMsg
->
pCont
)
<
0
)
{
/* TODO */
return
-
1
;
}
break
;
case
TSDB_MSG_TYPE_SUBMIT
:
/* TODO */
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
pMsg
->
pCont
)
<
0
)
{
/* TODO */
return
-
1
;
}
break
;
default:
break
;
}
if (vnodeShouldCommit(pVnode)) {
if (vnodeAsyncCommit(pVnode) < 0) {
// TODO: handle error
}
}
return code;
#endif
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录