more code
This commit is contained in:
parent
2ef773b0ab
commit
beab5f1fe3
|
@ -22,6 +22,7 @@ typedef struct {
|
|||
} SRowInfo;
|
||||
|
||||
typedef struct {
|
||||
SRowInfo rowInfo;
|
||||
SArray *aBlockL; // SArray<SBlockL>
|
||||
int32_t iBlockL;
|
||||
SBlockData bData;
|
||||
|
@ -32,7 +33,26 @@ typedef struct {
|
|||
SRBTree tMerge;
|
||||
} SDataMerger;
|
||||
|
||||
SRowInfo *tDataMergeNext(SDataMerger *pMerger) {
|
||||
static int32_t tRowInfoCmprFn(const void *p1, const void *p2) {
|
||||
SRowInfo *pInfo1 = (SRowInfo *)p1;
|
||||
SRowInfo *pInfo2 = (SRowInfo *)p2;
|
||||
|
||||
if (pInfo1->suid < pInfo2->suid) {
|
||||
return -1;
|
||||
} else if (pInfo1->suid > pInfo2->suid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pInfo1->uid < pInfo2->uid) {
|
||||
return -1;
|
||||
} else if (pInfo1->uid > pInfo2->uid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return tsdbRowCmprFn(&pInfo1->row, &pInfo2->row);
|
||||
}
|
||||
|
||||
static SRowInfo *tDataMergeNext(SDataMerger *pMerger) {
|
||||
SRowInfo *pRowInfo = NULL;
|
||||
|
||||
SRBTreeNode *pNode = pMerger->tMerge.minNode;
|
||||
|
|
|
@ -210,49 +210,6 @@ void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *pNode) {
|
|||
}
|
||||
|
||||
// drop impl
|
||||
if (pNode->left == NULL) {
|
||||
if (pNode->parent) {
|
||||
if (pNode == pNode->parent->left) {
|
||||
pNode->parent->left = pNode->right;
|
||||
} else {
|
||||
pNode->parent->right = pNode->right;
|
||||
}
|
||||
} else {
|
||||
pTree->rootNode = pNode->right;
|
||||
}
|
||||
|
||||
if (pNode->right) {
|
||||
pNode->right->parent = pNode->parent;
|
||||
}
|
||||
} else if (pNode->right == NULL) {
|
||||
if (pNode->parent) {
|
||||
if (pNode == pNode->parent->left) {
|
||||
pNode->parent->left = pNode->left;
|
||||
} else {
|
||||
pNode->parent->right = pNode->left;
|
||||
}
|
||||
} else {
|
||||
pTree->rootNode = pNode->left;
|
||||
}
|
||||
|
||||
if (pNode->left) {
|
||||
pNode->left->parent = pNode->parent;
|
||||
}
|
||||
} else {
|
||||
// TODO
|
||||
SRBTreeNode *pSuccessorNode = pNode->right;
|
||||
while (pSuccessorNode->left) {
|
||||
pSuccessorNode = pSuccessorNode->left;
|
||||
}
|
||||
|
||||
pSuccessorNode->parent->left = NULL; // todo: not correct here
|
||||
|
||||
pSuccessorNode->parent = pNode->parent;
|
||||
pSuccessorNode->left = pNode->left;
|
||||
pSuccessorNode->right = pNode->right;
|
||||
pNode->left->parent = pSuccessorNode;
|
||||
pNode->right->parent = pSuccessorNode;
|
||||
}
|
||||
|
||||
// fix
|
||||
if (pNode->color == BLACK) {
|
||||
|
|
Loading…
Reference in New Issue