提交 81488ee3 编写于 作者: H Hongze Cheng

Merge branch 'feature/vnode' into 3.0

......@@ -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.
......
......@@ -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
}
......
......@@ -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
......
......@@ -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 {
......
......@@ -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
......@@ -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
}
......
......@@ -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);
......
......@@ -13,27 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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
......@@ -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
......
......@@ -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
......
......@@ -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
......
/*
* 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
/*
* 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
......@@ -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);
}
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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)
......
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
......@@ -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
/*
* 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
......@@ -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.
先完成此消息的编辑!
想要评论请 注册