Merge pull request #11631 from taosdata/feature/TD-14481-3.0

feat: trow refactor
This commit is contained in:
Cary Xu 2022-04-19 14:30:04 +08:00 committed by GitHub
commit dc11ea8384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 26 deletions

View File

@ -308,21 +308,21 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx,
// use literal value directly and not use formula to simplify the codes // use literal value directly and not use formula to simplify the codes
switch (nOffset) { switch (nOffset) {
case 0: case 0:
// *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6); *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6);
// set the value and clear other partitions for offset 0 // set the value and clear other partitions for offset 0
*pDestByte = (valType << 6); // *pDestByte |= (valType << 6);
break; break;
case 1: case 1:
// *pDestByte = ((*pDestByte) & 0xCF) | (valType << 4); *pDestByte = ((*pDestByte) & 0xCF) | (valType << 4);
*pDestByte |= (valType << 4); // *pDestByte |= (valType << 4);
break; break;
case 2: case 2:
// *pDestByte = ((*pDestByte) & 0xF3) | (valType << 2); *pDestByte = ((*pDestByte) & 0xF3) | (valType << 2);
*pDestByte |= (valType << 2); // *pDestByte |= (valType << 2);
break; break;
case 3: case 3:
// *pDestByte = ((*pDestByte) & 0xFC) | valType; *pDestByte = ((*pDestByte) & 0xFC) | valType;
*pDestByte |= (valType); // *pDestByte |= (valType);
break; break;
default: default:
TASSERT(0); TASSERT(0);
@ -417,37 +417,37 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, T
// use literal value directly and not use formula to simplify the codes // use literal value directly and not use formula to simplify the codes
switch (nOffset) { switch (nOffset) {
case 0: case 0:
// *pDestByte = ((*pDestByte) & 0x7F) | (valType << 7); *pDestByte = ((*pDestByte) & 0x7F) | (valType << 7);
// set the value and clear other partitions for offset 0 // set the value and clear other partitions for offset 0
*pDestByte = (valType << 7); // *pDestByte |= (valType << 7);
break; break;
case 1: case 1:
// *pDestByte = ((*pDestByte) & 0xBF) | (valType << 6); *pDestByte = ((*pDestByte) & 0xBF) | (valType << 6);
*pDestByte |= (valType << 6); // *pDestByte |= (valType << 6);
break; break;
case 2: case 2:
// *pDestByte = ((*pDestByte) & 0xDF) | (valType << 5); *pDestByte = ((*pDestByte) & 0xDF) | (valType << 5);
*pDestByte |= (valType << 5); // *pDestByte |= (valType << 5);
break; break;
case 3: case 3:
// *pDestByte = ((*pDestByte) & 0xEF) | (valType << 4); *pDestByte = ((*pDestByte) & 0xEF) | (valType << 4);
*pDestByte |= (valType << 4); // *pDestByte |= (valType << 4);
break; break;
case 4: case 4:
// *pDestByte = ((*pDestByte) & 0xF7) | (valType << 3); *pDestByte = ((*pDestByte) & 0xF7) | (valType << 3);
*pDestByte |= (valType << 3); // *pDestByte |= (valType << 3);
break; break;
case 5: case 5:
// *pDestByte = ((*pDestByte) & 0xFB) | (valType << 2); *pDestByte = ((*pDestByte) & 0xFB) | (valType << 2);
*pDestByte |= (valType << 2); // *pDestByte |= (valType << 2);
break; break;
case 6: case 6:
// *pDestByte = ((*pDestByte) & 0xFD) | (valType << 1); *pDestByte = ((*pDestByte) & 0xFD) | (valType << 1);
*pDestByte |= (valType << 1); // *pDestByte |= (valType << 1);
break; break;
case 7: case 7:
// *pDestByte = ((*pDestByte) & 0xFE) | valType; *pDestByte = ((*pDestByte) & 0xFE) | valType;
*pDestByte |= (valType); // *pDestByte |= (valType);
break; break;
default: default:
TASSERT(0); TASSERT(0);
@ -656,6 +656,7 @@ static int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
case TD_ROW_TP: case TD_ROW_TP:
#ifdef TD_SUPPORT_BITMAP #ifdef TD_SUPPORT_BITMAP
pBuilder->pBitmap = tdGetBitmapAddrTp(pBuilder->pBuf, pBuilder->flen); pBuilder->pBitmap = tdGetBitmapAddrTp(pBuilder->pBuf, pBuilder->flen);
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
#endif #endif
// the primary TS key is stored separatedly // the primary TS key is stored separatedly
len = TD_ROW_HEAD_LEN + pBuilder->flen - sizeof(TSKEY) + pBuilder->nBitmaps; len = TD_ROW_HEAD_LEN + pBuilder->flen - sizeof(TSKEY) + pBuilder->nBitmaps;
@ -665,6 +666,7 @@ static int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
case TD_ROW_KV: case TD_ROW_KV:
#ifdef TD_SUPPORT_BITMAP #ifdef TD_SUPPORT_BITMAP
pBuilder->pBitmap = tdGetBitmapAddrKv(pBuilder->pBuf, pBuilder->nBoundCols); pBuilder->pBitmap = tdGetBitmapAddrKv(pBuilder->pBuf, pBuilder->nBoundCols);
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
#endif #endif
len = TD_ROW_HEAD_LEN + TD_ROW_NCOLS_LEN + (pBuilder->nBoundCols - 1) * sizeof(SKvRowIdx) + len = TD_ROW_HEAD_LEN + TD_ROW_NCOLS_LEN + (pBuilder->nBoundCols - 1) * sizeof(SKvRowIdx) +
pBuilder->nBoundBitmaps; // add pBuilder->nBoundBitmaps; // add

View File

@ -98,7 +98,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(SSchema *pSchema, uint8_t rowType,
*toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart *toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart
*colIdx = schemaIdx; *colIdx = schemaIdx;
} else { } else {
*toffset = idx * sizeof(SColIdx); // the offset of SColIdx *toffset = idx * sizeof(SKvRowIdx); // the offset of SKvRowIdx
*colIdx = idx; *colIdx = idx;
} }
} else { } else {
@ -108,7 +108,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(SSchema *pSchema, uint8_t rowType,
*toffset = (spd->cols + schemaIdx)->toffset; *toffset = (spd->cols + schemaIdx)->toffset;
*colIdx = schemaIdx; *colIdx = schemaIdx;
} else { } else {
*toffset = ((spd->colIdxInfo + idx)->finalIdx) * sizeof(SColIdx); *toffset = ((spd->colIdxInfo + idx)->finalIdx) * sizeof(SKvRowIdx);
*colIdx = (spd->colIdxInfo + idx)->finalIdx; *colIdx = (spd->colIdxInfo + idx)->finalIdx;
} }
} }