refact more code
This commit is contained in:
parent
7d023d72ca
commit
687dd81c44
|
@ -66,11 +66,11 @@ typedef struct SSmaInfo SSmaInfo;
|
|||
typedef struct SBlockCol SBlockCol;
|
||||
typedef struct SVersionRange SVersionRange;
|
||||
|
||||
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
|
||||
#define TSDB_MAX_SUBBLOCKS 8
|
||||
#define TSDB_MAX_LAST_FILE 16
|
||||
#define TSDB_DEFAULT_LAST_FILE 8
|
||||
#define TSDB_FHDR_SIZE 512
|
||||
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
|
||||
#define TSDB_MAX_SUBBLOCKS 8
|
||||
#define TSDB_MAX_SST_FILE 16
|
||||
#define TSDB_DEFAULT_SST_FILE 8
|
||||
#define TSDB_FHDR_SIZE 512
|
||||
|
||||
#define HAS_NONE ((int8_t)0x1)
|
||||
#define HAS_NULL ((int8_t)0x2)
|
||||
|
@ -563,7 +563,7 @@ struct SDFileSet {
|
|||
SDataFile *pDataF;
|
||||
SSmaFile *pSmaF;
|
||||
uint8_t nSstF;
|
||||
SSstFile *aSstF[TSDB_MAX_LAST_FILE];
|
||||
SSstFile *aSstF[TSDB_MAX_SST_FILE];
|
||||
};
|
||||
|
||||
struct SRowIter {
|
||||
|
@ -598,7 +598,7 @@ struct SDataFWriter {
|
|||
SHeadFile fHead;
|
||||
SDataFile fData;
|
||||
SSmaFile fSma;
|
||||
SSstFile fSst[TSDB_MAX_LAST_FILE];
|
||||
SSstFile fSst[TSDB_MAX_SST_FILE];
|
||||
|
||||
uint8_t *aBuf[4];
|
||||
};
|
||||
|
@ -615,7 +615,7 @@ struct SDataFReader {
|
|||
TdFilePtr pHeadFD;
|
||||
TdFilePtr pDataFD;
|
||||
TdFilePtr pSmaFD;
|
||||
TdFilePtr aLastFD[TSDB_MAX_LAST_FILE];
|
||||
TdFilePtr aLastFD[TSDB_MAX_SST_FILE];
|
||||
|
||||
uint8_t *aBuf[3];
|
||||
};
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct {
|
|||
SDataIter *pIter;
|
||||
SRBTree rbt;
|
||||
SDataIter dataIter;
|
||||
SDataIter aDataIter[TSDB_MAX_LAST_FILE];
|
||||
SDataIter aDataIter[TSDB_MAX_SST_FILE];
|
||||
int8_t toLastOnly;
|
||||
};
|
||||
struct {
|
||||
|
@ -760,7 +760,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
|||
pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows;
|
||||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||
pCommitter->maxLast = TSDB_DEFAULT_LAST_FILE; // TODO: make it as a config
|
||||
pCommitter->maxLast = TSDB_DEFAULT_SST_FILE; // TODO: make it as a config
|
||||
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
||||
if (pCommitter->aTbDataP == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -790,7 +790,7 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
|
|||
if (code) goto _exit;
|
||||
|
||||
// merger
|
||||
for (int32_t iSst = 0; iSst < TSDB_MAX_LAST_FILE; iSst++) {
|
||||
for (int32_t iSst = 0; iSst < TSDB_MAX_SST_FILE; iSst++) {
|
||||
SDataIter *pIter = &pCommitter->aDataIter[iSst];
|
||||
pIter->aSstBlk = taosArrayInit(0, sizeof(SSstBlk));
|
||||
if (pIter->aSstBlk == NULL) {
|
||||
|
@ -832,7 +832,7 @@ static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
|||
tBlockDataDestroy(&pCommitter->dReader.bData, 1);
|
||||
|
||||
// merger
|
||||
for (int32_t iSst = 0; iSst < TSDB_MAX_LAST_FILE; iSst++) {
|
||||
for (int32_t iSst = 0; iSst < TSDB_MAX_SST_FILE; iSst++) {
|
||||
SDataIter *pIter = &pCommitter->aDataIter[iSst];
|
||||
taosArrayDestroy(pIter->aSstBlk);
|
||||
tBlockDataDestroy(&pIter->bData, 1);
|
||||
|
|
|
@ -273,7 +273,8 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader* pFReader, uint64_t uid, STimeWindow* pTimeWindow, SVersionRange* pVerRange) {
|
||||
int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t uid,
|
||||
STimeWindow *pTimeWindow, SVersionRange *pVerRange) {
|
||||
pMTree->backward = backward;
|
||||
pMTree->pIter = NULL;
|
||||
pMTree->pIterList = taosArrayInit(4, POINTER_BYTES);
|
||||
|
@ -284,8 +285,8 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader* pFRead
|
|||
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
|
||||
int32_t code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
struct SLDataIter* pIterList[TSDB_DEFAULT_LAST_FILE] = {0};
|
||||
for(int32_t i = 0; i < pFReader->pSet->nSstF; ++i) { // open all last file
|
||||
struct SLDataIter *pIterList[TSDB_DEFAULT_SST_FILE] = {0};
|
||||
for (int32_t i = 0; i < pFReader->pSet->nSstF; ++i) { // open all last file
|
||||
code = tLDataIterOpen(&pIterList[i], pFReader, i, pMTree->backward, uid, pTimeWindow, pVerRange);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _end;
|
||||
|
@ -302,7 +303,7 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader* pFRead
|
|||
|
||||
return code;
|
||||
|
||||
_end:
|
||||
_end:
|
||||
tMergeTreeClose(pMTree);
|
||||
return code;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue