more code change
This commit is contained in:
parent
2ade750e4d
commit
665cc2c2c4
|
@ -205,8 +205,8 @@ struct SValue {
|
||||||
#define TD_MAX_PRIMARY_KEY_COL 8
|
#define TD_MAX_PRIMARY_KEY_COL 8
|
||||||
struct SRowKey {
|
struct SRowKey {
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
uint8_t numOfKeys;
|
uint8_t numOfPKs;
|
||||||
SValue keys[TD_MAX_PRIMARY_KEY_COL];
|
SValue pks[TD_MAX_PRIMARY_KEY_COL];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SColVal {
|
struct SColVal {
|
||||||
|
|
|
@ -1156,11 +1156,11 @@ int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, in
|
||||||
void tRowGetKey(SRow *pRow, SRowKey *key) {
|
void tRowGetKey(SRow *pRow, SRowKey *key) {
|
||||||
key->ts = pRow->ts;
|
key->ts = pRow->ts;
|
||||||
if ((pRow->flag & HAS_MULTI_KEY) == 0) {
|
if ((pRow->flag & HAS_MULTI_KEY) == 0) {
|
||||||
key->numOfKeys = 0;
|
key->numOfPKs = 0;
|
||||||
} else {
|
} else {
|
||||||
uint8_t *pEnd = ((uint8_t *)pRow) + pRow->len;
|
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
|
if (pRow->flag >> 4) { // Key-Value format
|
||||||
SKVIdx *pKVIdx = (SKVIdx *)pRow->data;
|
SKVIdx *pKVIdx = (SKVIdx *)pRow->data;
|
||||||
|
@ -1174,10 +1174,10 @@ void tRowGetKey(SRow *pRow, SRowKey *key) {
|
||||||
pv = pKVIdx->idx + (pKVIdx->nCol << 2);
|
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;
|
int32_t index;
|
||||||
uint8_t *pData;
|
uint8_t *pData;
|
||||||
SValue *pValue = &key->keys[iKey];
|
SValue *pValue = &key->pks[iKey];
|
||||||
|
|
||||||
pEnd -= tGetI8(pEnd, &pValue->type, false);
|
pEnd -= tGetI8(pEnd, &pValue->type, false);
|
||||||
pEnd -= tGetI32v(pEnd, &index, false);
|
pEnd -= tGetI32v(pEnd, &index, false);
|
||||||
|
@ -1221,18 +1221,18 @@ void tRowGetKey(SRow *pRow, SRowKey *key) {
|
||||||
ASSERTS(0, "invalid row format");
|
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;
|
int32_t offset;
|
||||||
SValue *pValue = &key->keys[iKey];
|
SValue *pValue = &key->pks[iKey];
|
||||||
|
|
||||||
pEnd -= tGetI8(pEnd, &pValue->type, false);
|
pEnd -= tGetI8(pEnd, &pValue->type, false);
|
||||||
pEnd -= tGetI32v(pEnd, &offset, 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 = pv + *(int32_t *)(pf + offset);
|
||||||
pValue->pData += tGetU32v(pValue->pData, &pValue->nData, true);
|
pValue->pData += tGetU32v(pValue->pData, &pValue->nData, true);
|
||||||
} else {
|
} 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t iKey = 0; iKey < key1->numOfKeys; iKey++) {
|
for (uint8_t iKey = 0; iKey < key1->numOfPKs; iKey++) {
|
||||||
int32_t ret = tValueCompare(&key1->keys[iKey], &key2->keys[iKey]);
|
int32_t ret = tValueCompare(&key1->pks[iKey], &key2->pks[iKey]);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
|
||||||
config.from->version = VERSION_MIN;
|
config.from->version = VERSION_MIN;
|
||||||
config.from->key = (SRowKey){
|
config.from->key = (SRowKey){
|
||||||
.ts = committer->ctx->minKey,
|
.ts = committer->ctx->minKey,
|
||||||
.numOfKeys = 0, // TODO: support multiple primary keys
|
.numOfPKs = 0, // TODO: support multiple primary keys
|
||||||
};
|
};
|
||||||
|
|
||||||
code = tsdbIterOpen(&config, &iter);
|
code = tsdbIterOpen(&config, &iter);
|
||||||
|
|
|
@ -1952,13 +1952,13 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
startKey = (STsdbRowKey){.version = pReader->info.verRange.minVer,
|
startKey = (STsdbRowKey){.version = pReader->info.verRange.minVer,
|
||||||
.key = {
|
.key = {
|
||||||
.ts = pBlockScanInfo->lastProcKey + 1,
|
.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 {
|
} else {
|
||||||
startKey = (STsdbRowKey){.version = pReader->info.verRange.maxVer,
|
startKey = (STsdbRowKey){.version = pReader->info.verRange.maxVer,
|
||||||
.key = {
|
.key = {
|
||||||
.ts = pBlockScanInfo->lastProcKey - 1,
|
.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
|
// update the last key for the corresponding table
|
||||||
pScanInfo->lastProcKey = asc ? pInfo->window.ekey : pInfo->window.skey;
|
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",
|
"table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s",
|
||||||
pReader, pScanInfo->uid, blockIndex, pBlockInfo->tbBlockIdx, pBlockInfo->numRow, pBlockInfo->firstKey,
|
pReader, pScanInfo->uid, blockIndex, pBlockInfo->tbBlockIdx, pBlockInfo->numRow, pBlockInfo->firstKey,
|
||||||
pBlockInfo->lastKey, pReader->idStr);
|
pBlockInfo->lastKey, pReader->idStr);
|
||||||
|
|
|
@ -608,15 +608,15 @@ void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key) {
|
||||||
} else {
|
} else {
|
||||||
key->version = row->pBlockData->aVersion[row->iRow];
|
key->version = row->pBlockData->aVersion[row->iRow];
|
||||||
key->key.ts = row->pBlockData->aTSKEY[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++) {
|
for (int32_t i = 0; i < row->pBlockData->nColData; i++) {
|
||||||
SColData *pColData = &row->pBlockData->aColData[i];
|
SColData *pColData = &row->pBlockData->aColData[i];
|
||||||
if (pColData->cflag & COL_IS_KEY) {
|
if (pColData->cflag & COL_IS_KEY) {
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
tColDataGetValue(pColData, row->iRow, &cv);
|
tColDataGetValue(pColData, row->iRow, &cv);
|
||||||
ASSERT(COL_VAL_IS_VALUE(&cv));
|
ASSERT(COL_VAL_IS_VALUE(&cv));
|
||||||
key->key.keys[key->key.numOfKeys] = cv.value;
|
key->key.pks[key->key.numOfPKs] = cv.value;
|
||||||
key->key.numOfKeys++;
|
key->key.numOfPKs++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue