提交 cc9496e5 编写于 作者: H Hongze Cheng

refact vnode

上级 0c605acf
......@@ -61,15 +61,25 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
int vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
// meta
typedef struct SMeta SMeta; // todo: remove
typedef struct SMTbCursor SMTbCursor;
typedef struct SMeta SMeta; // todo: remove
typedef struct SMetaReader SMetaReader;
typedef struct SMetaEntry SMetaEntry;
void metaReaderInit(SMetaReader *pReader, SVnode *pVnode, int32_t flags);
void metaReaderClear(SMetaReader *pReader);
int metaReadNext(SMetaReader *pReader);
const SMetaEntry *metaReaderGetEntry(SMetaReader *pReader);
typedef SVCreateTbReq STbCfg;
typedef SVCreateTSmaReq SSmaCfg;
#if 1
typedef struct SMTbCursor SMTbCursor;
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
void metaCloseTbCursor(SMTbCursor *pTbCur);
char *metaTbCursorNext(SMTbCursor *pTbCur);
#endif
// tsdb
typedef struct STsdb STsdb;
......@@ -167,6 +177,39 @@ typedef struct {
uint64_t uid;
} STableKeyInfo;
struct SMetaEntry {
int64_t version;
int8_t type;
tb_uid_t uid;
const char *name;
union {
struct {
SSchemaWrapper schema;
SSchemaWrapper schemaTag;
} stbEntry;
struct {
int64_t ctime;
int32_t ttlDays;
tb_uid_t suid;
const void *pTags;
} ctbEntry;
struct {
int64_t ctime;
int32_t ttlDays;
SSchemaWrapper schema;
} ntbEntry;
};
};
struct SMetaReader {
int32_t flags;
SMeta *pMeta;
SCoder coder;
SMetaEntry me;
void *pBuf;
int szBuf;
};
#ifdef __cplusplus
}
#endif
......
......@@ -40,8 +40,6 @@ int metaOpen(SVnode* pVnode, SMeta** ppMeta);
int metaClose(SMeta* pMeta);
// metaEntry ==================
typedef struct SMetaEntry SMetaEntry;
int metaEncodeEntry(SCoder* pCoder, const SMetaEntry* pME);
int metaDecodeEntry(SCoder* pCoder, SMetaEntry* pME);
......@@ -51,13 +49,9 @@ int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
// metaQuery ==================
typedef struct SMetaReader SMetaReader;
void metaEntryReaderInit(SMetaReader* pReader, SMeta* pMeta, int32_t flags);
void metaEntryReaderClear(SMetaReader* pReader);
int metaGetTableEntryByVersion(SMetaReader* pReader, int64_t version, tb_uid_t uid);
int metaGetTableEntryByUid(SMetaReader* pReader, tb_uid_t uid);
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
int metaGetTableEntryByVersion(SMetaReader* pReader, int64_t version, tb_uid_t uid);
int metaGetTableEntryByUid(SMetaReader* pReader, tb_uid_t uid);
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
// metaIdx ==================
int metaOpenIdx(SMeta* pMeta);
......@@ -134,39 +128,6 @@ SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid);
void metaCloseCtbCurosr(SMCtbCursor* pCtbCur);
tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur);
struct SMetaEntry {
int64_t version;
int8_t type;
tb_uid_t uid;
const char* name;
union {
struct {
SSchemaWrapper schema;
SSchemaWrapper schemaTag;
} stbEntry;
struct {
int64_t ctime;
int32_t ttlDays;
tb_uid_t suid;
const void* pTags;
} ctbEntry;
struct {
int64_t ctime;
int32_t ttlDays;
SSchemaWrapper schema;
} ntbEntry;
};
};
struct SMetaReader {
int32_t flags;
SMeta* pMeta;
SCoder coder;
SMetaEntry me;
void* pBuf;
int szBuf;
};
#ifndef META_REFACT
// SMetaDB
int metaOpenDB(SMeta* pMeta);
......
......@@ -15,13 +15,13 @@
#include "vnodeInt.h"
void metaEntryReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
void metaReaderInit(SMetaReader *pReader, SVnode *pVnode, int32_t flags) {
memset(pReader, 0, sizeof(*pReader));
pReader->flags = flags;
pReader->pMeta = pMeta;
pReader->pMeta = pVnode->pMeta;
}
void metaEntryReaderClear(SMetaReader *pReader) {
void metaReaderClear(SMetaReader *pReader) {
tCoderClear(&pReader->coder);
TDB_FREE(pReader->pBuf);
}
......@@ -74,7 +74,14 @@ int metaGetTableEntryByName(SMetaReader *pReader, const char *name) {
return metaGetTableEntryByUid(pReader, uid);
}
#if 1
int metaReadNext(SMetaReader *pReader) {
// TODO
return 0;
}
const SMetaEntry *metaReaderGetEntry(SMetaReader *pReader) { return &pReader->me; }
#if 1 // ===================================================
SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
SMTbCursor *pTbCur = NULL;
#if 0
......
......@@ -51,7 +51,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
}
// query meta
metaEntryReaderInit(&mer1, pVnode->pMeta, 0);
metaReaderInit(&mer1, pVnode, 0);
if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
goto _exit;
......@@ -66,7 +66,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
schemaTag = mer1.me.stbEntry.schemaTag;
metaRsp.suid = mer1.me.uid;
} else if (mer1.me.type == TSDB_CHILD_TABLE) {
metaEntryReaderInit(&mer2, pVnode->pMeta, 0);
metaReaderInit(&mer2, pVnode, 0);
if (metaGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
metaRsp.suid = mer2.me.uid;
......@@ -113,8 +113,8 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
_exit:
taosMemoryFree(metaRsp.pSchemas);
metaEntryReaderClear(&mer2);
metaEntryReaderClear(&mer1);
metaReaderClear(&mer2);
metaReaderClear(&mer1);
return code;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册