refact return code

This commit is contained in:
Hongze Cheng 2024-07-27 18:46:30 +08:00
parent 3727739721
commit 51e7ffa6c3
11 changed files with 57 additions and 67 deletions

View File

@ -27,9 +27,9 @@ typedef struct SBufferReader SBufferReader;
// SBuffer // SBuffer
#define BUFFER_INITIALIZER ((SBuffer){0, 0, NULL}) #define BUFFER_INITIALIZER ((SBuffer){0, 0, NULL})
static int32_t tBufferInit(SBuffer *buffer); static void tBufferInit(SBuffer *buffer);
static int32_t tBufferDestroy(SBuffer *buffer); static void tBufferDestroy(SBuffer *buffer);
static int32_t tBufferClear(SBuffer *buffer); static void tBufferClear(SBuffer *buffer);
static int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity); static int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity);
static int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size); static int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size);
static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size); static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size);

View File

@ -29,27 +29,22 @@ struct SBufferReader {
}; };
// SBuffer // SBuffer
static FORCE_INLINE int32_t tBufferInit(SBuffer *buffer) { static FORCE_INLINE void tBufferInit(SBuffer *buffer) {
buffer->size = 0; buffer->size = 0;
buffer->capacity = 0; buffer->capacity = 0;
buffer->data = NULL; buffer->data = NULL;
return 0;
} }
static FORCE_INLINE int32_t tBufferDestroy(SBuffer *buffer) { static FORCE_INLINE void tBufferDestroy(SBuffer *buffer) {
buffer->size = 0; buffer->size = 0;
buffer->capacity = 0; buffer->capacity = 0;
if (buffer->data) { if (buffer->data) {
taosMemoryFree(buffer->data); taosMemoryFree(buffer->data);
buffer->data = NULL; buffer->data = NULL;
} }
return 0;
} }
static FORCE_INLINE int32_t tBufferClear(SBuffer *buffer) { static FORCE_INLINE void tBufferClear(SBuffer *buffer) { buffer->size = 0; }
buffer->size = 0;
return 0;
}
static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity) { static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity) {
if (buffer->capacity < capacity) { if (buffer->capacity < capacity) {

View File

@ -2419,7 +2419,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie
if (!state->pBrinBlock) { if (!state->pBrinBlock) {
state->pBrinBlock = &state->brinBlock; state->pBrinBlock = &state->brinBlock;
} else { } else {
tBrinBlockClear(&state->brinBlock); (void)tBrinBlockClear(&state->brinBlock);
} }
TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlock(state->pr->pFileReader, pBrinBlk, &state->brinBlock), &lino, _err); TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlock(state->pr->pFileReader, pBrinBlk, &state->brinBlock), &lino, _err);
@ -2431,7 +2431,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie
if (SFSNEXTROW_BRINBLOCK == state->state) { if (SFSNEXTROW_BRINBLOCK == state->state) {
_next_brinrecord: _next_brinrecord:
if (state->iBrinRecord < 0) { // empty brin block, goto _next_brinindex if (state->iBrinRecord < 0) { // empty brin block, goto _next_brinindex
tBrinBlockClear(&state->brinBlock); (void)tBrinBlockClear(&state->brinBlock);
goto _next_brinindex; goto _next_brinindex;
} }
@ -2691,7 +2691,7 @@ int32_t clearNextRowFromFS(void *iter) {
} }
if (state->pBrinBlock) { if (state->pBrinBlock) {
tBrinBlockDestroy(state->pBrinBlock); (void)tBrinBlockDestroy(state->pBrinBlock);
state->pBrinBlock = NULL; state->pBrinBlock = NULL;
} }

View File

@ -230,7 +230,7 @@ int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinB
// decode brin block // decode brin block
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer); SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer);
tBrinBlockClear(brinBlock); (void)tBrinBlockClear(brinBlock);
brinBlock->numOfPKs = brinBlk->numOfPKs; brinBlock->numOfPKs = brinBlk->numOfPKs;
brinBlock->numOfRecords = brinBlk->numRec; brinBlock->numOfRecords = brinBlk->numRec;
for (int32_t i = 0; i < 10; i++) { // int64_t for (int32_t i = 0; i < 10; i++) { // int64_t
@ -673,12 +673,12 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
tTombBlockDestroy(writer->tombBlock); tTombBlockDestroy(writer->tombBlock);
TARRAY2_DESTROY(writer->tombBlkArray, NULL); TARRAY2_DESTROY(writer->tombBlkArray, NULL);
tBlockDataDestroy(writer->blockData); tBlockDataDestroy(writer->blockData);
tBrinBlockDestroy(writer->brinBlock); (void)tBrinBlockDestroy(writer->brinBlock);
TARRAY2_DESTROY(writer->brinBlkArray, NULL); TARRAY2_DESTROY(writer->brinBlkArray, NULL);
tTombBlockDestroy(writer->ctx->tombBlock); tTombBlockDestroy(writer->ctx->tombBlock);
tBlockDataDestroy(writer->ctx->blockData); tBlockDataDestroy(writer->ctx->blockData);
tBrinBlockDestroy(writer->ctx->brinBlock); (void)tBrinBlockDestroy(writer->ctx->brinBlock);
for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) {
tBufferDestroy(writer->local + i); tBufferDestroy(writer->local + i);
@ -838,7 +838,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
for (int i = 0; i < brinBlock->numOfRecords; i++) { for (int i = 0; i < brinBlock->numOfRecords; i++) {
SBrinRecord record; SBrinRecord record;
tBrinBlockGet(brinBlock, i, &record); (void)tBrinBlockGet(brinBlock, i, &record);
if (i == 0) { if (i == 0) {
brinBlk.minTbid.suid = record.suid; brinBlk.minTbid.suid = record.suid;
brinBlk.minTbid.uid = record.uid; brinBlk.minTbid.uid = record.uid;
@ -918,7 +918,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
// append to brinBlkArray // append to brinBlkArray
TAOS_CHECK_RETURN(TARRAY2_APPEND_PTR(brinBlkArray, &brinBlk)); TAOS_CHECK_RETURN(TARRAY2_APPEND_PTR(brinBlkArray, &brinBlk));
tBrinBlockClear(brinBlock); (void)tBrinBlockClear(brinBlock);
return 0; return 0;
} }
@ -1147,7 +1147,7 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST
for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) { for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) {
SBrinRecord record; SBrinRecord record;
tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record);
if (record.uid != writer->ctx->tbid->uid) { if (record.uid != writer->ctx->tbid->uid) {
writer->ctx->tbHasOldData = false; writer->ctx->tbHasOldData = false;
goto _exit; goto _exit;
@ -1157,7 +1157,7 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST
goto _exit; goto _exit;
} else { } else {
SBrinRecord record[1]; SBrinRecord record[1];
tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record);
if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey
if (writer->blockData->nRow > 0) { if (writer->blockData->nRow > 0) {
TAOS_CHECK_GOTO(tsdbDataFileDoWriteBlockData(writer, writer->blockData), &lino, _exit); TAOS_CHECK_GOTO(tsdbDataFileDoWriteBlockData(writer, writer->blockData), &lino, _exit);
@ -1351,7 +1351,7 @@ int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAl
}; };
for (int i = 0; i < TOMB_BLOCK_SIZE(tombBlock); i++) { for (int i = 0; i < TOMB_BLOCK_SIZE(tombBlock); i++) {
STombRecord record; STombRecord record;
tTombBlockGet(tombBlock, i, &record); TAOS_UNUSED(tTombBlockGet(tombBlock, i, &record));
if (i == 0) { if (i == 0) {
tombBlk.minTbid.suid = record.suid; tombBlk.minTbid.suid = record.suid;
@ -1506,7 +1506,7 @@ static int32_t tsdbDataFileDoWriteTombRecord(SDataFileWriter *writer, const STom
while (writer->ctx->hasOldTomb) { while (writer->ctx->hasOldTomb) {
for (; writer->ctx->tombBlockIdx < TOMB_BLOCK_SIZE(writer->ctx->tombBlock); writer->ctx->tombBlockIdx++) { for (; writer->ctx->tombBlockIdx < TOMB_BLOCK_SIZE(writer->ctx->tombBlock); writer->ctx->tombBlockIdx++) {
STombRecord record1[1]; STombRecord record1[1];
tTombBlockGet(writer->ctx->tombBlock, writer->ctx->tombBlockIdx, record1); TAOS_UNUSED(tTombBlockGet(writer->ctx->tombBlock, writer->ctx->tombBlockIdx, record1));
int32_t c = tTombRecordCompare(record, record1); int32_t c = tTombRecordCompare(record, record1);
if (c < 0) { if (c < 0) {

View File

@ -153,7 +153,7 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) {
for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) { for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) {
SBrinRecord record[1]; SBrinRecord record[1];
tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); (void)tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record);
if (iter->filterByVersion && (record->maxVer < iter->range[0] || record->minVer > iter->range[1])) { if (iter->filterByVersion && (record->maxVer < iter->range[0] || record->minVer > iter->range[1])) {
continue; continue;
@ -254,7 +254,8 @@ _exit:
static int32_t tsdbDataTombIterNext(STsdbIter *iter, const TABLEID *tbid) { static int32_t tsdbDataTombIterNext(STsdbIter *iter, const TABLEID *tbid) {
while (!iter->noMoreData) { while (!iter->noMoreData) {
for (; iter->dataTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->dataTomb->tombBlock); iter->dataTomb->tombBlockIdx++) { for (; iter->dataTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->dataTomb->tombBlock); iter->dataTomb->tombBlockIdx++) {
tTombBlockGet(iter->dataTomb->tombBlock, iter->dataTomb->tombBlockIdx, iter->record); int32_t code = tTombBlockGet(iter->dataTomb->tombBlock, iter->dataTomb->tombBlockIdx, iter->record);
if (code) return code;
if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) {
continue; continue;
@ -372,7 +373,7 @@ static int32_t tsdbDataIterOpen(STsdbIter *iter) {
iter->dataData->brinBlkArrayIdx = 0; iter->dataData->brinBlkArrayIdx = 0;
// SBrinBlock // SBrinBlock
tBrinBlockInit(iter->dataData->brinBlock); (void)tBrinBlockInit(iter->dataData->brinBlock);
iter->dataData->brinBlockIdx = 0; iter->dataData->brinBlockIdx = 0;
// SBlockData // SBlockData
@ -429,7 +430,7 @@ static int32_t tsdbMemTombIterOpen(STsdbIter *iter) {
} }
static int32_t tsdbDataIterClose(STsdbIter *iter) { static int32_t tsdbDataIterClose(STsdbIter *iter) {
tBrinBlockDestroy(iter->dataData->brinBlock); (void)tBrinBlockDestroy(iter->dataData->brinBlock);
tBlockDataDestroy(iter->dataData->blockData); tBlockDataDestroy(iter->dataData->blockData);
return 0; return 0;
} }
@ -439,7 +440,8 @@ static int32_t tsdbMemTableIterClose(STsdbIter *iter) { return 0; }
static int32_t tsdbSttTombIterNext(STsdbIter *iter, const TABLEID *tbid) { static int32_t tsdbSttTombIterNext(STsdbIter *iter, const TABLEID *tbid) {
while (!iter->noMoreData) { while (!iter->noMoreData) {
for (; iter->sttTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->sttTomb->tombBlock); iter->sttTomb->tombBlockIdx++) { for (; iter->sttTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->sttTomb->tombBlock); iter->sttTomb->tombBlockIdx++) {
tTombBlockGet(iter->sttTomb->tombBlock, iter->sttTomb->tombBlockIdx, iter->record); int32_t code = tTombBlockGet(iter->sttTomb->tombBlock, iter->sttTomb->tombBlockIdx, iter->record);
if (code) return code;
if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) {
continue; continue;

View File

@ -63,8 +63,8 @@ int32_t tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t num
return code; return code;
} }
static void freeItem(void* pValue) { static void freeItem(void *pValue) {
SValue* p = (SValue*) pValue; SValue *p = (SValue *)pValue;
if (IS_VAR_DATA_TYPE(p->type)) { if (IS_VAR_DATA_TYPE(p->type)) {
taosMemoryFree(p->pData); taosMemoryFree(p->pData);
} }
@ -120,7 +120,7 @@ void destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoad
continue; continue;
} }
SSttBlockLoadCostInfo* pCost = &pIter->pBlockLoadInfo->cost; SSttBlockLoadCostInfo *pCost = &pIter->pBlockLoadInfo->cost;
if (pLoadCost != NULL) { if (pLoadCost != NULL) {
pLoadCost->loadBlocks += pCost->loadBlocks; pLoadCost->loadBlocks += pCost->loadBlocks;
pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks; pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks;
@ -380,7 +380,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
pBlockLoadInfo->cost.loadStatisBlocks += num; pBlockLoadInfo->cost.loadStatisBlocks += num;
STbStatisBlock block; STbStatisBlock block;
tStatisBlockInit(&block); TAOS_UNUSED(tStatisBlockInit(&block));
int64_t st = taosGetTimestampUs(); int64_t st = taosGetTimestampUs();
@ -436,7 +436,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
} }
} else { } else {
SValue vFirst = {0}; SValue vFirst = {0};
for(int32_t j = 0; j < size; ++j) { for (int32_t j = 0; j < size; ++j) {
taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst); taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst);
} }
@ -445,7 +445,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
STbStatisRecord record = {0}; STbStatisRecord record = {0};
while (i < rows) { while (i < rows) {
tStatisBlockGet(&block, i, &record); (void)tStatisBlockGet(&block, i, &record);
if (record.suid != suid) { if (record.suid != suid) {
break; break;
} }
@ -476,7 +476,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
} }
} }
tStatisBlockDestroy(&block); (void)tStatisBlockDestroy(&block);
double el = (taosGetTimestampUs() - st) / 1000.0; double el = (taosGetTimestampUs() - st) / 1000.0;
pBlockLoadInfo->cost.statisElapsedTime += el; pBlockLoadInfo->cost.statisElapsedTime += el;
@ -712,7 +712,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
} }
int64_t ts = pData->aTSKEY[i]; int64_t ts = pData->aTSKEY[i];
if (!pIter->backward) { // asc if (!pIter->backward) { // asc
if (ts > pIter->timeWindow.ekey) { // no more data if (ts > pIter->timeWindow.ekey) { // no more data
break; break;
} else { } else {

View File

@ -1022,7 +1022,8 @@ static int32_t tsdbSnapWriteTombData(STsdbSnapWriter* writer, SSnapDataHdr* hdr)
code = tsdbSnapWriteDecmprTombBlock(hdr, tombBlock); code = tsdbSnapWriteDecmprTombBlock(hdr, tombBlock);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
tTombBlockGet(tombBlock, 0, &record); code = tTombBlockGet(tombBlock, 0, &record);
TSDB_CHECK_CODE(code, lino, _exit);
int32_t fid = tsdbKeyFid(record.skey, writer->minutes, writer->precision); int32_t fid = tsdbKeyFid(record.skey, writer->minutes, writer->precision);
if (!writer->ctx->fsetWriteBegin || fid != writer->ctx->fid) { if (!writer->ctx->fsetWriteBegin || fid != writer->ctx->fid) {
code = tsdbSnapWriteFileSetEnd(writer); code = tsdbSnapWriteFileSetEnd(writer);
@ -1045,7 +1046,8 @@ static int32_t tsdbSnapWriteTombData(STsdbSnapWriter* writer, SSnapDataHdr* hdr)
ASSERT(writer->ctx->hasData == false); ASSERT(writer->ctx->hasData == false);
for (int32_t i = 0; i < TOMB_BLOCK_SIZE(tombBlock); ++i) { for (int32_t i = 0; i < TOMB_BLOCK_SIZE(tombBlock); ++i) {
tTombBlockGet(tombBlock, i, &record); code = tTombBlockGet(tombBlock, i, &record);
TSDB_CHECK_CODE(code, lino, _exit);
code = tsdbSnapWriteTombRecord(writer, &record); code = tsdbSnapWriteTombRecord(writer, &record);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);

View File

@ -401,7 +401,7 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta
&lino, _exit); &lino, _exit);
// decode data // decode data
tStatisBlockClear(statisBlock); TAOS_UNUSED(tStatisBlockClear(statisBlock));
statisBlock->numOfPKs = statisBlk->numOfPKs; statisBlock->numOfPKs = statisBlk->numOfPKs;
statisBlock->numOfRecords = statisBlk->numRec; statisBlock->numOfRecords = statisBlk->numRec;
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
@ -574,11 +574,11 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
statisBlk.cmprAlg = writer->config->cmprAlg; statisBlk.cmprAlg = writer->config->cmprAlg;
statisBlk.numOfPKs = statisBlock->numOfPKs; statisBlk.numOfPKs = statisBlock->numOfPKs;
tStatisBlockGet(statisBlock, 0, &record); (void)tStatisBlockGet(statisBlock, 0, &record);
statisBlk.minTbid.suid = record.suid; statisBlk.minTbid.suid = record.suid;
statisBlk.minTbid.uid = record.uid; statisBlk.minTbid.uid = record.uid;
tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); (void)tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record);
statisBlk.maxTbid.suid = record.suid; statisBlk.maxTbid.suid = record.suid;
statisBlk.maxTbid.uid = record.uid; statisBlk.maxTbid.uid = record.uid;
@ -636,7 +636,7 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
TAOS_CHECK_GOTO(TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk), &lino, _exit); TAOS_CHECK_GOTO(TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk), &lino, _exit);
tStatisBlockClear(writer->staticBlock); TAOS_UNUSED(tStatisBlockClear(writer->staticBlock));
_exit: _exit:
if (code) { if (code) {
@ -822,7 +822,7 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
tDestroyTSchema(writer->skmRow->pTSchema); tDestroyTSchema(writer->skmRow->pTSchema);
tDestroyTSchema(writer->skmTb->pTSchema); tDestroyTSchema(writer->skmTb->pTSchema);
tTombBlockDestroy(writer->tombBlock); tTombBlockDestroy(writer->tombBlock);
tStatisBlockDestroy(writer->staticBlock); (void)tStatisBlockDestroy(writer->staticBlock);
tBlockDataDestroy(writer->blockData); tBlockDataDestroy(writer->blockData);
TARRAY2_DESTROY(writer->tombBlkArray, NULL); TARRAY2_DESTROY(writer->tombBlkArray, NULL);
TARRAY2_DESTROY(writer->statisBlkArray, NULL); TARRAY2_DESTROY(writer->statisBlkArray, NULL);

View File

@ -167,7 +167,7 @@ _exit:
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
} }
TARRAY2_DESTROY(ctx->brinBlkArray, NULL); TARRAY2_DESTROY(ctx->brinBlkArray, NULL);
tBrinBlockDestroy(ctx->brinBlock); (void)tBrinBlockDestroy(ctx->brinBlock);
tBlockDataDestroy(ctx->blockData); tBlockDataDestroy(ctx->blockData);
tMapDataClear(ctx->mDataBlk); tMapDataClear(ctx->mDataBlk);
taosArrayDestroy(ctx->aBlockIdx); taosArrayDestroy(ctx->aBlockIdx);

View File

@ -16,35 +16,26 @@
#include "tsdbUtil2.h" #include "tsdbUtil2.h"
// SDelBlock ---------- // SDelBlock ----------
int32_t tTombBlockInit(STombBlock *tombBlock) { void tTombBlockInit(STombBlock *tombBlock) {
int32_t code;
tombBlock->numOfRecords = 0; tombBlock->numOfRecords = 0;
for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
TAOS_CHECK_GOTO(tBufferInit(&tombBlock->buffers[i]), NULL, _exit); tBufferInit(&tombBlock->buffers[i]);
} }
return;
_exit:
if (code) {
TAOS_UNUSED(tTombBlockDestroy(tombBlock));
}
return code;
} }
int32_t tTombBlockDestroy(STombBlock *tombBlock) { void tTombBlockDestroy(STombBlock *tombBlock) {
tombBlock->numOfRecords = 0; tombBlock->numOfRecords = 0;
for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
TAOS_UNUSED(tBufferDestroy(&tombBlock->buffers[i])); tBufferDestroy(&tombBlock->buffers[i]);
} }
return 0;
} }
int32_t tTombBlockClear(STombBlock *tombBlock) { void tTombBlockClear(STombBlock *tombBlock) {
tombBlock->numOfRecords = 0; tombBlock->numOfRecords = 0;
for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
TAOS_UNUSED(tBufferClear(&tombBlock->buffers[i])); tBufferClear(&tombBlock->buffers[i]);
} }
return 0;
} }
int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) { int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) {
@ -79,12 +70,12 @@ int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) {
// STbStatisBlock ---------- // STbStatisBlock ----------
int32_t tStatisBlockInit(STbStatisBlock *statisBlock) { int32_t tStatisBlockInit(STbStatisBlock *statisBlock) {
int32_t code; int32_t code = 0;
statisBlock->numOfPKs = 0; statisBlock->numOfPKs = 0;
statisBlock->numOfRecords = 0; statisBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
TAOS_CHECK_GOTO(tBufferInit(&statisBlock->buffers[i]), NULL, _exit); tBufferInit(&statisBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
TAOS_CHECK_GOTO(tValueColumnInit(&statisBlock->firstKeyPKs[i]), NULL, _exit); TAOS_CHECK_GOTO(tValueColumnInit(&statisBlock->firstKeyPKs[i]), NULL, _exit);
@ -244,7 +235,7 @@ int32_t tBrinBlockInit(SBrinBlock *brinBlock) {
brinBlock->numOfPKs = 0; brinBlock->numOfPKs = 0;
brinBlock->numOfRecords = 0; brinBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
TAOS_CHECK_GOTO(tBufferInit(&brinBlock->buffers[i]), NULL, _exit); tBufferInit(&brinBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
TAOS_CHECK_GOTO(tValueColumnInit(&brinBlock->firstKeyPKs[i]), NULL, _exit); TAOS_CHECK_GOTO(tValueColumnInit(&brinBlock->firstKeyPKs[i]), NULL, _exit);
@ -253,7 +244,7 @@ int32_t tBrinBlockInit(SBrinBlock *brinBlock) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tBrinBlockDestroy(brinBlock)); (void)tBrinBlockDestroy(brinBlock);
} }
return code; return code;
} }

View File

@ -65,9 +65,9 @@ typedef TARRAY2(STombBlk) TTombBlkArray;
#define TOMB_BLOCK_SIZE(db) ((db)->numOfRecords) #define TOMB_BLOCK_SIZE(db) ((db)->numOfRecords)
int32_t tTombBlockInit(STombBlock *tombBlock); void tTombBlockInit(STombBlock *tombBlock);
int32_t tTombBlockDestroy(STombBlock *tombBlock); void tTombBlockDestroy(STombBlock *tombBlock);
int32_t tTombBlockClear(STombBlock *tombBlock); void tTombBlockClear(STombBlock *tombBlock);
int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record); int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record);
int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record); int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record);
int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2); int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2);