more code
This commit is contained in:
parent
2f5f0b75df
commit
0c9b66b574
|
@ -65,16 +65,14 @@ int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record);
|
|||
int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2);
|
||||
|
||||
// STbStatisBlock ----------
|
||||
#define STATIS_RECORD_NUM_ELEM 9
|
||||
#define STATIS_RECORD_NUM_ELEM 7
|
||||
typedef union {
|
||||
int64_t dataArr[STATIS_RECORD_NUM_ELEM];
|
||||
struct {
|
||||
int64_t suid;
|
||||
int64_t uid;
|
||||
int64_t firstKey;
|
||||
int64_t firstKeyVer;
|
||||
int64_t lastKey;
|
||||
int64_t lastKeyVer;
|
||||
int64_t minVer;
|
||||
int64_t maxVer;
|
||||
int64_t count;
|
||||
|
@ -87,9 +85,7 @@ typedef union {
|
|||
TARRAY2(int64_t) suid[1];
|
||||
TARRAY2(int64_t) uid[1];
|
||||
TARRAY2(int64_t) firstKey[1];
|
||||
TARRAY2(int64_t) firstKeyVer[1];
|
||||
TARRAY2(int64_t) lastKey[1];
|
||||
TARRAY2(int64_t) lastKeyVer[1];
|
||||
TARRAY2(int64_t) minVer[1];
|
||||
TARRAY2(int64_t) maxVer[1];
|
||||
TARRAY2(int64_t) count[1];
|
||||
|
@ -109,9 +105,9 @@ typedef struct SStatisBlk {
|
|||
#define STATIS_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid)
|
||||
|
||||
int32_t tStatisBlockInit(STbStatisBlock *statisBlock);
|
||||
int32_t tStatisBlockFree(STbStatisBlock *statisBlock);
|
||||
int32_t tStatisBlockDestroy(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
|
||||
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb);
|
||||
|
|
|
@ -390,7 +390,7 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
|
|||
}
|
||||
|
||||
tTombBlockDestroy(writer->tData);
|
||||
tStatisBlockFree(writer->sData);
|
||||
tStatisBlockDestroy(writer->sData);
|
||||
tBlockDataDestroy(writer->bData);
|
||||
TARRAY2_DESTROY(writer->tombBlkArray, NULL);
|
||||
TARRAY2_DESTROY(writer->dataBlkArray, NULL);
|
||||
|
|
|
@ -626,7 +626,7 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
|
|||
tDestroyTSchema(writer->skmRow->pTSchema);
|
||||
tDestroyTSchema(writer->skmTb->pTSchema);
|
||||
tTombBlockDestroy(writer->tData);
|
||||
tStatisBlockFree(writer->sData);
|
||||
tStatisBlockDestroy(writer->sData);
|
||||
tBlockDataDestroy(writer->bData);
|
||||
TARRAY2_DESTROY(writer->tombBlkArray, NULL);
|
||||
TARRAY2_DESTROY(writer->statisBlkArray, NULL);
|
||||
|
@ -774,9 +774,7 @@ int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row) {
|
|||
.suid = row->suid,
|
||||
.uid = row->uid,
|
||||
.firstKey = key->ts,
|
||||
.firstKeyVer = key->version,
|
||||
.lastKey = key->ts,
|
||||
.lastKeyVer = key->version,
|
||||
.minVer = key->version,
|
||||
.maxVer = key->version,
|
||||
.count = 1,
|
||||
|
@ -789,9 +787,7 @@ int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row) {
|
|||
if (key->ts > TARRAY2_LAST(writer->sData->lastKey)) {
|
||||
TARRAY2_LAST(writer->sData->count)++;
|
||||
TARRAY2_LAST(writer->sData->lastKey) = key->ts;
|
||||
TARRAY2_LAST(writer->sData->lastKeyVer) = key->version;
|
||||
} else if (key->ts == TARRAY2_LAST(writer->sData->lastKey)) {
|
||||
TARRAY2_LAST(writer->sData->lastKeyVer) = key->version;
|
||||
} else {
|
||||
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->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);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
} else {
|
||||
|
|
|
@ -38,8 +38,9 @@ int32_t tTombBlockClear(STombBlock *tombBlock) {
|
|||
}
|
||||
|
||||
int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) {
|
||||
int32_t code;
|
||||
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;
|
||||
}
|
||||
return 0;
|
||||
|
@ -57,29 +58,30 @@ int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) {
|
|||
|
||||
// STbStatisBlock ----------
|
||||
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]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tStatisBlockFree(STbStatisBlock *statisBlock) {
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) {
|
||||
int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock) {
|
||||
for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
|
||||
TARRAY2_DESTROY(&statisBlock->dataArr[i], NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *statisRecord) {
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) {
|
||||
int32_t code = TARRAY2_APPEND(&statisBlock->dataArr[i], statisRecord->dataArr[i]);
|
||||
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *record) {
|
||||
int32_t code;
|
||||
for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) {
|
||||
code = TARRAY2_APPEND(&statisBlock->dataArr[i], record->dataArr[i]);
|
||||
if (code) return code;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue