more
This commit is contained in:
parent
735bd1c736
commit
2ae35c3404
|
@ -68,8 +68,8 @@ typedef struct STbCfg {
|
||||||
SMeta *metaOpen(const char *path, const SMetaCfg *pOptions);
|
SMeta *metaOpen(const char *path, const SMetaCfg *pOptions);
|
||||||
void metaClose(SMeta *pMeta);
|
void metaClose(SMeta *pMeta);
|
||||||
void metaRemove(const char *path);
|
void metaRemove(const char *path);
|
||||||
int metaCreateTable(SMeta *pMeta, const STbCfg *pTbOptions);
|
int metaCreateTable(SMeta *pMeta, const void *pReq, const int len);
|
||||||
int metaDropTable(SMeta *pMeta, tb_uid_t uid);
|
int metaDropTable(SMeta *pMeta, const void *pReq, const int len);
|
||||||
int metaCommit(SMeta *pMeta);
|
int metaCommit(SMeta *pMeta);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|
|
@ -29,7 +29,7 @@ typedef struct STsdbMemAllocator STsdbMemAllocator;
|
||||||
STsdb *tsdbOpen(const char *path, const STsdbCfg *);
|
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 *pData, int len);
|
||||||
|
|
||||||
// STsdbCfg
|
// STsdbCfg
|
||||||
int tsdbOptionsInit(STsdbCfg *);
|
int tsdbOptionsInit(STsdbCfg *);
|
||||||
|
@ -38,6 +38,9 @@ void tsdbOptionsClear(STsdbCfg *);
|
||||||
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
||||||
struct STsdbCfg {
|
struct STsdbCfg {
|
||||||
uint64_t lruCacheSize;
|
uint64_t lruCacheSize;
|
||||||
|
uint32_t keep0;
|
||||||
|
uint32_t keep1;
|
||||||
|
uint32_t keep2;
|
||||||
/* TODO */
|
/* TODO */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,37 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ------------------------ TYPES EXPOSED ------------------------ */
|
/* ------------------------ TYPES EXPOSED ------------------------ */
|
||||||
typedef struct SVnode SVnode;
|
typedef struct SVnode SVnode;
|
||||||
typedef struct SVnodeCfg SVnodeCfg;
|
typedef struct SVnodeCfg {
|
||||||
|
/** vnode buffer pool options */
|
||||||
|
struct {
|
||||||
|
/** write buffer size */
|
||||||
|
uint64_t wsize;
|
||||||
|
/** use heap allocator or arena allocator */
|
||||||
|
bool isHeapAllocator;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** time to live of tables in this vnode */
|
||||||
|
uint32_t ttl;
|
||||||
|
|
||||||
|
/** data to keep in this vnode */
|
||||||
|
uint32_t keep;
|
||||||
|
|
||||||
|
/** if TS data is eventually consistency */
|
||||||
|
bool isWeak;
|
||||||
|
|
||||||
|
/** TSDB config */
|
||||||
|
STsdbCfg tsdbCfg;
|
||||||
|
|
||||||
|
/** META config */
|
||||||
|
SMetaCfg metaCfg;
|
||||||
|
|
||||||
|
/** TQ config */
|
||||||
|
STqCfg tqCfg;
|
||||||
|
|
||||||
|
/** WAL config */
|
||||||
|
SWalCfg walCfg;
|
||||||
|
} SVnodeCfg;
|
||||||
|
|
||||||
/* ------------------------ SVnode ------------------------ */
|
/* ------------------------ SVnode ------------------------ */
|
||||||
/**
|
/**
|
||||||
|
@ -101,38 +130,6 @@ void vnodeOptionsInit(SVnodeCfg *pOptions);
|
||||||
*/
|
*/
|
||||||
void vnodeOptionsClear(SVnodeCfg *pOptions);
|
void vnodeOptionsClear(SVnodeCfg *pOptions);
|
||||||
|
|
||||||
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
|
||||||
struct SVnodeCfg {
|
|
||||||
/** vnode buffer pool options */
|
|
||||||
struct {
|
|
||||||
/** write buffer size */
|
|
||||||
uint64_t wsize;
|
|
||||||
/** use heap allocator or arena allocator */
|
|
||||||
bool isHeapAllocator;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** time to live of tables in this vnode *
|
|
||||||
uint32_t ttl;
|
|
||||||
|
|
||||||
/** data to keep in this vnode */
|
|
||||||
uint32_t keep;
|
|
||||||
|
|
||||||
/** if TS data is eventually consistency */
|
|
||||||
bool isWeak;
|
|
||||||
|
|
||||||
/** TSDB config */
|
|
||||||
STsdbCfg tsdbCfg;
|
|
||||||
|
|
||||||
/** META config */
|
|
||||||
SMetaCfg metaCfg;
|
|
||||||
|
|
||||||
/** TQ config */
|
|
||||||
STqCfg tqCfg;
|
|
||||||
|
|
||||||
/** WAL config */
|
|
||||||
SWalCfg walCfg;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------ FOR COMPILE ------------------------ */
|
/* ------------------------ FOR COMPILE ------------------------ */
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "vnodeBufferPool.h"
|
#include "vnodeBufferPool.h"
|
||||||
#include "vnodeCommit.h"
|
#include "vnodeCommit.h"
|
||||||
#include "vnodeFileSystem.h"
|
#include "vnodeFS.h"
|
||||||
#include "vnodeCfg.h"
|
#include "vnodeCfg.h"
|
||||||
#include "vnodeStateMgr.h"
|
#include "vnodeStateMgr.h"
|
||||||
#include "vnodeSync.h"
|
#include "vnodeSync.h"
|
||||||
|
|
|
@ -13,18 +13,35 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_FILE_SYSTEM_H_
|
#ifndef _TD_VNODE_FS_H_
|
||||||
#define _TD_VNODE_FILE_SYSTEM_H_
|
#define _TD_VNODE_FS_H_
|
||||||
|
|
||||||
|
#include "vnode.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
} SDir;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
} SFile;
|
||||||
|
|
||||||
|
typedef struct SFS {
|
||||||
|
void *pImpl;
|
||||||
|
int (*startEdit)(struct SFS *);
|
||||||
|
int (*endEdit)(struct SFS *);
|
||||||
|
} SFS;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
} SVnodeFS;
|
} SVnodeFS;
|
||||||
|
|
||||||
|
int vnodeOpenFS(SVnode *pVnode);
|
||||||
|
void vnodeCloseFS(SVnode *pVnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_FILE_SYSTEM_H_*/
|
#endif /*_TD_VNODE_FS_H_*/
|
|
@ -34,19 +34,19 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
|
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
case TSDB_MSG_TYPE_CREATE_TABLE:
|
case TSDB_MSG_TYPE_CREATE_TABLE:
|
||||||
if (metaCreateTable(pVnode->pMeta, pMsg->pCont) < 0) {
|
if (metaCreateTable(pVnode->pMeta, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_MSG_TYPE_DROP_TABLE:
|
case TSDB_MSG_TYPE_DROP_TABLE:
|
||||||
if (metaDropTable(pVnode->pMeta, pMsg->pCont) < 0) {
|
if (metaDropTable(pVnode->pMeta, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_MSG_TYPE_SUBMIT:
|
case TSDB_MSG_TYPE_SUBMIT:
|
||||||
if (tsdbInsertData(pVnode->pTsdb, pMsg->pCont) < 0) {
|
if (tsdbInsertData(pVnode->pTsdb, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,21 +15,22 @@
|
||||||
|
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
|
|
||||||
int metaCreateTable(SMeta *pMeta, const STbCfg *pTbOptions) {
|
int metaCreateTable(SMeta *pMeta, const void *pCont, const int len) {
|
||||||
|
STbCfg *pTbCfg = NULL;
|
||||||
// Validate the tbOptions
|
// Validate the tbOptions
|
||||||
if (metaValidateTbOptions(pMeta, pTbOptions) < 0) {
|
if (metaValidateTbOptions(pMeta, pTbCfg) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add atomicity
|
// TODO: add atomicity
|
||||||
|
|
||||||
if (metaSaveTableToDB(pMeta, pTbOptions) < 0) {
|
if (metaSaveTableToDB(pMeta, pTbCfg) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaSaveTableToIdx(pMeta, pTbOptions) < 0) {
|
if (metaSaveTableToIdx(pMeta, pTbCfg) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,8 @@ int metaCreateTable(SMeta *pMeta, const STbCfg *pTbOptions) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
|
int metaDropTable(SMeta *pMeta, const void *pCont, const int len) {
|
||||||
|
tb_uid_t uid;
|
||||||
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -49,8 +49,8 @@ STQ* tqOpen(const char* path, STqCfg* tqConfig, TqLogReader* tqLogReader, SMemAl
|
||||||
strcpy(pTq->path, path);
|
strcpy(pTq->path, path);
|
||||||
pTq->tqConfig = tqConfig;
|
pTq->tqConfig = tqConfig;
|
||||||
pTq->tqLogReader = tqLogReader;
|
pTq->tqLogReader = tqLogReader;
|
||||||
pTq->tqMemRef.pAlloctorFactory = allocFac;
|
// pTq->tqMemRef.pAlloctorFactory = allocFac;
|
||||||
pTq->tqMemRef.pAllocator = allocFac->create(allocFac);
|
// pTq->tqMemRef.pAllocator = allocFac->create(allocFac);
|
||||||
if(pTq->tqMemRef.pAllocator == NULL) {
|
if(pTq->tqMemRef.pAllocator == NULL) {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue