refact some code
This commit is contained in:
parent
a9343acde4
commit
3efb2c7c53
|
@ -36,7 +36,6 @@ typedef struct TSDBROW TSDBROW;
|
||||||
typedef struct TSDBKEY TSDBKEY;
|
typedef struct TSDBKEY TSDBKEY;
|
||||||
typedef struct TABLEID TABLEID;
|
typedef struct TABLEID TABLEID;
|
||||||
typedef struct KEYINFO KEYINFO;
|
typedef struct KEYINFO KEYINFO;
|
||||||
typedef struct SDelOp SDelOp;
|
|
||||||
typedef struct SDelData SDelData;
|
typedef struct SDelData SDelData;
|
||||||
typedef struct SDelIdx SDelIdx;
|
typedef struct SDelIdx SDelIdx;
|
||||||
typedef struct STbData STbData;
|
typedef struct STbData STbData;
|
||||||
|
@ -257,8 +256,8 @@ struct STbData {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
KEYINFO info;
|
KEYINFO info;
|
||||||
SDelOp *pHead;
|
SDelData *pHead;
|
||||||
SDelOp *pTail;
|
SDelData *pTail;
|
||||||
SMemSkipList sl;
|
SMemSkipList sl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -358,17 +357,11 @@ struct STbDataIter {
|
||||||
TSDBROW row;
|
TSDBROW row;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDelOp {
|
|
||||||
int64_t version;
|
|
||||||
TSKEY sKey; // included
|
|
||||||
TSKEY eKey; // included
|
|
||||||
SDelOp *pNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SDelData {
|
struct SDelData {
|
||||||
int64_t version;
|
int64_t version;
|
||||||
TSKEY sKey;
|
TSKEY sKey;
|
||||||
TSKEY eKey;
|
TSKEY eKey;
|
||||||
|
SDelData *pNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDelIdx {
|
struct SDelIdx {
|
||||||
|
|
|
@ -149,12 +149,11 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDelIdx *pDelIdx) {
|
static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDelIdx *pDelIdx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SDelData delData;
|
SDelData *pDelData;
|
||||||
SDelOp *pDelOp;
|
tb_uid_t suid;
|
||||||
tb_uid_t suid;
|
tb_uid_t uid;
|
||||||
tb_uid_t uid;
|
SDelIdx delIdx; // TODO
|
||||||
SDelIdx delIdx; // TODO
|
|
||||||
|
|
||||||
// check no del data, just return
|
// check no del data, just return
|
||||||
if (pTbData && pTbData->pHead == NULL) {
|
if (pTbData && pTbData->pHead == NULL) {
|
||||||
|
@ -186,32 +185,28 @@ static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDel
|
||||||
|
|
||||||
// disk
|
// disk
|
||||||
for (int32_t iDelData = 0; iDelData < pCommitter->oDelDataMap.nItem; iDelData++) {
|
for (int32_t iDelData = 0; iDelData < pCommitter->oDelDataMap.nItem; iDelData++) {
|
||||||
code = tMapDataGetItemByIdx(&pCommitter->oDelDataMap, iDelData, &delData, tGetDelData);
|
code = tMapDataGetItemByIdx(&pCommitter->oDelDataMap, iDelData, pDelData, tGetDelData);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, &delData, tPutDelData);
|
code = tMapDataPutItem(&pCommitter->nDelDataMap, pDelData, tPutDelData);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
if (delIdx.minKey > delData.sKey) delIdx.minKey = delData.sKey;
|
if (delIdx.minKey > pDelData->sKey) delIdx.minKey = pDelData->sKey;
|
||||||
if (delIdx.maxKey < delData.eKey) delIdx.maxKey = delData.eKey;
|
if (delIdx.maxKey < pDelData->eKey) delIdx.maxKey = pDelData->eKey;
|
||||||
if (delIdx.minVersion > delData.version) delIdx.minVersion = delData.version;
|
if (delIdx.minVersion > pDelData->version) delIdx.minVersion = pDelData->version;
|
||||||
if (delIdx.maxVersion < delData.version) delIdx.maxVersion = delData.version;
|
if (delIdx.maxVersion < pDelData->version) delIdx.maxVersion = pDelData->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
pDelOp = pTbData ? pTbData->pHead : NULL;
|
pDelData = pTbData ? pTbData->pHead : NULL;
|
||||||
for (; pDelOp; pDelOp = pDelOp->pNext) {
|
for (; pDelData; pDelData = pDelData->pNext) {
|
||||||
delData.version = pDelOp->version;
|
code = tMapDataPutItem(&pCommitter->nDelDataMap, pDelData, tPutDelData);
|
||||||
delData.sKey = pDelOp->sKey;
|
|
||||||
delData.eKey = pDelOp->eKey;
|
|
||||||
|
|
||||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, &delData, tPutDelData);
|
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
if (delIdx.minKey > delData.sKey) delIdx.minKey = delData.sKey;
|
if (delIdx.minKey > pDelData->sKey) delIdx.minKey = pDelData->sKey;
|
||||||
if (delIdx.maxKey < delData.eKey) delIdx.maxKey = delData.eKey;
|
if (delIdx.maxKey < pDelData->eKey) delIdx.maxKey = pDelData->eKey;
|
||||||
if (delIdx.minVersion > delData.version) delIdx.minVersion = delData.version;
|
if (delIdx.minVersion > pDelData->version) delIdx.minVersion = pDelData->version;
|
||||||
if (delIdx.maxVersion < delData.version) delIdx.maxVersion = delData.version;
|
if (delIdx.maxVersion < pDelData->version) delIdx.maxVersion = pDelData->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pCommitter->nDelDataMap.nItem > 0);
|
ASSERT(pCommitter->nDelDataMap.nItem > 0);
|
||||||
|
|
|
@ -154,21 +154,21 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid
|
||||||
}
|
}
|
||||||
|
|
||||||
// do delete
|
// do delete
|
||||||
SDelOp *pDelOp = (SDelOp *)vnodeBufPoolMalloc(pPool, sizeof(*pDelOp));
|
SDelData *pDelData = (SDelData *)vnodeBufPoolMalloc(pPool, sizeof(*pDelData));
|
||||||
if (pDelOp == NULL) {
|
if (pDelData == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pDelOp->version = version;
|
pDelData->version = version;
|
||||||
pDelOp->sKey = sKey;
|
pDelData->sKey = sKey;
|
||||||
pDelOp->eKey = eKey;
|
pDelData->eKey = eKey;
|
||||||
pDelOp->pNext = NULL;
|
pDelData->pNext = NULL;
|
||||||
if (pTbData->pHead == NULL) {
|
if (pTbData->pHead == NULL) {
|
||||||
ASSERT(pTbData->pTail == NULL);
|
ASSERT(pTbData->pTail == NULL);
|
||||||
pTbData->pHead = pTbData->pTail = pDelOp;
|
pTbData->pHead = pTbData->pTail = pDelData;
|
||||||
} else {
|
} else {
|
||||||
pTbData->pTail->pNext = pDelOp;
|
pTbData->pTail->pNext = pDelData;
|
||||||
pTbData->pTail = pDelOp;
|
pTbData->pTail = pDelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the state of pMemTable and other (todo)
|
// update the state of pMemTable and other (todo)
|
||||||
|
|
Loading…
Reference in New Issue