diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index 207157c415..139300ea80 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -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.
diff --git a/include/dnode/vnode/meta/meta.h b/include/dnode/vnode/meta/meta.h
index b94ffc7a5d..421f96ef5f 100644
--- a/include/dnode/vnode/meta/meta.h
+++ b/include/dnode/vnode/meta/meta.h
@@ -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
}
diff --git a/include/dnode/vnode/tsdb/tsdb.h b/include/dnode/vnode/tsdb/tsdb.h
index 949ac679ae..e92205378a 100644
--- a/include/dnode/vnode/tsdb/tsdb.h
+++ b/include/dnode/vnode/tsdb/tsdb.h
@@ -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
diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h
index 29e14a673a..52470d60a9 100644
--- a/include/dnode/vnode/vnode.h
+++ b/include/dnode/vnode/vnode.h
@@ -17,9 +17,10 @@
#define _TD_VNODE_H_
#include "os.h"
-#include "trequest.h"
+#include "trpc.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 {
diff --git a/include/libs/lru/lru.h b/include/libs/cache/cache.h
similarity index 91%
rename from include/libs/lru/lru.h
rename to include/libs/cache/cache.h
index c82e8ed746..6a2587ee96 100644
--- a/include/libs/lru/lru.h
+++ b/include/libs/cache/cache.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#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
diff --git a/include/util/mallocator.h b/include/util/mallocator.h
index a4705bdd2c..fd66811f38 100644
--- a/include/util/mallocator.h
+++ b/include/util/mallocator.h
@@ -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
}
diff --git a/include/util/tlist.h b/include/util/tlist.h
index 8246205e9b..e803e96605 100644
--- a/include/util/tlist.h
+++ b/include/util/tlist.h
@@ -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);
diff --git a/source/dnode/vnode/impl/inc/vnodeAllocatorPool.h b/source/dnode/vnode/impl/inc/vnodeBufferPool.h
similarity index 68%
rename from source/dnode/vnode/impl/inc/vnodeAllocatorPool.h
rename to source/dnode/vnode/impl/inc/vnodeBufferPool.h
index f02329fa87..3033862779 100644
--- a/source/dnode/vnode/impl/inc/vnodeAllocatorPool.h
+++ b/source/dnode/vnode/impl/inc/vnodeBufferPool.h
@@ -13,27 +13,23 @@
* along with this program. If not, see .
*/
-#ifndef _TD_VNODE_ALLOCATOR_POOL_H_
-#define _TD_VNODE_ALLOCATOR_POOL_H_
+#ifndef _TD_VNODE_BUFFER_POOL_H_
+#define _TD_VNODE_BUFFER_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);
#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
diff --git a/source/dnode/vnode/impl/inc/vnodeDef.h b/source/dnode/vnode/impl/inc/vnodeDef.h
index 3ad7de722e..9cf9210cf3 100644
--- a/source/dnode/vnode/impl/inc/vnodeDef.h
+++ b/source/dnode/vnode/impl/inc/vnodeDef.h
@@ -19,9 +19,10 @@
#include "mallocator.h"
#include "sync.h"
#include "tlockfree.h"
+#include "wal.h"
#include "vnode.h"
-#include "vnodeAllocatorPool.h"
+#include "vnodeBufferPool.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;
- SVAllocatorPool* pool;
- SMemAllocator* inuse;
- SMeta* pMeta;
- STsdb* pTsdb;
- STQ* pTq;
- 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
diff --git a/source/dnode/vnode/impl/inc/vnodeMemAllocator.h b/source/dnode/vnode/impl/inc/vnodeMemAllocator.h
index 7e9bd21fe3..9184eb416b 100644
--- a/source/dnode/vnode/impl/inc/vnodeMemAllocator.h
+++ b/source/dnode/vnode/impl/inc/vnodeMemAllocator.h
@@ -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
diff --git a/source/dnode/vnode/impl/inc/vnodeRequest.h b/source/dnode/vnode/impl/inc/vnodeRequest.h
index af909fb636..788918f105 100644
--- a/source/dnode/vnode/impl/inc/vnodeRequest.h
+++ b/source/dnode/vnode/impl/inc/vnodeRequest.h
@@ -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
diff --git a/source/dnode/vnode/impl/src/vnodeBufferPool.c b/source/dnode/vnode/impl/src/vnodeBufferPool.c
new file mode 100644
index 0000000000..eba71b5ba3
--- /dev/null
+++ b/source/dnode/vnode/impl/src/vnodeBufferPool.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * 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 .
+ */
+
+#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
diff --git a/source/dnode/vnode/impl/src/vnodeMain.c b/source/dnode/vnode/impl/src/vnodeMain.c
index f9efb88bd9..7381fb28af 100644
--- a/source/dnode/vnode/impl/src/vnodeMain.c
+++ b/source/dnode/vnode/impl/src/vnodeMain.c
@@ -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);
}
diff --git a/source/dnode/vnode/impl/src/vnodeMemAllocator.c b/source/dnode/vnode/impl/src/vnodeMemAllocator.c
index 3771a14113..902014eb47 100644
--- a/source/dnode/vnode/impl/src/vnodeMemAllocator.c
+++ b/source/dnode/vnode/impl/src/vnodeMemAllocator.c
@@ -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
diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c
index f3204cfd37..810ac570bc 100644
--- a/source/dnode/vnode/impl/src/vnodeWrite.c
+++ b/source/dnode/vnode/impl/src/vnodeWrite.c
@@ -15,24 +15,25 @@
#include "vnodeDef.h"
-int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) {
+int vnodeProcessWMsgs(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, pRequest, reqSize);
+ memcpy(pReq, pMsg, 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
diff --git a/source/dnode/vnode/meta/inc/metaDef.h b/source/dnode/vnode/meta/inc/metaDef.h
index 562476a439..b0d31de1b4 100644
--- a/source/dnode/vnode/meta/inc/metaDef.h
+++ b/source/dnode/vnode/meta/inc/metaDef.h
@@ -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
diff --git a/source/dnode/vnode/tsdb/inc/tsdbDef.h b/source/dnode/vnode/tsdb/inc/tsdbDef.h
index ebe0d6b4b0..ca3d0319c1 100644
--- a/source/dnode/vnode/tsdb/inc/tsdbDef.h
+++ b/source/dnode/vnode/tsdb/inc/tsdbDef.h
@@ -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
diff --git a/include/dnode/vnode/tsdb/impl/tsdbImpl.h b/source/dnode/vnode/tsdb/inc/tsdbMemTable.h
similarity index 80%
rename from include/dnode/vnode/tsdb/impl/tsdbImpl.h
rename to source/dnode/vnode/tsdb/inc/tsdbMemTable.h
index 04d2ec43c9..6be90ef53c 100644
--- a/include/dnode/vnode/tsdb/impl/tsdbImpl.h
+++ b/source/dnode/vnode/tsdb/inc/tsdbMemTable.h
@@ -13,22 +13,22 @@
* along with this program. If not, see .
*/
-#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
diff --git a/source/libs/lru/src/lru.c b/source/dnode/vnode/tsdb/src/tsdbMemTable.c
similarity index 100%
rename from source/libs/lru/src/lru.c
rename to source/dnode/vnode/tsdb/src/tsdbMemTable.c
diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt
index eeaac61e21..007bb1e967 100644
--- a/source/libs/CMakeLists.txt
+++ b/source/libs/CMakeLists.txt
@@ -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)
diff --git a/source/libs/cache/CMakeLists.txt b/source/libs/cache/CMakeLists.txt
new file mode 100644
index 0000000000..5ba59ef160
--- /dev/null
+++ b/source/libs/cache/CMakeLists.txt
@@ -0,0 +1,7 @@
+aux_source_directory(src CACHE_SRC)
+add_library(cache ${CACHE_SRC})
+target_include_directories(
+ cache
+ PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/cache"
+ PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
+)
\ No newline at end of file
diff --git a/source/libs/lru/inc/lruInt.h b/source/libs/cache/inc/cacheDef.h
similarity index 90%
rename from source/libs/lru/inc/lruInt.h
rename to source/libs/cache/inc/cacheDef.h
index e0da680104..2e0dbfcdb6 100644
--- a/source/libs/lru/inc/lruInt.h
+++ b/source/libs/cache/inc/cacheDef.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#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
diff --git a/source/dnode/vnode/impl/src/vnodeAllocatorPool.c b/source/libs/cache/src/cache.c
similarity index 61%
rename from source/dnode/vnode/impl/src/vnodeAllocatorPool.c
rename to source/libs/cache/src/cache.c
index b5617210a0..6dea4a4e57 100644
--- a/source/dnode/vnode/impl/src/vnodeAllocatorPool.c
+++ b/source/libs/cache/src/cache.c
@@ -11,27 +11,4 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
-
-#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
+ */
\ No newline at end of file
diff --git a/source/libs/lru/test/lruTests.cpp b/source/libs/cache/test/cacheTests.cpp
similarity index 100%
rename from source/libs/lru/test/lruTests.cpp
rename to source/libs/cache/test/cacheTests.cpp
diff --git a/source/libs/lru/CMakeLists.txt b/source/libs/lru/CMakeLists.txt
deleted file mode 100644
index b65615dbbf..0000000000
--- a/source/libs/lru/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-aux_source_directory(src LRU_SRC)
-add_library(lru ${LRU_SRC})
-target_include_directories(
- lru
- PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/lru"
- PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
-)
\ No newline at end of file
diff --git a/source/util/src/tlist.c b/source/util/src/tlist.c
index c5b4dbad10..6756af226f 100644
--- a/source/util/src/tlist.c
+++ b/source/util/src/tlist.c
@@ -13,16 +13,20 @@
* along with this program. If not, see .
*/
-#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;
}