提交 2b5e0592 编写于 作者: H Hongze Cheng

refact

上级 9ae30318
...@@ -161,9 +161,9 @@ typedef struct TqLogReader { ...@@ -161,9 +161,9 @@ typedef struct TqLogReader {
int64_t (*logGetLastVer)(void* logHandle); int64_t (*logGetLastVer)(void* logHandle);
} TqLogReader; } TqLogReader;
typedef struct TqConfig { typedef struct STqCfg {
// TODO // TODO
} TqConfig; } STqCfg;
typedef struct TqMemRef { typedef struct TqMemRef {
SMemAllocatorFactory *pAlloctorFactory; SMemAllocatorFactory *pAlloctorFactory;
...@@ -256,14 +256,14 @@ typedef struct STQ { ...@@ -256,14 +256,14 @@ typedef struct STQ {
// the collection of group handle // the collection of group handle
// the handle of kvstore // the handle of kvstore
char* path; char* path;
TqConfig* tqConfig; STqCfg* tqConfig;
TqLogReader* tqLogReader; TqLogReader* tqLogReader;
TqMemRef tqMemRef; TqMemRef tqMemRef;
TqMetaStore* tqMeta; TqMetaStore* tqMeta;
} STQ; } STQ;
// open in each vnode // open in each vnode
STQ* tqOpen(const char* path, TqConfig* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac); STQ* tqOpen(const char* path, STqCfg* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac);
void tqDestroy(STQ*); void tqDestroy(STQ*);
// void* will be replace by a msg type // void* will be replace by a msg type
......
...@@ -22,21 +22,21 @@ extern "C" { ...@@ -22,21 +22,21 @@ extern "C" {
// TYPES EXPOSED // TYPES EXPOSED
typedef struct STsdb STsdb; typedef struct STsdb STsdb;
typedef struct STsdbOptions STsdbOptions; typedef struct STsdbCfg STsdbCfg;
typedef struct STsdbMemAllocator STsdbMemAllocator; typedef struct STsdbMemAllocator STsdbMemAllocator;
// STsdb // STsdb
STsdb *tsdbOpen(const char *path, const STsdbOptions *); STsdb *tsdbOpen(const char *path, const STsdbCfg *);
void tsdbClose(STsdb *); void tsdbClose(STsdb *);
void tsdbRemove(const char *path); void tsdbRemove(const char *path);
int tsdbInsertData(STsdb *pTsdb, void *); int tsdbInsertData(STsdb *pTsdb, void *);
// STsdbOptions // STsdbCfg
int tsdbOptionsInit(STsdbOptions *); int tsdbOptionsInit(STsdbCfg *);
void tsdbOptionsClear(STsdbOptions *); void tsdbOptionsClear(STsdbCfg *);
/* ------------------------ STRUCT DEFINITIONS ------------------------ */ /* ------------------------ STRUCT DEFINITIONS ------------------------ */
struct STsdbOptions { struct STsdbCfg {
uint64_t lruCacheSize; uint64_t lruCacheSize;
/* TODO */ /* TODO */
}; };
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "tarray.h" #include "tarray.h"
#include "tq.h" #include "tq.h"
#include "tsdb.h" #include "tsdb.h"
#include "wal.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -102,43 +103,34 @@ void vnodeOptionsClear(SVnodeCfg *pOptions); ...@@ -102,43 +103,34 @@ void vnodeOptionsClear(SVnodeCfg *pOptions);
/* ------------------------ STRUCT DEFINITIONS ------------------------ */ /* ------------------------ STRUCT DEFINITIONS ------------------------ */
struct SVnodeCfg { struct SVnodeCfg {
/** /** vnode buffer pool options */
* @brief write buffer size in BYTES struct {
* /** write buffer size */
*/ uint64_t wsize;
uint64_t wsize; /** use heap allocator or arena allocator */
bool isHeapAllocator;
/** };
* @brief time to live of tables in this vnode
* in SECONDS /** time to live of tables in this vnode *
*
*/
uint32_t ttl; uint32_t ttl;
/** /** data to keep in this vnode */
* @brief if time-series requests eventual consistency uint32_t keep;
*
*/ /** if TS data is eventually consistency */
bool isWeak; bool isWeak;
/** /** TSDB config */
* @brief if the allocator is heap allcator or arena allocator STsdbCfg tsdbCfg;
*
*/ /** META config */
bool isHeapAllocator; SMetaCfg metaCfg;
/** /** TQ config */
* @brief TSDB options STqCfg tqCfg;
*
*/ /** WAL config */
STsdbOptions tsdbOptions; SWalCfg walCfg;
/**
* @brief META options
*
*/
SMetaCfg metaOptions;
// STqOptions tqOptions; // TODO
}; };
/* ------------------------ FOR COMPILE ------------------------ */ /* ------------------------ FOR COMPILE ------------------------ */
......
...@@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) { ...@@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open meta // Open meta
sprintf(dir, "%s/meta", pVnode->path); sprintf(dir, "%s/meta", pVnode->path);
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaOptions)); pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg));
if (pVnode->pMeta == NULL) { if (pVnode->pMeta == NULL) {
// TODO: handle error // TODO: handle error
return -1; return -1;
...@@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) { ...@@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open tsdb // Open tsdb
sprintf(dir, "%s/tsdb", pVnode->path); sprintf(dir, "%s/tsdb", pVnode->path);
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbOptions)); pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbCfg));
if (pVnode->pTsdb == NULL) { if (pVnode->pTsdb == NULL) {
// TODO: handle error // TODO: handle error
return -1; return -1;
......
...@@ -40,7 +40,7 @@ void* tqSerializeBufItem(TqBufferItem* bufItem, void* ptr); ...@@ -40,7 +40,7 @@ void* tqSerializeBufItem(TqBufferItem* bufItem, void* ptr);
const void* tqDeserializeBufHandle(const void* pBytes, TqBufferHandle* bufHandle); const void* tqDeserializeBufHandle(const void* pBytes, TqBufferHandle* bufHandle);
const void* tqDeserializeBufItem(const void* pBytes, TqBufferItem* bufItem); const void* tqDeserializeBufItem(const void* pBytes, TqBufferItem* bufItem);
STQ* tqOpen(const char* path, TqConfig* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac) { STQ* tqOpen(const char* path, STqCfg* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac) {
STQ* pTq = malloc(sizeof(STQ)); STQ* pTq = malloc(sizeof(STQ));
if(pTq == NULL) { if(pTq == NULL) {
//TODO: memory error //TODO: memory error
......
...@@ -28,7 +28,7 @@ extern "C" { ...@@ -28,7 +28,7 @@ extern "C" {
struct STsdb { struct STsdb {
char * path; char * path;
STsdbOptions options; STsdbCfg options;
SMemAllocatorFactory *pmaf; SMemAllocatorFactory *pmaf;
}; };
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
extern "C" { extern "C" {
#endif #endif
extern const STsdbOptions defautlTsdbOptions; extern const STsdbCfg defautlTsdbOptions;
int tsdbValidateOptions(const STsdbOptions *); int tsdbValidateOptions(const STsdbCfg *);
void tsdbOptionsCopy(STsdbOptions *pDest, const STsdbOptions *pSrc); void tsdbOptionsCopy(STsdbCfg *pDest, const STsdbCfg *pSrc);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#include "tsdbDef.h" #include "tsdbDef.h"
static STsdb *tsdbNew(const char *path, const STsdbOptions *pTsdbOptions); static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions);
static void tsdbFree(STsdb *pTsdb); static void tsdbFree(STsdb *pTsdb);
static int tsdbOpenImpl(STsdb *pTsdb); static int tsdbOpenImpl(STsdb *pTsdb);
static void tsdbCloseImpl(STsdb *pTsdb); static void tsdbCloseImpl(STsdb *pTsdb);
STsdb *tsdbOpen(const char *path, const STsdbOptions *pTsdbOptions) { STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbOptions) {
STsdb *pTsdb = NULL; STsdb *pTsdb = NULL;
// Set default TSDB Options // Set default TSDB Options
...@@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) { ...@@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) {
void tsdbRemove(const char *path) { taosRemoveDir(path); } void tsdbRemove(const char *path) { taosRemoveDir(path); }
/* ------------------------ STATIC METHODS ------------------------ */ /* ------------------------ STATIC METHODS ------------------------ */
static STsdb *tsdbNew(const char *path, const STsdbOptions *pTsdbOptions) { static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions) {
STsdb *pTsdb = NULL; STsdb *pTsdb = NULL;
pTsdb = (STsdb *)calloc(1, sizeof(STsdb)); pTsdb = (STsdb *)calloc(1, sizeof(STsdb));
......
...@@ -15,20 +15,20 @@ ...@@ -15,20 +15,20 @@
#include "tsdbDef.h" #include "tsdbDef.h"
const STsdbOptions defautlTsdbOptions = {.lruCacheSize = 0}; const STsdbCfg defautlTsdbOptions = {.lruCacheSize = 0};
int tsdbOptionsInit(STsdbOptions *pTsdbOptions) { int tsdbOptionsInit(STsdbCfg *pTsdbOptions) {
// TODO // TODO
return 0; return 0;
} }
void tsdbOptionsClear(STsdbOptions *pTsdbOptions) { void tsdbOptionsClear(STsdbCfg *pTsdbOptions) {
// TODO // TODO
} }
int tsdbValidateOptions(const STsdbOptions *pTsdbOptions) { int tsdbValidateOptions(const STsdbCfg *pTsdbOptions) {
// TODO // TODO
return 0; return 0;
} }
void tsdbOptionsCopy(STsdbOptions *pDest, const STsdbOptions *pSrc) { memcpy(pDest, pSrc, sizeof(STsdbOptions)); } void tsdbOptionsCopy(STsdbCfg *pDest, const STsdbCfg *pSrc) { memcpy(pDest, pSrc, sizeof(STsdbCfg)); }
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册