perf: optimize insert

This commit is contained in:
Hongze Cheng 2022-11-08 14:36:18 +08:00
parent df69e060b2
commit 7bba9996cf
4 changed files with 23 additions and 28 deletions

View File

@ -74,9 +74,7 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema *
void tTSchemaDestroy(STSchema *pTSchema); void tTSchemaDestroy(STSchema *pTSchema);
// SValue ================================ // SValue ================================
int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type); static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type);
// SColVal ================================ // SColVal ================================
#define CV_FLAG_VALUE ((int8_t)0x0) #define CV_FLAG_VALUE ((int8_t)0x0)
@ -283,6 +281,15 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version)
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes); int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes);
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder); STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
if (IS_VAR_DATA_TYPE(type)) {
return tGetBinary(p, &pValue->pData, pValue ? &pValue->nData : NULL);
} else {
memcpy(&pValue->val, p, tDataTypes[type].bytes);
return tDataTypes[type].bytes;
}
}
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -56,7 +56,7 @@ typedef struct {
#define TSROW_IS_KV_ROW(r) ((r)->flags & TSROW_KV_ROW) #define TSROW_IS_KV_ROW(r) ((r)->flags & TSROW_KV_ROW)
// SValue // SValue
int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) { static FORCE_INLINE int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
if (IS_VAR_DATA_TYPE(type)) { if (IS_VAR_DATA_TYPE(type)) {
return tPutBinary(p, pValue->pData, pValue->nData); return tPutBinary(p, pValue->pData, pValue->nData);
} else { } else {
@ -65,20 +65,6 @@ int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
} }
} }
int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
if (IS_VAR_DATA_TYPE(type)) {
return tGetBinary(p, &pValue->pData, pValue ? &pValue->nData : NULL);
} else {
memcpy(&pValue->val, p, tDataTypes[type].bytes);
return tDataTypes[type].bytes;
}
}
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type) {
// TODO
return 0;
}
// STSRow2 ======================================================================== // STSRow2 ========================================================================
static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) { static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
if (pb) { if (pb) {

View File

@ -74,7 +74,7 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
printf("NONE "); printf("NONE ");
return; return;
} }
if(!pVal->val) { if (!pVal->val) {
ASSERT(0); ASSERT(0);
printf("BadVal "); printf("BadVal ");
return; return;
@ -1083,13 +1083,15 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
} else if (tdValTypeIsNull(cv.valType)) { } else if (tdValTypeIsNull(cv.valType)) {
*pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type);
} else { } else {
if (IS_VAR_DATA_TYPE(pTColumn->type)) { pColVal->cid = pTColumn->colId;
value.nData = varDataLen(cv.val); pColVal->type = pTColumn->type;
value.pData = varDataVal(cv.val); pColVal->flag = CV_FLAG_VALUE;
} else {
tGetValue(cv.val, &value, pTColumn->type);
}
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, value); if (IS_VAR_DATA_TYPE(pTColumn->type)) {
pColVal->value.nData = varDataLen(cv.val);
pColVal->value.pData = varDataVal(cv.val);
} else {
memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
}
} }
} }

View File

@ -607,7 +607,7 @@ void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
SColVal *tRowIterNext(SRowIter *pIter) { SColVal *tRowIterNext(SRowIter *pIter) {
if (pIter->pRow->type == 0) { if (pIter->pRow->type == 0) {
if (pIter->i < pIter->pTSchema->numOfCols) { if (pIter->i < pIter->pTSchema->numOfCols) {
tsdbRowGetColVal(pIter->pRow, pIter->pTSchema, pIter->i, &pIter->colVal); tTSRowGetVal(pIter->pRow->pTSRow, pIter->pTSchema, pIter->i, &pIter->colVal);
pIter->i++; pIter->i++;
return &pIter->colVal; return &pIter->colVal;