more code
This commit is contained in:
parent
3d50b62381
commit
8b58508e2e
|
@ -56,6 +56,7 @@ struct SRBTreeNode {
|
|||
|
||||
struct SRBTree {
|
||||
tRBTreeCmprFn cmprFn;
|
||||
int64_t n;
|
||||
SRBTreeNode *root;
|
||||
SRBTreeNode *min;
|
||||
SRBTreeNode *max;
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef struct SBlockCol SBlockCol;
|
|||
#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_DEFAULT_LAST_FILE 1
|
||||
#define TSDB_FHDR_SIZE 512
|
||||
|
||||
#define HAS_NONE ((int8_t)0x1)
|
||||
|
|
|
@ -78,6 +78,7 @@ typedef struct {
|
|||
SRBTree rbt;
|
||||
SDataIter dataIter;
|
||||
SDataIter aDataIter[TSDB_MAX_LAST_FILE];
|
||||
int8_t toLast;
|
||||
};
|
||||
struct {
|
||||
SDataFWriter *pWriter;
|
||||
|
@ -454,6 +455,10 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
|
|||
tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pIter);
|
||||
iIter++;
|
||||
}
|
||||
|
||||
pCommitter->toLast = 0;
|
||||
} else {
|
||||
pCommitter->toLast = 1;
|
||||
}
|
||||
|
||||
code = tsdbNextCommitRow(pCommitter);
|
||||
|
@ -1206,7 +1211,7 @@ _err:
|
|||
static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
|
||||
int32_t code = 0;
|
||||
|
||||
// Reader
|
||||
// reader
|
||||
pCommitter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pCommitter->dReader.aBlockIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1216,7 +1221,20 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
|
|||
code = tBlockDataCreate(&pCommitter->dReader.bData);
|
||||
if (code) goto _exit;
|
||||
|
||||
// Writer
|
||||
// merger
|
||||
for (int32_t iLast = 0; iLast < TSDB_MAX_LAST_FILE; iLast++) {
|
||||
SDataIter *pIter = &pCommitter->aDataIter[iLast];
|
||||
pIter->aBlockL = taosArrayInit(0, sizeof(SBlockL));
|
||||
if (pIter->aBlockL == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = tBlockDataCreate(&pIter->bData);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
// writer
|
||||
pCommitter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pCommitter->dWriter.aBlockIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1240,12 +1258,19 @@ _exit:
|
|||
}
|
||||
|
||||
static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
||||
// Reader
|
||||
// reader
|
||||
taosArrayDestroy(pCommitter->dReader.aBlockIdx);
|
||||
tMapDataClear(&pCommitter->dReader.mBlock);
|
||||
tBlockDataDestroy(&pCommitter->dReader.bData, 1);
|
||||
|
||||
// Writer
|
||||
// merger
|
||||
for (int32_t iLast = 0; iLast < TSDB_MAX_LAST_FILE; iLast++) {
|
||||
SDataIter *pIter = &pCommitter->aDataIter[iLast];
|
||||
taosArrayDestroy(pIter->aBlockL);
|
||||
tBlockDataDestroy(&pIter->bData, 1);
|
||||
}
|
||||
|
||||
// writer
|
||||
taosArrayDestroy(pCommitter->dWriter.aBlockIdx);
|
||||
taosArrayDestroy(pCommitter->dWriter.aBlockL);
|
||||
tMapDataClear(&pCommitter->dWriter.mBlock);
|
||||
|
|
|
@ -201,6 +201,7 @@ static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
|
|||
|
||||
void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn) {
|
||||
pTree->cmprFn = cmprFn;
|
||||
pTree->n = 0;
|
||||
pTree->NIL = &pTree->NILNODE;
|
||||
pTree->NIL->color = BLACK;
|
||||
pTree->NIL->parent = NULL;
|
||||
|
@ -250,6 +251,7 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) {
|
|||
if (pTree->max == pTree->NIL || pTree->cmprFn(pTree->max->payload, z->payload) < 0) {
|
||||
pTree->max = z;
|
||||
}
|
||||
pTree->n++;
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@ -294,6 +296,7 @@ void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z) {
|
|||
if (y_orignal_color == BLACK) {
|
||||
tRBTreeDropFix(pTree, x);
|
||||
}
|
||||
pTree->n--;
|
||||
}
|
||||
|
||||
SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
|
||||
|
|
Loading…
Reference in New Issue