more code change

This commit is contained in:
Hongze Cheng 2024-02-22 10:13:35 +08:00
parent 2ade750e4d
commit 665cc2c2c4
5 changed files with 20 additions and 19 deletions

View File

@ -205,8 +205,8 @@ struct SValue {
#define TD_MAX_PRIMARY_KEY_COL 8
struct SRowKey {
TSKEY ts;
uint8_t numOfKeys;
SValue keys[TD_MAX_PRIMARY_KEY_COL];
uint8_t numOfPKs;
SValue pks[TD_MAX_PRIMARY_KEY_COL];
};
struct SColVal {

View File

@ -1156,11 +1156,11 @@ int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, in
void tRowGetKey(SRow *pRow, SRowKey *key) {
key->ts = pRow->ts;
if ((pRow->flag & HAS_MULTI_KEY) == 0) {
key->numOfKeys = 0;
key->numOfPKs = 0;
} else {
uint8_t *pEnd = ((uint8_t *)pRow) + pRow->len;
pEnd -= tGetU8(pEnd, &key->numOfKeys, false);
pEnd -= tGetU8(pEnd, &key->numOfPKs, false);
if (pRow->flag >> 4) { // Key-Value format
SKVIdx *pKVIdx = (SKVIdx *)pRow->data;
@ -1174,10 +1174,10 @@ void tRowGetKey(SRow *pRow, SRowKey *key) {
pv = pKVIdx->idx + (pKVIdx->nCol << 2);
}
for (uint8_t iKey = 0; iKey < key->numOfKeys; iKey++) {
for (uint8_t iKey = 0; iKey < key->numOfPKs; iKey++) {
int32_t index;
uint8_t *pData;
SValue *pValue = &key->keys[iKey];
SValue *pValue = &key->pks[iKey];
pEnd -= tGetI8(pEnd, &pValue->type, false);
pEnd -= tGetI32v(pEnd, &index, false);
@ -1221,18 +1221,18 @@ void tRowGetKey(SRow *pRow, SRowKey *key) {
ASSERTS(0, "invalid row format");
}
for (uint8_t iKey = 0; iKey < key->numOfKeys; iKey++) {
for (uint8_t iKey = 0; iKey < key->numOfPKs; iKey++) {
int32_t offset;
SValue *pValue = &key->keys[iKey];
SValue *pValue = &key->pks[iKey];
pEnd -= tGetI8(pEnd, &pValue->type, false);
pEnd -= tGetI32v(pEnd, &offset, false);
if (IS_VAR_DATA_TYPE(key->keys[iKey].type)) {
if (IS_VAR_DATA_TYPE(key->pks[iKey].type)) {
pValue->pData = pv + *(int32_t *)(pf + offset);
pValue->pData += tGetU32v(pValue->pData, &pValue->nData, true);
} else {
memcpy(&key->keys[iKey].val, pf + offset, TYPE_BYTES[key->keys[iKey].type]);
memcpy(&key->pks[iKey].val, pf + offset, TYPE_BYTES[key->pks[iKey].type]);
}
}
}
@ -1309,8 +1309,8 @@ int32_t tRowKeyCmpr(const void *p1, const void *p2) {
return 1;
}
for (uint8_t iKey = 0; iKey < key1->numOfKeys; iKey++) {
int32_t ret = tValueCompare(&key1->keys[iKey], &key2->keys[iKey]);
for (uint8_t iKey = 0; iKey < key1->numOfPKs; iKey++) {
int32_t ret = tValueCompare(&key1->pks[iKey], &key2->pks[iKey]);
if (ret) return ret;
}

View File

@ -301,7 +301,7 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
config.from->version = VERSION_MIN;
config.from->key = (SRowKey){
.ts = committer->ctx->minKey,
.numOfKeys = 0, // TODO: support multiple primary keys
.numOfPKs = 0, // TODO: support multiple primary keys
};
code = tsdbIterOpen(&config, &iter);

View File

@ -1952,13 +1952,13 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
startKey = (STsdbRowKey){.version = pReader->info.verRange.minVer,
.key = {
.ts = pBlockScanInfo->lastProcKey + 1,
.numOfKeys = 0, // TODO: change here if multi-key is supported
.numOfPKs = 0, // TODO: change here if multi-key is supported
}};
} else {
startKey = (STsdbRowKey){.version = pReader->info.verRange.maxVer,
.key = {
.ts = pBlockScanInfo->lastProcKey - 1,
.numOfKeys = 0, // TODO: change here if multi-key is supported
.numOfPKs = 0, // TODO: change here if multi-key is supported
}};
}
@ -2681,7 +2681,8 @@ static void buildCleanBlockFromDataFiles(STsdbReader* pReader, STableBlockScanIn
// update the last key for the corresponding table
pScanInfo->lastProcKey = asc ? pInfo->window.ekey : pInfo->window.skey;
tsdbDebug("%p uid:%" PRIu64 " clean file block retrieved from file, global index:%d, "
tsdbDebug("%p uid:%" PRIu64
" clean file block retrieved from file, global index:%d, "
"table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s",
pReader, pScanInfo->uid, blockIndex, pBlockInfo->tbBlockIdx, pBlockInfo->numRow, pBlockInfo->firstKey,
pBlockInfo->lastKey, pReader->idStr);

View File

@ -608,15 +608,15 @@ void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key) {
} else {
key->version = row->pBlockData->aVersion[row->iRow];
key->key.ts = row->pBlockData->aTSKEY[row->iRow];
key->key.numOfKeys = 0;
key->key.numOfPKs = 0;
for (int32_t i = 0; i < row->pBlockData->nColData; i++) {
SColData *pColData = &row->pBlockData->aColData[i];
if (pColData->cflag & COL_IS_KEY) {
SColVal cv;
tColDataGetValue(pColData, row->iRow, &cv);
ASSERT(COL_VAL_IS_VALUE(&cv));
key->key.keys[key->key.numOfKeys] = cv.value;
key->key.numOfKeys++;
key->key.pks[key->key.numOfPKs] = cv.value;
key->key.numOfPKs++;
} else {
break;
}