refactor: do some internal refactor
This commit is contained in:
parent
4ea58e5682
commit
cbd24bb254
|
@ -731,13 +731,6 @@ typedef struct SSttBlockLoadInfo {
|
||||||
bool sttBlockLoaded;
|
bool sttBlockLoaded;
|
||||||
|
|
||||||
SSttBlockLoadCostInfo cost;
|
SSttBlockLoadCostInfo cost;
|
||||||
|
|
||||||
// keep the last access position, this position may be used to reduce the binary times for
|
|
||||||
// starting last block data for a new table
|
|
||||||
struct {
|
|
||||||
int32_t blockIndex;
|
|
||||||
int32_t rowIndex;
|
|
||||||
} prevEndPos;
|
|
||||||
} SSttBlockLoadInfo;
|
} SSttBlockLoadInfo;
|
||||||
|
|
||||||
typedef struct SMergeTree {
|
typedef struct SMergeTree {
|
||||||
|
|
|
@ -530,6 +530,7 @@ static int32_t tsdbCloseCommitter(SCommitter2 *committer, int32_t eno) {
|
||||||
ASSERT(committer->tombIterMerger == NULL);
|
ASSERT(committer->tombIterMerger == NULL);
|
||||||
TARRAY2_DESTROY(committer->dataIterArray, NULL);
|
TARRAY2_DESTROY(committer->dataIterArray, NULL);
|
||||||
TARRAY2_DESTROY(committer->tombIterArray, NULL);
|
TARRAY2_DESTROY(committer->tombIterArray, NULL);
|
||||||
|
TARRAY2_DESTROY(committer->sttReaderArray, NULL);
|
||||||
TARRAY2_DESTROY(committer->fopArray, NULL);
|
TARRAY2_DESTROY(committer->fopArray, NULL);
|
||||||
tsdbFSDestroyCopySnapshot(&committer->fsetArr);
|
tsdbFSDestroyCopySnapshot(&committer->fsetArr);
|
||||||
|
|
||||||
|
|
|
@ -120,14 +120,10 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||||
pLoadInfo->blockIndex[0] = -1;
|
pLoadInfo->blockIndex[0] = -1;
|
||||||
pLoadInfo->blockIndex[1] = -1;
|
pLoadInfo->blockIndex[1] = -1;
|
||||||
|
|
||||||
tStatisBlockDestroy(pLoadInfo->statisBlock);
|
|
||||||
TARRAY2_DESTROY((TStatisBlkArray*)pLoadInfo->pSttStatisBlkArray, NULL);
|
|
||||||
|
|
||||||
tBlockDataDestroy(&pLoadInfo->blockData[0]);
|
tBlockDataDestroy(&pLoadInfo->blockData[0]);
|
||||||
tBlockDataDestroy(&pLoadInfo->blockData[1]);
|
tBlockDataDestroy(&pLoadInfo->blockData[1]);
|
||||||
|
|
||||||
taosArrayDestroy(pLoadInfo->aSttBlk);
|
taosArrayDestroy(pLoadInfo->aSttBlk);
|
||||||
|
|
||||||
taosMemoryFree(pLoadInfo);
|
taosMemoryFree(pLoadInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -395,28 +391,27 @@ static bool existsFromSttBlkStatis(SSttBlockLoadInfo *pBlockLoadInfo, uint64_t s
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlockLoadInfo->statisBlock == NULL) {
|
// if (pBlockLoadInfo->statisBlock == NULL) {
|
||||||
pBlockLoadInfo->statisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock));
|
// pBlockLoadInfo->statisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock));
|
||||||
|
//
|
||||||
int64_t st = taosGetTimestampMs();
|
// int64_t st = taosGetTimestampMs();
|
||||||
tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock);
|
// tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock);
|
||||||
pBlockLoadInfo->statisBlockIndex = i;
|
// pBlockLoadInfo->statisBlockIndex = i;
|
||||||
|
//
|
||||||
double el = (taosGetTimestampMs() - st) / 1000.0;
|
// double el = (taosGetTimestampMs() - st) / 1000.0;
|
||||||
pBlockLoadInfo->cost.loadStatisBlocks += 1;
|
// pBlockLoadInfo->cost.loadStatisBlocks += 1;
|
||||||
pBlockLoadInfo->cost.statisElapsedTime += el;
|
// pBlockLoadInfo->cost.statisElapsedTime += el;
|
||||||
} else if (pBlockLoadInfo->statisBlockIndex != i) {
|
// } else if (pBlockLoadInfo->statisBlockIndex != i) {
|
||||||
tStatisBlockDestroy(pBlockLoadInfo->statisBlock);
|
// tStatisBlockDestroy(pBlockLoadInfo->statisBlock);
|
||||||
|
//
|
||||||
int64_t st = taosGetTimestampMs();
|
// int64_t st = taosGetTimestampMs();
|
||||||
tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock);
|
// tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock);
|
||||||
pBlockLoadInfo->statisBlockIndex = i;
|
// pBlockLoadInfo->statisBlockIndex = i;
|
||||||
|
//
|
||||||
|
// double el = (taosGetTimestampMs() - st) / 1000.0;
|
||||||
double el = (taosGetTimestampMs() - st) / 1000.0;
|
// pBlockLoadInfo->cost.loadStatisBlocks += 1;
|
||||||
pBlockLoadInfo->cost.loadStatisBlocks += 1;
|
// pBlockLoadInfo->cost.statisElapsedTime += el;
|
||||||
pBlockLoadInfo->cost.statisElapsedTime += el;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
STbStatisBlock* pBlock = pBlockLoadInfo->statisBlock;
|
STbStatisBlock* pBlock = pBlockLoadInfo->statisBlock;
|
||||||
int32_t index = tarray2SearchIdx(pBlock->suid, &suid, sizeof(int64_t), suidComparFn, TD_EQ);
|
int32_t index = tarray2SearchIdx(pBlock->suid, &suid, sizeof(int64_t), suidComparFn, TD_EQ);
|
||||||
|
@ -517,12 +512,12 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exists = existsFromSttBlkStatis(pBlockLoadInfo, suid, uid, pIter->pReader);
|
// bool exists = existsFromSttBlkStatis(pBlockLoadInfo, suid, uid, pIter->pReader);
|
||||||
if (!exists) {
|
// if (!exists) {
|
||||||
pIter->iSttBlk = -1;
|
// pIter->iSttBlk = -1;
|
||||||
pIter->pSttBlk = NULL;
|
// pIter->pSttBlk = NULL;
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// find the start block, actually we could load the position to avoid repeatly searching for the start position when
|
// find the start block, actually we could load the position to avoid repeatly searching for the start position when
|
||||||
// the skey is updated.
|
// the skey is updated.
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct STableBlockScanInfo {
|
||||||
SIterInfo iiter; // imem buffer skip list iterator
|
SIterInfo iiter; // imem buffer skip list iterator
|
||||||
SArray* delSkyline; // delete info for this table
|
SArray* delSkyline; // delete info for this table
|
||||||
int32_t fileDelIndex; // file block delete index
|
int32_t fileDelIndex; // file block delete index
|
||||||
int32_t lastBlockDelIndex; // delete index for last block
|
int32_t sttBlockDelIndex; // delete index for last block
|
||||||
bool iterInit; // whether to initialize the in-memory skip list iterator or not
|
bool iterInit; // whether to initialize the in-memory skip list iterator or not
|
||||||
} STableBlockScanInfo;
|
} STableBlockScanInfo;
|
||||||
|
|
||||||
|
@ -1976,7 +1976,7 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
|
||||||
pLastBlockReader->currentKey = key;
|
pLastBlockReader->currentKey = key;
|
||||||
pScanInfo->lastKeyInStt = key;
|
pScanInfo->lastKeyInStt = key;
|
||||||
|
|
||||||
if (!hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->lastBlockDelIndex, key, ver, pLastBlockReader->order,
|
if (!hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->sttBlockDelIndex, key, ver, pLastBlockReader->order,
|
||||||
pVerRange)) {
|
pVerRange)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3018,7 +3018,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
pBlockScanInfo->iter.index = index;
|
pBlockScanInfo->iter.index = index;
|
||||||
pBlockScanInfo->iiter.index = index;
|
pBlockScanInfo->iiter.index = index;
|
||||||
pBlockScanInfo->fileDelIndex = index;
|
pBlockScanInfo->fileDelIndex = index;
|
||||||
pBlockScanInfo->lastBlockDelIndex = index;
|
pBlockScanInfo->sttBlockDelIndex = index;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -4029,7 +4029,7 @@ int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockSc
|
||||||
tsdbRowMergerAdd(pMerger, pRow1, NULL);
|
tsdbRowMergerAdd(pMerger, pRow1, NULL);
|
||||||
} else {
|
} else {
|
||||||
tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid,
|
tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid,
|
||||||
pScanInfo->lastBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->lastKeyInStt,
|
pScanInfo->sttBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->lastKeyInStt,
|
||||||
idStr);
|
idStr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1387,7 +1387,7 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
|
||||||
pLastBlockReader->currentKey = key;
|
pLastBlockReader->currentKey = key;
|
||||||
pScanInfo->lastKeyInStt = key;
|
pScanInfo->lastKeyInStt = key;
|
||||||
|
|
||||||
if (!hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->lastBlockDelIndex, key, ver, pLastBlockReader->order,
|
if (!hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->sttBlockDelIndex, key, ver, pLastBlockReader->order,
|
||||||
pVerRange)) {
|
pVerRange)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2406,7 +2406,7 @@ int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order) {
|
||||||
|
|
||||||
int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t order, SCostSummary* pCost) {
|
int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t order, SCostSummary* pCost) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t newDelDataInFile = taosArrayGetSize(pBlockScanInfo->pfileDelData);
|
int32_t newDelDataInFile = taosArrayGetSize(pBlockScanInfo->pFileDelData);
|
||||||
if (newDelDataInFile == 0 &&
|
if (newDelDataInFile == 0 &&
|
||||||
((pBlockScanInfo->delSkyline != NULL) || (TARRAY_SIZE(pBlockScanInfo->pMemDelData) == 0))) {
|
((pBlockScanInfo->delSkyline != NULL) || (TARRAY_SIZE(pBlockScanInfo->pMemDelData) == 0))) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -2420,7 +2420,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t orde
|
||||||
pBlockScanInfo->delSkyline = taosArrayInit(4, sizeof(TSDBKEY));
|
pBlockScanInfo->delSkyline = taosArrayInit(4, sizeof(TSDBKEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pSource = pBlockScanInfo->pfileDelData;
|
SArray* pSource = pBlockScanInfo->pFileDelData;
|
||||||
if (pSource == NULL) {
|
if (pSource == NULL) {
|
||||||
pSource = pBlockScanInfo->pMemDelData;
|
pSource = pBlockScanInfo->pMemDelData;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2429,13 +2429,13 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t orde
|
||||||
|
|
||||||
code = tsdbBuildDeleteSkyline(pSource, 0, taosArrayGetSize(pSource) - 1, pBlockScanInfo->delSkyline);
|
code = tsdbBuildDeleteSkyline(pSource, 0, taosArrayGetSize(pSource) - 1, pBlockScanInfo->delSkyline);
|
||||||
|
|
||||||
taosArrayClear(pBlockScanInfo->pfileDelData);
|
taosArrayClear(pBlockScanInfo->pFileDelData);
|
||||||
int32_t index = getInitialDelIndex(pBlockScanInfo->delSkyline, order);
|
int32_t index = getInitialDelIndex(pBlockScanInfo->delSkyline, order);
|
||||||
|
|
||||||
pBlockScanInfo->iter.index = index;
|
pBlockScanInfo->iter.index = index;
|
||||||
pBlockScanInfo->iiter.index = index;
|
pBlockScanInfo->iiter.index = index;
|
||||||
pBlockScanInfo->fileDelIndex = index;
|
pBlockScanInfo->fileDelIndex = index;
|
||||||
pBlockScanInfo->lastBlockDelIndex = index;
|
pBlockScanInfo->sttBlockDelIndex = index;
|
||||||
|
|
||||||
double el = taosGetTimestampUs() - st;
|
double el = taosGetTimestampUs() - st;
|
||||||
pCost->createSkylineIterTime = el / 1000.0;
|
pCost->createSkylineIterTime = el / 1000.0;
|
||||||
|
@ -3409,7 +3409,7 @@ int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockSc
|
||||||
tsdbRowMergerAdd(pMerger, pRow1, NULL);
|
tsdbRowMergerAdd(pMerger, pRow1, NULL);
|
||||||
} else {
|
} else {
|
||||||
tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid,
|
tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid,
|
||||||
pScanInfo->lastBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->lastKeyInStt,
|
pScanInfo->sttBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->lastKeyInStt,
|
||||||
idStr);
|
idStr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4133,7 +4133,7 @@ int32_t tsdbReaderSuspend2(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline);
|
pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline);
|
||||||
pInfo->pfileDelData = taosArrayDestroy(pInfo->pfileDelData);
|
pInfo->pFileDelData = taosArrayDestroy(pInfo->pFileDelData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// resetDataBlockScanInfo excluding lastKey
|
// resetDataBlockScanInfo excluding lastKey
|
||||||
|
|
|
@ -221,7 +221,7 @@ void clearBlockScanInfo(STableBlockScanInfo* p) {
|
||||||
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||||
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
||||||
p->pMemDelData = taosArrayDestroy(p->pMemDelData);
|
p->pMemDelData = taosArrayDestroy(p->pMemDelData);
|
||||||
p->pfileDelData = taosArrayDestroy(p->pfileDelData);
|
p->pFileDelData = taosArrayDestroy(p->pFileDelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyAllBlockScanInfo(SSHashObj* pTableMap) {
|
void destroyAllBlockScanInfo(SSHashObj* pTableMap) {
|
||||||
|
@ -238,7 +238,7 @@ void destroyAllBlockScanInfo(SSHashObj* pTableMap) {
|
||||||
static void doCleanupInfoForNextFileset(STableBlockScanInfo* pScanInfo) {
|
static void doCleanupInfoForNextFileset(STableBlockScanInfo* pScanInfo) {
|
||||||
// reset the index in last block when handing a new file
|
// reset the index in last block when handing a new file
|
||||||
taosArrayClear(pScanInfo->pBlockList);
|
taosArrayClear(pScanInfo->pBlockList);
|
||||||
taosArrayClear(pScanInfo->pfileDelData); // del data from each file set
|
taosArrayClear(pScanInfo->pFileDelData); // del data from each file set
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanupInfoFoxNextFileset(SSHashObj* pTableMap) {
|
void cleanupInfoFoxNextFileset(SSHashObj* pTableMap) {
|
||||||
|
@ -502,14 +502,14 @@ static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_
|
||||||
|
|
||||||
if (newTable) {
|
if (newTable) {
|
||||||
(*pScanInfo) = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr);
|
(*pScanInfo) = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr);
|
||||||
if ((*pScanInfo)->pfileDelData == NULL) {
|
if ((*pScanInfo)->pFileDelData == NULL) {
|
||||||
(*pScanInfo)->pfileDelData = taosArrayInit(4, sizeof(SDelData));
|
(*pScanInfo)->pFileDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.version <= pReader->info.verRange.maxVer) {
|
if (record.version <= pReader->info.verRange.maxVer) {
|
||||||
SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey};
|
SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey};
|
||||||
taosArrayPush((*pScanInfo)->pfileDelData, &delData);
|
taosArrayPush((*pScanInfo)->pFileDelData, &delData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,8 +556,8 @@ static int32_t doLoadTombDataFromTombBlk(const TTombBlkArray* pTombBlkArray, STs
|
||||||
uint64_t uid = pReader->status.uidList.tableUidList[j];
|
uint64_t uid = pReader->status.uidList.tableUidList[j];
|
||||||
|
|
||||||
STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr);
|
STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr);
|
||||||
if (pScanInfo->pfileDelData == NULL) {
|
if (pScanInfo->pFileDelData == NULL) {
|
||||||
pScanInfo->pfileDelData = taosArrayInit(4, sizeof(SDelData));
|
pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
}
|
}
|
||||||
|
|
||||||
ETombBlkCheckEnum ret = 0;
|
ETombBlkCheckEnum ret = 0;
|
||||||
|
|
|
@ -65,12 +65,12 @@ typedef struct STableBlockScanInfo {
|
||||||
TSKEY lastKeyInStt; // last accessed key in stt
|
TSKEY lastKeyInStt; // last accessed key in stt
|
||||||
SArray* pBlockList; // block data index list, SArray<SBrinRecord>
|
SArray* pBlockList; // block data index list, SArray<SBrinRecord>
|
||||||
SArray* pMemDelData; // SArray<SDelData>
|
SArray* pMemDelData; // SArray<SDelData>
|
||||||
SArray* pfileDelData; // SArray<SDelData> from each file set
|
SArray* pFileDelData; // SArray<SDelData> from each file set
|
||||||
SIterInfo iter; // mem buffer skip list iterator
|
SIterInfo iter; // mem buffer skip list iterator
|
||||||
SIterInfo iiter; // imem buffer skip list iterator
|
SIterInfo iiter; // imem buffer skip list iterator
|
||||||
SArray* delSkyline; // delete info for this table
|
SArray* delSkyline; // delete info for this table
|
||||||
int32_t fileDelIndex; // file block delete index
|
int32_t fileDelIndex; // file block delete index
|
||||||
int32_t lastBlockDelIndex; // delete index for last block
|
int32_t sttBlockDelIndex; // delete index for last block
|
||||||
bool iterInit; // whether to initialize the in-memory skip list iterator or not
|
bool iterInit; // whether to initialize the in-memory skip list iterator or not
|
||||||
} STableBlockScanInfo;
|
} STableBlockScanInfo;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue