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 TABLEID TABLEID;
|
||||
typedef struct KEYINFO KEYINFO;
|
||||
typedef struct SDelOp SDelOp;
|
||||
typedef struct SDelData SDelData;
|
||||
typedef struct SDelIdx SDelIdx;
|
||||
typedef struct STbData STbData;
|
||||
|
@ -257,8 +256,8 @@ struct STbData {
|
|||
tb_uid_t suid;
|
||||
tb_uid_t uid;
|
||||
KEYINFO info;
|
||||
SDelOp *pHead;
|
||||
SDelOp *pTail;
|
||||
SDelData *pHead;
|
||||
SDelData *pTail;
|
||||
SMemSkipList sl;
|
||||
};
|
||||
|
||||
|
@ -358,17 +357,11 @@ struct STbDataIter {
|
|||
TSDBROW row;
|
||||
};
|
||||
|
||||
struct SDelOp {
|
||||
int64_t version;
|
||||
TSKEY sKey; // included
|
||||
TSKEY eKey; // included
|
||||
SDelOp *pNext;
|
||||
};
|
||||
|
||||
struct SDelData {
|
||||
int64_t version;
|
||||
TSKEY sKey;
|
||||
TSKEY eKey;
|
||||
int64_t version;
|
||||
TSKEY sKey;
|
||||
TSKEY eKey;
|
||||
SDelData *pNext;
|
||||
};
|
||||
|
||||
struct SDelIdx {
|
||||
|
|
|
@ -149,12 +149,11 @@ _err:
|
|||
}
|
||||
|
||||
static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDelIdx *pDelIdx) {
|
||||
int32_t code = 0;
|
||||
SDelData delData;
|
||||
SDelOp *pDelOp;
|
||||
tb_uid_t suid;
|
||||
tb_uid_t uid;
|
||||
SDelIdx delIdx; // TODO
|
||||
int32_t code = 0;
|
||||
SDelData *pDelData;
|
||||
tb_uid_t suid;
|
||||
tb_uid_t uid;
|
||||
SDelIdx delIdx; // TODO
|
||||
|
||||
// check no del data, just return
|
||||
if (pTbData && pTbData->pHead == NULL) {
|
||||
|
@ -186,32 +185,28 @@ static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDel
|
|||
|
||||
// disk
|
||||
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;
|
||||
|
||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, &delData, tPutDelData);
|
||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, pDelData, tPutDelData);
|
||||
if (code) goto _err;
|
||||
|
||||
if (delIdx.minKey > delData.sKey) delIdx.minKey = delData.sKey;
|
||||
if (delIdx.maxKey < delData.eKey) delIdx.maxKey = delData.eKey;
|
||||
if (delIdx.minVersion > delData.version) delIdx.minVersion = delData.version;
|
||||
if (delIdx.maxVersion < delData.version) delIdx.maxVersion = delData.version;
|
||||
if (delIdx.minKey > pDelData->sKey) delIdx.minKey = pDelData->sKey;
|
||||
if (delIdx.maxKey < pDelData->eKey) delIdx.maxKey = pDelData->eKey;
|
||||
if (delIdx.minVersion > pDelData->version) delIdx.minVersion = pDelData->version;
|
||||
if (delIdx.maxVersion < pDelData->version) delIdx.maxVersion = pDelData->version;
|
||||
}
|
||||
|
||||
// memory
|
||||
pDelOp = pTbData ? pTbData->pHead : NULL;
|
||||
for (; pDelOp; pDelOp = pDelOp->pNext) {
|
||||
delData.version = pDelOp->version;
|
||||
delData.sKey = pDelOp->sKey;
|
||||
delData.eKey = pDelOp->eKey;
|
||||
|
||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, &delData, tPutDelData);
|
||||
pDelData = pTbData ? pTbData->pHead : NULL;
|
||||
for (; pDelData; pDelData = pDelData->pNext) {
|
||||
code = tMapDataPutItem(&pCommitter->nDelDataMap, pDelData, tPutDelData);
|
||||
if (code) goto _err;
|
||||
|
||||
if (delIdx.minKey > delData.sKey) delIdx.minKey = delData.sKey;
|
||||
if (delIdx.maxKey < delData.eKey) delIdx.maxKey = delData.eKey;
|
||||
if (delIdx.minVersion > delData.version) delIdx.minVersion = delData.version;
|
||||
if (delIdx.maxVersion < delData.version) delIdx.maxVersion = delData.version;
|
||||
if (delIdx.minKey > pDelData->sKey) delIdx.minKey = pDelData->sKey;
|
||||
if (delIdx.maxKey < pDelData->eKey) delIdx.maxKey = pDelData->eKey;
|
||||
if (delIdx.minVersion > pDelData->version) delIdx.minVersion = pDelData->version;
|
||||
if (delIdx.maxVersion < pDelData->version) delIdx.maxVersion = pDelData->version;
|
||||
}
|
||||
|
||||
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
|
||||
SDelOp *pDelOp = (SDelOp *)vnodeBufPoolMalloc(pPool, sizeof(*pDelOp));
|
||||
if (pDelOp == NULL) {
|
||||
SDelData *pDelData = (SDelData *)vnodeBufPoolMalloc(pPool, sizeof(*pDelData));
|
||||
if (pDelData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
pDelOp->version = version;
|
||||
pDelOp->sKey = sKey;
|
||||
pDelOp->eKey = eKey;
|
||||
pDelOp->pNext = NULL;
|
||||
pDelData->version = version;
|
||||
pDelData->sKey = sKey;
|
||||
pDelData->eKey = eKey;
|
||||
pDelData->pNext = NULL;
|
||||
if (pTbData->pHead == NULL) {
|
||||
ASSERT(pTbData->pTail == NULL);
|
||||
pTbData->pHead = pTbData->pTail = pDelOp;
|
||||
pTbData->pHead = pTbData->pTail = pDelData;
|
||||
} else {
|
||||
pTbData->pTail->pNext = pDelOp;
|
||||
pTbData->pTail = pDelOp;
|
||||
pTbData->pTail->pNext = pDelData;
|
||||
pTbData->pTail = pDelData;
|
||||
}
|
||||
|
||||
// update the state of pMemTable and other (todo)
|
||||
|
|
Loading…
Reference in New Issue