Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
81488ee3
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看板
提交
81488ee3
编写于
11月 16, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/vnode' into 3.0
上级
c1c31645
e12b2d04
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
412 addition
and
151 deletion
+412
-151
docs/Doxyfile.in
docs/Doxyfile.in
+5
-5
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+10
-10
include/dnode/vnode/tsdb/tsdb.h
include/dnode/vnode/tsdb/tsdb.h
+9
-4
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+65
-9
include/libs/cache/cache.h
include/libs/cache/cache.h
+3
-3
include/util/mallocator.h
include/util/mallocator.h
+12
-28
include/util/tlist.h
include/util/tlist.h
+2
-1
source/dnode/vnode/impl/inc/vnodeBufferPool.h
source/dnode/vnode/impl/inc/vnodeBufferPool.h
+7
-11
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+12
-11
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
+6
-0
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
+188
-0
source/dnode/vnode/impl/src/vnodeMain.c
source/dnode/vnode/impl/src/vnodeMain.c
+1
-4
source/dnode/vnode/impl/src/vnodeMemAllocator.c
source/dnode/vnode/impl/src/vnodeMemAllocator.c
+14
-1
source/dnode/vnode/impl/src/vnodeWrite.c
source/dnode/vnode/impl/src/vnodeWrite.c
+9
-4
source/dnode/vnode/meta/inc/metaDef.h
source/dnode/vnode/meta/inc/metaDef.h
+9
-6
source/dnode/vnode/tsdb/inc/tsdbDef.h
source/dnode/vnode/tsdb/inc/tsdbDef.h
+6
-2
source/dnode/vnode/tsdb/inc/tsdbMemTable.h
source/dnode/vnode/tsdb/inc/tsdbMemTable.h
+7
-7
source/dnode/vnode/tsdb/src/tsdbMemTable.c
source/dnode/vnode/tsdb/src/tsdbMemTable.c
+0
-0
source/libs/CMakeLists.txt
source/libs/CMakeLists.txt
+1
-1
source/libs/cache/CMakeLists.txt
source/libs/cache/CMakeLists.txt
+7
-0
source/libs/cache/inc/cacheDef.h
source/libs/cache/inc/cacheDef.h
+3
-3
source/libs/cache/src/cache.c
source/libs/cache/src/cache.c
+14
-0
source/libs/cache/test/cacheTests.cpp
source/libs/cache/test/cacheTests.cpp
+0
-0
source/util/src/tlist.c
source/util/src/tlist.c
+8
-4
未找到文件。
docs/Doxyfile.in
浏览文件 @
81488ee3
...
...
@@ -491,7 +491,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC =
NO
EXTRACT_STATIC =
YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
...
...
@@ -1526,7 +1526,7 @@ ECLIPSE_DOC_ID = org.doxygen.Project
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
DISABLE_INDEX =
NO
DISABLE_INDEX =
YES
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. If the tag
...
...
@@ -1543,7 +1543,7 @@ DISABLE_INDEX = NO
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW =
NO
GENERATE_TREEVIEW =
YES
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.
...
...
@@ -2416,7 +2416,7 @@ INCLUDED_BY_GRAPH = YES
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALL_GRAPH =
NO
CALL_GRAPH =
YES
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
# dependency graph for every global function or class method.
...
...
@@ -2428,7 +2428,7 @@ CALL_GRAPH = NO
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALLER_GRAPH =
NO
CALLER_GRAPH =
YES
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
# hierarchy of all classes instead of a textual one.
...
...
include/dnode/vnode/meta/meta.h
浏览文件 @
81488ee3
...
...
@@ -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/dnode/vnode/tsdb/tsdb.h
浏览文件 @
81488ee3
...
...
@@ -16,15 +16,14 @@
#ifndef _TD_TSDB_H_
#define _TD_TSDB_H_
#include "impl/tsdbImpl.h"
#ifdef __cplusplus
extern
"C"
{
#endif
// TYPES EXPOSED
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdbOptions
STsdbOptions
;
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdbOptions
STsdbOptions
;
typedef
struct
STsdbMemAllocator
STsdbMemAllocator
;
// STsdb
STsdb
*
tsdbOpen
(
const
char
*
path
,
const
STsdbOptions
*
);
...
...
@@ -35,6 +34,12 @@ void tsdbRemove(const char *path);
int
tsdbOptionsInit
(
STsdbOptions
*
);
void
tsdbOptionsClear
(
STsdbOptions
*
);
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
struct
STsdbOptions
{
uint64_t
lruCacheSize
;
/* TODO */
};
#ifdef __cplusplus
}
#endif
...
...
include/dnode/vnode/vnode.h
浏览文件 @
81488ee3
...
...
@@ -17,9 +17,10 @@
#define _TD_VNODE_H_
#include "os.h"
#include "tr
equest
.h"
#include "tr
pc
.h"
#include "meta.h"
#include "tarray.h"
#include "tq.h"
#include "tsdb.h"
...
...
@@ -32,17 +33,72 @@ typedef struct SVnode SVnode;
typedef
struct
SVnodeOptions
SVnodeOptions
;
/* ------------------------ SVnode ------------------------ */
/**
* @brief Open a VNODE.
*
* @param path path of the vnode
* @param pVnodeOptions options of the vnode
* @return SVnode* The vnode object
*/
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeOptions
*
pVnodeOptions
);
void
vnodeClose
(
SVnode
*
pVnode
);
void
vnodeDestroy
(
const
char
*
path
);
int
vnodeProcessWriteReqs
(
SVnode
*
pVnode
,
SReqBatch
*
pReqBatch
);
int
vnodeApplyWriteRequest
(
SVnode
*
pVnode
,
const
SRequest
*
pRequest
);
int
vnodeProcessReadReq
(
SVnode
*
pVnode
,
SRequest
*
pReq
);
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRequest
*
pReq
);
/**
* @brief Close a VNODE
*
* @param pVnode The vnode object to close
*/
void
vnodeClose
(
SVnode
*
pVnode
);
/**
* @brief Destroy a VNODE.
*
* @param path Path of the VNODE.
*/
void
vnodeDestroy
(
const
char
*
path
);
/**
* @brief Process an array of write messages.
*
* @param pVnode The vnode object.
* @param pMsgs The array of SRpcMsg
* @return int 0 for success, -1 for failure
*/
int
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
);
/**
* @brief Apply a write request message.
*
* @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
);
/**
* @brief Process the sync request
*
* @param pVnode
* @param pMsg
* @param pRsp
* @return int
*/
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
/* ------------------------ SVnodeOptions ------------------------ */
void
vnodeOptionsInit
(
SVnodeOptions
*
);
void
vnodeOptionsClear
(
SVnodeOptions
*
);
/**
* @brief Initialize VNODE options.
*
* @param pOptions The options object to be initialized. It should not be NULL.
*/
void
vnodeOptionsInit
(
SVnodeOptions
*
pOptions
);
/**
* @brief Clear VNODE options.
*
* @param pOptions Options to clear.
*/
void
vnodeOptionsClear
(
SVnodeOptions
*
pOptions
);
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
struct
SVnodeOptions
{
...
...
include/libs/
lru/lru
.h
→
include/libs/
cache/cache
.h
浏览文件 @
81488ee3
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_
LRU
_H_
#define _TD_
LRU
_H_
#ifndef _TD_
CACHE
_H_
#define _TD_
CACHE
_H_
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -24,4 +24,4 @@ extern "C" {
}
#endif
#endif
/*_TD_LRU_H_*/
\ No newline at end of file
#endif
/*_TD_CACHE_H_*/
\ No newline at end of file
include/util/mallocator.h
浏览文件 @
81488ee3
...
...
@@ -24,37 +24,21 @@ extern "C" {
typedef
struct
SMemAllocator
SMemAllocator
;
#define MALLOCATOR_APIS \
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
char
name
[
16
];
void
*
impl
;
void
*
(
*
malloc
)(
SMemAllocator
*
,
uint64_t
size
);
void
*
(
*
calloc
)(
SMemAllocator
*
,
uint64_t
nmemb
,
uint64_t
size
);
void
*
(
*
realloc
)(
SMemAllocator
*
,
void
*
ptr
,
uint64_t
size
);
void
(
*
free
)(
SMemAllocator
*
,
void
*
ptr
);
uint64_t
(
*
usage
)(
SMemAllocator
*
);
};
// heap allocator
SMemAllocator
*
tdCreateHeapAllocator
();
void
tdDestroyHeapAllocator
(
SMemAllocator
*
pMemAllocator
);
// arena allocator
SMemAllocator
*
tdCreateArenaAllocator
(
size_t
size
);
void
tdDestroyArenaAllocator
(
SMemAllocator
*
);
#define mMalloc(pMemAllocator, size) (*(pMemAllocator->malloc))(pMemAllocator, size)
#define mCalloc(pMemAllocator, nmemb, size) (*(pMemAllocator->calloc))(pMemAllocator, nmemb, size)
#define mRealloc(pMemAllocator, ptr, size) (*(pMemAllocator->realloc))(pMemAllocator, ptr, size)
#define mFree(pMemAllocator, ptr) (*(pMemAllocator->free))(pMemAllocator, ptr)
#define mUsage(pMemAllocator) (*(pMemAllocator->usage))(pMemAllocator)
typedef
struct
{
void
*
impl
;
SMemAllocator
*
(
*
create
)();
void
(
*
destroy
)(
SMemAllocator
*
);
}
SMemAllocatorFactory
;
#ifdef __cplusplus
}
...
...
include/util/tlist.h
浏览文件 @
81488ee3
...
...
@@ -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
浏览文件 @
81488ee3
...
...
@@ -13,27 +13,23 @@
* 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
vnodeOpen
Allocator
Pool
(
SVnode
*
pVnode
);
void
vnodeClose
Allocator
Pool
(
SVnode
*
pVnode
);
int
vnodeOpen
Buf
Pool
(
SVnode
*
pVnode
);
void
vnodeClose
Buf
Pool
(
SVnode
*
pVnode
);
#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
浏览文件 @
81488ee3
...
...
@@ -19,9 +19,10 @@
#include "mallocator.h"
#include "sync.h"
#include "tlockfree.h"
#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"
...
...
@@ -33,16 +34,16 @@ extern "C" {
#endif
struct
SVnode
{
char
*
path
;
SVnodeOptions
options
;
SVState
state
;
SV
AllocatorPool
*
p
ool
;
SMe
mAllocator
*
inuse
;
S
Meta
*
pMeta
;
ST
sdb
*
pTsdb
;
S
TQ
*
pTq
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
char
*
path
;
SVnodeOptions
options
;
SVState
state
;
SV
BufPool
*
pBufP
ool
;
SMe
ta
*
pMeta
;
S
Tsdb
*
pTsdb
;
ST
Q
*
pTq
;
S
Wal
*
pWal
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
};
#ifdef __cplusplus
...
...
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
浏览文件 @
81488ee3
...
...
@@ -16,10 +16,16 @@
#ifndef _TD_VNODE_MEM_ALLOCATOR_H_
#define _TD_VNODE_MEM_ALLOCATOR_H_
#include "mallocator.h"
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
SMemAllocator
*
vnodeCreateMemAllocator
(
SVnode
*
pVnode
);
void
vnodeDestroyMemAllocator
(
SMemAllocator
*
pma
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/impl/inc/vnodeRequest.h
浏览文件 @
81488ee3
...
...
@@ -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
浏览文件 @
c1c31645
/*
* 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
浏览文件 @
81488ee3
/*
* 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 ------------------------ */
#define VNODE_BUF_POOL_SHARDS 3
struct
SVBufPool
{
SList
free
;
SList
incycle
;
SListNode
*
inuse
;
};
typedef
enum
{
// Heap allocator
E_V_HEAP_ALLOCATOR
=
0
,
// Arena allocator
E_V_ARENA_ALLOCATOR
}
EVMemAllocatorT
;
typedef
struct
{
/* TODO */
}
SVHeapAllocator
;
typedef
struct
SVArenaNode
{
struct
SVArenaNode
*
prev
;
uint64_t
size
;
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
{
uint64_t
ssize
;
// step size
uint64_t
lsize
;
// limit size
SVArenaNode
*
inuse
;
SVArenaNode
node
;
}
SVArenaAllocator
;
typedef
struct
{
T_REF_DECLARE
()
uint64_t
capacity
;
EVMemAllocatorT
type
;
union
{
SVHeapAllocator
vha
;
SVArenaAllocator
vaa
;
};
}
SVMemAllocator
;
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
);
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
);
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
/
VNODE_BUF_POOL_SHARDS
;
if
(
pVnode
->
options
.
isHeapAllocator
)
{
type
=
E_V_HEAP_ALLOCATOR
;
}
for
(
int
i
=
0
;
i
<
VNODE_BUF_POOL_SHARDS
;
i
++
)
{
SListNode
*
pNode
=
vBufPoolNewNode
(
capacity
,
type
);
if
(
pNode
==
NULL
)
{
vnodeCloseBufPool
(
pVnode
);
return
-
1
;
}
tdListAppendNode
(
&
(
pVnode
->
pBufPool
->
free
),
pNode
);
}
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
if
(
pVnode
->
pBufPool
->
inuse
)
{
vBufPoolFreeNode
(
pVnode
->
pBufPool
->
inuse
);
}
free
(
pVnode
->
pBufPool
);
pVnode
->
pBufPool
=
NULL
;
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static
void
vArenaAllocatorInit
(
SVArenaAllocator
*
pvaa
,
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
)
{
/* TODO */
pvaa
->
ssize
=
ssize
;
pvaa
->
lsize
=
lsize
;
pvaa
->
inuse
=
&
pvaa
->
node
;
pvaa
->
node
.
prev
=
NULL
;
pvaa
->
node
.
size
=
capacity
;
pvaa
->
node
.
ptr
=
pvaa
->
node
.
data
;
}
static
void
vArenaAllocatorClear
(
SVArenaAllocator
*
pvaa
)
{
/* TODO */
while
(
pvaa
->
inuse
!=
&
(
pvaa
->
node
))
{
SVArenaNode
*
pANode
=
pvaa
->
inuse
;
pvaa
->
inuse
=
pANode
->
prev
;
free
(
pANode
);
}
}
static
SListNode
*
vBufPoolNewNode
(
uint64_t
capacity
,
EVMemAllocatorT
type
)
{
SListNode
*
pNode
;
SVMemAllocator
*
pvma
;
uint64_t
msize
;
uint64_t
ssize
=
0
;
// TODO
uint64_t
lsize
=
0
;
// TODO
msize
=
sizeof
(
SListNode
)
+
sizeof
(
SVMemAllocator
);
if
(
type
==
E_V_ARENA_ALLOCATOR
)
{
msize
+=
capacity
;
}
pNode
=
(
SListNode
*
)
calloc
(
1
,
msize
);
if
(
pNode
==
NULL
)
{
// TODO: handle error
return
NULL
;
}
pvma
=
(
SVMemAllocator
*
)(
pNode
->
data
);
pvma
->
capacity
=
capacity
;
pvma
->
type
=
type
;
switch
(
type
)
{
case
E_V_ARENA_ALLOCATOR
:
vArenaAllocatorInit
(
&
(
pvma
->
vaa
),
capacity
,
ssize
,
lsize
);
break
;
case
E_V_HEAP_ALLOCATOR
:
// vHeapAllocatorInit(&(pvma->vha));
break
;
default:
ASSERT
(
0
);
}
return
pNode
;
}
static
void
vBufPoolFreeNode
(
SListNode
*
pNode
)
{
SVMemAllocator
*
pvma
=
(
SVMemAllocator
*
)(
pNode
->
data
);
switch
(
pvma
->
type
)
{
case
E_V_ARENA_ALLOCATOR
:
vArenaAllocatorClear
(
&
(
pvma
->
vaa
));
break
;
case
E_V_HEAP_ALLOCATOR
:
// vHeapAllocatorClear(&(pvma->vha));
break
;
default:
break
;
}
free
(
pNode
);
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeMain.c
浏览文件 @
81488ee3
...
...
@@ -87,8 +87,7 @@ static void vnodeFree(SVnode *pVnode) {
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
)
{
char
dir
[
TSDB_FILENAME_LEN
];
// Open allocator pool
if
(
vnodeOpenAllocatorPool
(
pVnode
)
<
0
)
{
if
(
vnodeOpenBufPool
(
pVnode
)
<
0
)
{
// TODO: handle error
return
-
1
;
}
...
...
@@ -132,8 +131,6 @@ static int vnodeOpenImpl(SVnode *pVnode) {
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
)
{
if
(
pVnode
)
{
vnodeCloseBufPool
(
pVnode
);
walClose
(
pVnode
->
pWal
);
tqClose
(
pVnode
->
pTq
);
tsdbClose
(
pVnode
->
pTsdb
);
metaClose
(
pVnode
->
pMeta
);
}
...
...
source/dnode/vnode/impl/src/vnodeMemAllocator.c
浏览文件 @
81488ee3
...
...
@@ -15,6 +15,17 @@
#include "vnodeDef.h"
SMemAllocator
*
vnodeCreateMemAllocator
(
SVnode
*
pVnode
)
{
SMemAllocator
*
pma
=
NULL
;
/* TODO */
return
pma
;
}
void
vnodeDestroyMemAllocator
(
SMemAllocator
*
pma
)
{
// TODO
}
#if 0
#define VNODE_HEAP_ALLOCATOR 0
#define VNODE_ARENA_ALLOCATOR 1
...
...
@@ -97,4 +108,6 @@ void vnodeUnrefMemAllocator(SMemAllocator *pma) {
/* ------------------------ Heap Allocator IMPL ------------------------ */
/* ------------------------ Arena Allocator IMPL ------------------------ */
\ No newline at end of file
/* ------------------------ Arena Allocator IMPL ------------------------ */
#endif
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeWrite.c
浏览文件 @
81488ee3
...
...
@@ -15,24 +15,25 @@
#include "vnodeDef.h"
int
vnodeProcessW
riteReqs
(
SVnode
*
pVnode
,
SReqBatch
*
pReqBatch
)
{
int
vnodeProcessW
Msgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
/* TODO */
return
0
;
}
int
vnodeApplyWriteRequest
(
SVnode
*
pVnode
,
const
SRequest
*
pRequest
)
{
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;
// Copy the request to vnode buffer
SRequest
*
pReq
=
mMalloc
(
pVnode
->
inuse
,
reqSize
);
void
*pReq = mMalloc(pVnode->inuse, reqSize);
if (pReq == NULL) {
// TODO: handle error
}
memcpy
(
pReq
,
p
Request
,
reqSize
);
memcpy(pReq, p
Msg
, reqSize);
// Push the request to TQ so consumers can consume
tqPushMsg(pVnode->pTq, pReq, 0);
...
...
@@ -45,7 +46,9 @@ int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) {
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 vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) {
}
return code;
#endif
return
0
;
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/dnode/vnode/meta/inc/metaDef.h
浏览文件 @
81488ee3
...
...
@@ -16,6 +16,8 @@
#ifndef _TD_META_DEF_H_
#define _TD_META_DEF_H_
#include "mallocator.h"
#include "meta.h"
#include "metaCache.h"
#include "metaDB.h"
...
...
@@ -30,12 +32,13 @@ extern "C" {
#endif
struct
SMeta
{
char
*
path
;
// path of current meta
SMetaOptions
options
;
// meta option
meta_db_t
*
pDB
;
// raw data db
meta_index_t
*
pIdx
;
// tag index
meta_cache_t
*
pCache
;
// LRU cache
STbUidGenerator
uidGnrt
;
// meta table UID generator
char
*
path
;
SMetaOptions
options
;
meta_db_t
*
pDB
;
meta_index_t
*
pIdx
;
meta_cache_t
*
pCache
;
STbUidGenerator
uidGnrt
;
SMemAllocatorFactory
*
pmaf
;
};
#ifdef __cplusplus
...
...
source/dnode/vnode/tsdb/inc/tsdbDef.h
浏览文件 @
81488ee3
...
...
@@ -16,7 +16,10 @@
#ifndef _TD_TSDB_DEF_H_
#define _TD_TSDB_DEF_H_
#include "mallocator.h"
#include "tsdb.h"
#include "tsdbMemTable.h"
#include "tsdbOptions.h"
#ifdef __cplusplus
...
...
@@ -24,8 +27,9 @@ extern "C" {
#endif
struct
STsdb
{
char
*
path
;
STsdbOptions
options
;
char
*
path
;
STsdbOptions
options
;
SMemAllocatorFactory
*
pmaf
;
};
#ifdef __cplusplus
...
...
include/dnode/vnode/tsdb/impl/tsdbImpl
.h
→
source/dnode/vnode/tsdb/inc/tsdbMemTable
.h
浏览文件 @
81488ee3
...
...
@@ -13,22 +13,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TSDB_
IMPL
_H_
#define _TD_TSDB_
IMPL
_H_
#ifndef _TD_TSDB_
MEM_TABLE
_H_
#define _TD_TSDB_
MEM_TABLE
_H_
#include "
os
.h"
#include "
tsdb
.h"
#ifdef __cplusplus
extern
"C"
{
#endif
struct
STsdbOptions
{
size_t
lruCacheSize
;
typedef
struct
SMemTable
{
/* TODO */
};
SMemAllocator
*
pma
;
}
SMemTable
;
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_IMPL_H_*/
\ No newline at end of file
#endif
/*_TD_TSDB_MEM_TABLE_H_*/
\ No newline at end of file
source/
libs/lru/src/lru
.c
→
source/
dnode/vnode/tsdb/src/tsdbMemTable
.c
浏览文件 @
81488ee3
文件已移动
source/libs/CMakeLists.txt
浏览文件 @
81488ee3
...
...
@@ -5,7 +5,7 @@ add_subdirectory(index)
add_subdirectory
(
wal
)
add_subdirectory
(
parser
)
add_subdirectory
(
scheduler
)
add_subdirectory
(
lru
)
add_subdirectory
(
cache
)
add_subdirectory
(
catalog
)
add_subdirectory
(
executor
)
add_subdirectory
(
planner
)
...
...
source/libs/
lru
/CMakeLists.txt
→
source/libs/
cache
/CMakeLists.txt
浏览文件 @
81488ee3
aux_source_directory
(
src
LRU
_SRC
)
add_library
(
lru
${
LRU
_SRC
}
)
aux_source_directory
(
src
CACHE
_SRC
)
add_library
(
cache
${
CACHE
_SRC
}
)
target_include_directories
(
lru
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/
lru
"
cache
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/
cache
"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
\ No newline at end of file
source/libs/
lru/inc/lruInt
.h
→
source/libs/
cache/inc/cacheDef
.h
浏览文件 @
81488ee3
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_
LRU_INT
_H_
#define _TD_
LRU_INT
_H_
#ifndef _TD_
CACHE_DEF
_H_
#define _TD_
CACHE_DEF
_H_
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -24,4 +24,4 @@ extern "C" {
}
#endif
#endif
/*_TD_LRU_INT_H_*/
\ No newline at end of file
#endif
/*_TD_CACHE_DEF_H_*/
\ No newline at end of file
source/libs/cache/src/cache.c
0 → 100644
浏览文件 @
81488ee3
/*
* 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/>.
*/
\ No newline at end of file
source/libs/
lru/test/lru
Tests.cpp
→
source/libs/
cache/test/cache
Tests.cpp
浏览文件 @
81488ee3
文件已移动
source/util/src/tlist.c
浏览文件 @
81488ee3
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录