refact
This commit is contained in:
parent
9ae3031898
commit
2b5e0592c4
|
@ -161,9 +161,9 @@ typedef struct TqLogReader {
|
|||
int64_t (*logGetLastVer)(void* logHandle);
|
||||
} TqLogReader;
|
||||
|
||||
typedef struct TqConfig {
|
||||
typedef struct STqCfg {
|
||||
// TODO
|
||||
} TqConfig;
|
||||
} STqCfg;
|
||||
|
||||
typedef struct TqMemRef {
|
||||
SMemAllocatorFactory *pAlloctorFactory;
|
||||
|
@ -256,14 +256,14 @@ typedef struct STQ {
|
|||
// the collection of group handle
|
||||
// the handle of kvstore
|
||||
char* path;
|
||||
TqConfig* tqConfig;
|
||||
STqCfg* tqConfig;
|
||||
TqLogReader* tqLogReader;
|
||||
TqMemRef tqMemRef;
|
||||
TqMetaStore* tqMeta;
|
||||
} STQ;
|
||||
|
||||
// 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* will be replace by a msg type
|
||||
|
|
|
@ -22,21 +22,21 @@ extern "C" {
|
|||
|
||||
// TYPES EXPOSED
|
||||
typedef struct STsdb STsdb;
|
||||
typedef struct STsdbOptions STsdbOptions;
|
||||
typedef struct STsdbCfg STsdbCfg;
|
||||
typedef struct STsdbMemAllocator STsdbMemAllocator;
|
||||
|
||||
// STsdb
|
||||
STsdb *tsdbOpen(const char *path, const STsdbOptions *);
|
||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *);
|
||||
void tsdbClose(STsdb *);
|
||||
void tsdbRemove(const char *path);
|
||||
int tsdbInsertData(STsdb *pTsdb, void *);
|
||||
|
||||
// STsdbOptions
|
||||
int tsdbOptionsInit(STsdbOptions *);
|
||||
void tsdbOptionsClear(STsdbOptions *);
|
||||
// STsdbCfg
|
||||
int tsdbOptionsInit(STsdbCfg *);
|
||||
void tsdbOptionsClear(STsdbCfg *);
|
||||
|
||||
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
||||
struct STsdbOptions {
|
||||
struct STsdbCfg {
|
||||
uint64_t lruCacheSize;
|
||||
/* TODO */
|
||||
};
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "tarray.h"
|
||||
#include "tq.h"
|
||||
#include "tsdb.h"
|
||||
#include "wal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -102,43 +103,34 @@ void vnodeOptionsClear(SVnodeCfg *pOptions);
|
|||
|
||||
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
||||
struct SVnodeCfg {
|
||||
/**
|
||||
* @brief write buffer size in BYTES
|
||||
*
|
||||
*/
|
||||
uint64_t wsize;
|
||||
/** vnode buffer pool options */
|
||||
struct {
|
||||
/** write buffer size */
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief if time-series requests eventual consistency
|
||||
*
|
||||
*/
|
||||
/** data to keep in this vnode */
|
||||
uint32_t keep;
|
||||
|
||||
/** if TS data is eventually consistency */
|
||||
bool isWeak;
|
||||
|
||||
/**
|
||||
* @brief if the allocator is heap allcator or arena allocator
|
||||
*
|
||||
*/
|
||||
bool isHeapAllocator;
|
||||
/** TSDB config */
|
||||
STsdbCfg tsdbCfg;
|
||||
|
||||
/**
|
||||
* @brief TSDB options
|
||||
*
|
||||
*/
|
||||
STsdbOptions tsdbOptions;
|
||||
/** META config */
|
||||
SMetaCfg metaCfg;
|
||||
|
||||
/**
|
||||
* @brief META options
|
||||
*
|
||||
*/
|
||||
SMetaCfg metaOptions;
|
||||
// STqOptions tqOptions; // TODO
|
||||
/** TQ config */
|
||||
STqCfg tqCfg;
|
||||
|
||||
/** WAL config */
|
||||
SWalCfg walCfg;
|
||||
};
|
||||
|
||||
/* ------------------------ FOR COMPILE ------------------------ */
|
||||
|
|
|
@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
|
||||
// Open meta
|
||||
sprintf(dir, "%s/meta", pVnode->path);
|
||||
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaOptions));
|
||||
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg));
|
||||
if (pVnode->pMeta == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
|||
|
||||
// Open tsdb
|
||||
sprintf(dir, "%s/tsdb", pVnode->path);
|
||||
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbOptions));
|
||||
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbCfg));
|
||||
if (pVnode->pTsdb == NULL) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
|
|
@ -40,7 +40,7 @@ void* tqSerializeBufItem(TqBufferItem* bufItem, void* ptr);
|
|||
const void* tqDeserializeBufHandle(const void* pBytes, TqBufferHandle* bufHandle);
|
||||
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));
|
||||
if(pTq == NULL) {
|
||||
//TODO: memory error
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
|
||||
struct STsdb {
|
||||
char * path;
|
||||
STsdbOptions options;
|
||||
STsdbCfg options;
|
||||
SMemAllocatorFactory *pmaf;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const STsdbOptions defautlTsdbOptions;
|
||||
extern const STsdbCfg defautlTsdbOptions;
|
||||
|
||||
int tsdbValidateOptions(const STsdbOptions *);
|
||||
void tsdbOptionsCopy(STsdbOptions *pDest, const STsdbOptions *pSrc);
|
||||
int tsdbValidateOptions(const STsdbCfg *);
|
||||
void tsdbOptionsCopy(STsdbCfg *pDest, const STsdbCfg *pSrc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
#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 int tsdbOpenImpl(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;
|
||||
|
||||
// Set default TSDB Options
|
||||
|
@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) {
|
|||
void tsdbRemove(const char *path) { taosRemoveDir(path); }
|
||||
|
||||
/* ------------------------ STATIC METHODS ------------------------ */
|
||||
static STsdb *tsdbNew(const char *path, const STsdbOptions *pTsdbOptions) {
|
||||
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions) {
|
||||
STsdb *pTsdb = NULL;
|
||||
|
||||
pTsdb = (STsdb *)calloc(1, sizeof(STsdb));
|
||||
|
|
|
@ -15,20 +15,20 @@
|
|||
|
||||
#include "tsdbDef.h"
|
||||
|
||||
const STsdbOptions defautlTsdbOptions = {.lruCacheSize = 0};
|
||||
const STsdbCfg defautlTsdbOptions = {.lruCacheSize = 0};
|
||||
|
||||
int tsdbOptionsInit(STsdbOptions *pTsdbOptions) {
|
||||
int tsdbOptionsInit(STsdbCfg *pTsdbOptions) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tsdbOptionsClear(STsdbOptions *pTsdbOptions) {
|
||||
void tsdbOptionsClear(STsdbCfg *pTsdbOptions) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
int tsdbValidateOptions(const STsdbOptions *pTsdbOptions) {
|
||||
int tsdbValidateOptions(const STsdbCfg *pTsdbOptions) {
|
||||
// TODO
|
||||
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)); }
|
Loading…
Reference in New Issue