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

more code

上级 fc8802df
......@@ -76,7 +76,6 @@ typedef struct SRSmaSnapReader SRSmaSnapReader;
typedef struct SRSmaSnapWriter SRSmaSnapWriter;
typedef struct SSnapDataHdr SSnapDataHdr;
typedef struct SCommitInfo SCommitInfo;
typedef struct SCompactInfo SCompactInfo;
#define VNODE_META_DIR "meta"
#define VNODE_TSDB_DIR "tsdb"
......@@ -428,13 +427,10 @@ struct SCommitInfo {
SVnodeInfo info;
SVnode* pVnode;
TXN* txn;
};
struct SCompactInfo {
SVnodeInfo info;
SVnode* pVnode;
TXN* txn;
};
// APIs
int32_t (*commitFn)(STsdb* pTsdb, SCommitInfo* pInfo);
};
#ifdef __cplusplus
}
#endif
......
......@@ -15,23 +15,26 @@
#include "tsdb.h"
// typedef struct {
// } SMemDIter;
typedef struct {
} SMemDIter;
typedef struct {
SArray *aBlockIdx; // SArray<SBlockIdx>
SMapData mDataBlk; // SMapData<SDataBlk>
SBlockData bData;
int32_t iBlockIdx;
int32_t iDataBlk;
int32_t iRow;
SDataFReader *pReader;
SArray *aBlockIdx; // SArray<SBlockIdx>
SMapData mDataBlk; // SMapData<SDataBlk>
SBlockData bData;
int32_t iBlockIdx;
int32_t iDataBlk;
int32_t iRow;
} SDataDIter;
typedef struct {
SArray *aSttBlk; // SArray<SSttBlk>
SBlockData bData;
int32_t iSttBlk;
int32_t iRow;
SDataFReader *pReader;
int32_t iStt;
SArray *aSttBlk; // SArray<SSttBlk>
SBlockData bData;
int32_t iSttBlk;
int32_t iRow;
} SSttDIter;
typedef struct {
......@@ -53,11 +56,66 @@ typedef struct {
#define TSDB_FLG_DEEP_COMPACT 0x1
// ITER =========================
static int32_t tsdbDataIterOpen(STsdbDataIter *pIter) {
static int32_t tsdbMemDIterOpen(STsdbDataIter **ppIter) {
int32_t code = 0;
int32_t lino = 0;
STsdbDataIter *pIter = (STsdbDataIter *)taosMemoryCalloc(1, sizeof(*pIter) + sizeof(SMemDIter));
if (pIter == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
// TODO
_exit:
if (code) {
*ppIter = NULL;
} else {
*ppIter = pIter;
}
return code;
}
static int32_t tsdbDataDIterOpen(SDataFReader *pReader, STsdbDataIter **ppIter) {
int32_t code = 0;
int32_t lino = 0;
STsdbDataIter *pIter = (STsdbDataIter *)taosMemoryCalloc(1, sizeof(*pIter) + sizeof(SDataDIter));
if (NULL == pIter) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
// TODO
_exit:
if (code) {
*ppIter = NULL;
} else {
*ppIter = pIter;
}
return code;
}
static int32_t tsdbSttDIterOpen(SDataFReader *pReader, STsdbDataIter **ppIter) {
int32_t code = 0;
int32_t lino = 0;
STsdbDataIter *pIter = (STsdbDataIter *)taosMemoryCalloc(1, sizeof(*pIter) + sizeof(SSttDIter));
if (pIter == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
// TODO
_exit:
if (code) {
*ppIter = NULL;
} else {
*ppIter = pIter;
}
return code;
}
......
......@@ -17,9 +17,7 @@
extern void vnodePrepareCommit(SVnode *pVnode);
#define vnodePrepareCompact vnodePrepareCommit
static int32_t vnodeCompactImpl(SCompactInfo *pInfo) {
static int32_t vnodeCompactImpl(SCommitInfo *pInfo) {
int32_t code = 0;
// TODO
......@@ -30,7 +28,7 @@ static int32_t vnodeCompactImpl(SCompactInfo *pInfo) {
static int32_t vnodeCompactTask(void *param) {
int32_t code = 0;
SCompactInfo *pInfo = (SCompactInfo *)param;
SCommitInfo *pInfo = (SCommitInfo *)param;
// compact
vnodeCompactImpl(pInfo);
......@@ -46,10 +44,10 @@ int32_t vnodeAsyncCompact(SVnode *pVnode) {
int32_t code = 0;
// prepare
vnodePrepareCompact(pVnode);
vnodePrepareCommit(pVnode);
// schedule compact task
SCompactInfo *pInfo = taosMemoryCalloc(1, sizeof(*pInfo));
SCommitInfo *pInfo = taosMemoryCalloc(1, sizeof(*pInfo));
if (NULL == pInfo) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册