more code

This commit is contained in:
Hongze Cheng 2024-02-29 17:06:53 +08:00
parent b8754b4209
commit 2de7f87c74
4 changed files with 16 additions and 7 deletions

View File

@ -124,7 +124,7 @@ int32_t tRowSort(SArray *aRowP);
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag); int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag); int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
void tRowGetKey(SRow *pRow, SRowKey *key); void tRowGetKey(SRow *pRow, SRowKey *key);
int32_t tRowKeyCmpr(const void *p1, const void *p2); int32_t tRowKeyCompare(const void *p1, const void *p2);
// SRowIter ================================ // SRowIter ================================
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter); int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);

View File

@ -1243,7 +1243,10 @@ int32_t tValueCompare(const SValue *tv1, const SValue *tv2) {
return 0; return 0;
} }
int32_t tRowKeyCmpr(const void *p1, const void *p2) { // NOTE:
// set key->numOfPKs to 0 as the smallest key with ts
// set key->numOfPKs to (TD_MAX_PK_COLS + 1) as the largest key with ts
int32_t tRowKeyCompare(const void *p1, const void *p2) {
SRowKey *key1 = (SRowKey *)p1; SRowKey *key1 = (SRowKey *)p1;
SRowKey *key2 = (SRowKey *)p2; SRowKey *key2 = (SRowKey *)p2;
@ -1253,9 +1256,15 @@ int32_t tRowKeyCmpr(const void *p1, const void *p2) {
return 1; return 1;
} }
for (uint8_t iKey = 0; iKey < key1->numOfPKs; iKey++) { if (key1->numOfPKs == key2->numOfPKs) {
int32_t ret = tValueCompare(&key1->pks[iKey], &key2->pks[iKey]); for (uint8_t iKey = 0; iKey < key1->numOfPKs; iKey++) {
if (ret) return ret; int32_t ret = tValueCompare(&key1->pks[iKey], &key2->pks[iKey]);
if (ret) return ret;
}
} else if (key1->numOfPKs < key2->numOfPKs) {
return -1;
} else {
return 1;
} }
return 0; return 0;

View File

@ -1033,7 +1033,7 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) {
tStatisBlockGet(writer->staticBlock, writer->staticBlock->numOfRecords, &record); tStatisBlockGet(writer->staticBlock, writer->staticBlock->numOfRecords, &record);
if (tRowKeyCmpr(&key.key, &record.lastKey) > 0) { if (tRowKeyCompare(&key.key, &record.lastKey) > 0) {
// TODO: update count and last key // TODO: update count and last key
// TARRAY2_LAST(writer->staticBlock->count)++; // TARRAY2_LAST(writer->staticBlock->count)++;
// TARRAY2_LAST(writer->staticBlock->lastKey) = key->ts; // TARRAY2_LAST(writer->staticBlock->lastKey) = key->ts;

View File

@ -625,7 +625,7 @@ void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key) {
} }
int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2) { int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2) {
int32_t c = tRowKeyCmpr(&key1->key, &key2->key); int32_t c = tRowKeyCompare(&key1->key, &key2->key);
if (c) { if (c) {
return c; return c;