more code

This commit is contained in:
Hongze Cheng 2023-06-08 10:51:43 +08:00
parent 2f5f0b75df
commit 0c9b66b574
4 changed files with 15 additions and 25 deletions

View File

@ -65,16 +65,14 @@ int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record);
int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2); int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2);
// STbStatisBlock ---------- // STbStatisBlock ----------
#define STATIS_RECORD_NUM_ELEM 9 #define STATIS_RECORD_NUM_ELEM 7
typedef union { typedef union {
int64_t dataArr[STATIS_RECORD_NUM_ELEM]; int64_t dataArr[STATIS_RECORD_NUM_ELEM];
struct { struct {
int64_t suid; int64_t suid;
int64_t uid; int64_t uid;
int64_t firstKey; int64_t firstKey;
int64_t firstKeyVer;
int64_t lastKey; int64_t lastKey;
int64_t lastKeyVer;
int64_t minVer; int64_t minVer;
int64_t maxVer; int64_t maxVer;
int64_t count; int64_t count;
@ -87,9 +85,7 @@ typedef union {
TARRAY2(int64_t) suid[1]; TARRAY2(int64_t) suid[1];
TARRAY2(int64_t) uid[1]; TARRAY2(int64_t) uid[1];
TARRAY2(int64_t) firstKey[1]; TARRAY2(int64_t) firstKey[1];
TARRAY2(int64_t) firstKeyVer[1];
TARRAY2(int64_t) lastKey[1]; TARRAY2(int64_t) lastKey[1];
TARRAY2(int64_t) lastKeyVer[1];
TARRAY2(int64_t) minVer[1]; TARRAY2(int64_t) minVer[1];
TARRAY2(int64_t) maxVer[1]; TARRAY2(int64_t) maxVer[1];
TARRAY2(int64_t) count[1]; TARRAY2(int64_t) count[1];
@ -109,9 +105,9 @@ typedef struct SStatisBlk {
#define STATIS_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid) #define STATIS_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid)
int32_t tStatisBlockInit(STbStatisBlock *statisBlock); int32_t tStatisBlockInit(STbStatisBlock *statisBlock);
int32_t tStatisBlockFree(STbStatisBlock *statisBlock); int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock);
int32_t tStatisBlockClear(STbStatisBlock *statisBlock); int32_t tStatisBlockClear(STbStatisBlock *statisBlock);
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *statisRecord); int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *record);
// other apis // other apis
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb); int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb);

View File

@ -390,7 +390,7 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
} }
tTombBlockDestroy(writer->tData); tTombBlockDestroy(writer->tData);
tStatisBlockFree(writer->sData); tStatisBlockDestroy(writer->sData);
tBlockDataDestroy(writer->bData); tBlockDataDestroy(writer->bData);
TARRAY2_DESTROY(writer->tombBlkArray, NULL); TARRAY2_DESTROY(writer->tombBlkArray, NULL);
TARRAY2_DESTROY(writer->dataBlkArray, NULL); TARRAY2_DESTROY(writer->dataBlkArray, NULL);

View File

@ -626,7 +626,7 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
tDestroyTSchema(writer->skmRow->pTSchema); tDestroyTSchema(writer->skmRow->pTSchema);
tDestroyTSchema(writer->skmTb->pTSchema); tDestroyTSchema(writer->skmTb->pTSchema);
tTombBlockDestroy(writer->tData); tTombBlockDestroy(writer->tData);
tStatisBlockFree(writer->sData); tStatisBlockDestroy(writer->sData);
tBlockDataDestroy(writer->bData); tBlockDataDestroy(writer->bData);
TARRAY2_DESTROY(writer->tombBlkArray, NULL); TARRAY2_DESTROY(writer->tombBlkArray, NULL);
TARRAY2_DESTROY(writer->statisBlkArray, NULL); TARRAY2_DESTROY(writer->statisBlkArray, NULL);
@ -774,9 +774,7 @@ int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row) {
.suid = row->suid, .suid = row->suid,
.uid = row->uid, .uid = row->uid,
.firstKey = key->ts, .firstKey = key->ts,
.firstKeyVer = key->version,
.lastKey = key->ts, .lastKey = key->ts,
.lastKeyVer = key->version,
.minVer = key->version, .minVer = key->version,
.maxVer = key->version, .maxVer = key->version,
.count = 1, .count = 1,
@ -789,9 +787,7 @@ int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row) {
if (key->ts > TARRAY2_LAST(writer->sData->lastKey)) { if (key->ts > TARRAY2_LAST(writer->sData->lastKey)) {
TARRAY2_LAST(writer->sData->count)++; TARRAY2_LAST(writer->sData->count)++;
TARRAY2_LAST(writer->sData->lastKey) = key->ts; TARRAY2_LAST(writer->sData->lastKey) = key->ts;
TARRAY2_LAST(writer->sData->lastKeyVer) = key->version;
} else if (key->ts == TARRAY2_LAST(writer->sData->lastKey)) { } else if (key->ts == TARRAY2_LAST(writer->sData->lastKey)) {
TARRAY2_LAST(writer->sData->lastKeyVer) = key->version;
} else { } else {
ASSERTS(0, "timestamp should be in ascending order"); ASSERTS(0, "timestamp should be in ascending order");
} }
@ -811,10 +807,6 @@ int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row) {
: writer->bData->aUid[writer->bData->nRow - 1]) == row->uid // : writer->bData->aUid[writer->bData->nRow - 1]) == row->uid //
&& writer->bData->aTSKEY[writer->bData->nRow - 1] == key->ts // && writer->bData->aTSKEY[writer->bData->nRow - 1] == key->ts //
) { ) {
if (writer->bData->nRow == 1) {
TARRAY2_LAST(writer->sData->firstKeyVer) = key->version;
}
code = tBlockDataUpdateRow(writer->bData, &row->row, writer->config->skmRow->pTSchema); code = tBlockDataUpdateRow(writer->bData, &row->row, writer->config->skmRow->pTSchema);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} else { } else {

View File

@ -38,8 +38,9 @@ int32_t tTombBlockClear(STombBlock *tombBlock) {
} }
int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) { int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) {
int32_t code;
for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
int32_t code = TARRAY2_APPEND(&tombBlock->dataArr[i], record->dataArr[i]); code = TARRAY2_APPEND(&tombBlock->dataArr[i], record->dataArr[i]);
if (code) return code; if (code) return code;
} }
return 0; return 0;
@ -57,29 +58,30 @@ int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) {
// STbStatisBlock ---------- // STbStatisBlock ----------
int32_t tStatisBlockInit(STbStatisBlock *statisBlock) { int32_t tStatisBlockInit(STbStatisBlock *statisBlock) {
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) { for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
TARRAY2_INIT(&statisBlock->dataArr[i]); TARRAY2_INIT(&statisBlock->dataArr[i]);
} }
return 0; return 0;
} }
int32_t tStatisBlockFree(STbStatisBlock *statisBlock) { int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock) {
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) { for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
TARRAY2_DESTROY(&statisBlock->dataArr[i], NULL); TARRAY2_DESTROY(&statisBlock->dataArr[i], NULL);
} }
return 0; return 0;
} }
int32_t tStatisBlockClear(STbStatisBlock *statisBlock) { int32_t tStatisBlockClear(STbStatisBlock *statisBlock) {
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) { for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
TARRAY2_CLEAR(&statisBlock->dataArr[i], NULL); TARRAY2_CLEAR(&statisBlock->dataArr[i], NULL);
} }
return 0; return 0;
} }
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *statisRecord) { int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *record) {
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) { int32_t code;
int32_t code = TARRAY2_APPEND(&statisBlock->dataArr[i], statisRecord->dataArr[i]); for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
code = TARRAY2_APPEND(&statisBlock->dataArr[i], record->dataArr[i]);
if (code) return code; if (code) return code;
} }
return 0; return 0;