perf: optimize insert
This commit is contained in:
parent
df69e060b2
commit
7bba9996cf
|
@ -74,9 +74,7 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema *
|
|||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
|
||||
// SValue ================================
|
||||
int32_t tPutValue(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);
|
||||
static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||
|
||||
// SColVal ================================
|
||||
#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);
|
||||
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
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct {
|
|||
#define TSROW_IS_KV_ROW(r) ((r)->flags & TSROW_KV_ROW)
|
||||
|
||||
// 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)) {
|
||||
return tPutBinary(p, pValue->pData, pValue->nData);
|
||||
} 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 ========================================================================
|
||||
static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
|
||||
if (pb) {
|
||||
|
|
|
@ -73,8 +73,8 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
|
|||
} else if (tdValTypeIsNone(pVal->valType)) {
|
||||
printf("NONE ");
|
||||
return;
|
||||
}
|
||||
if(!pVal->val) {
|
||||
}
|
||||
if (!pVal->val) {
|
||||
ASSERT(0);
|
||||
printf("BadVal ");
|
||||
return;
|
||||
|
@ -1083,13 +1083,15 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
} else if (tdValTypeIsNull(cv.valType)) {
|
||||
*pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type);
|
||||
} else {
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
value.nData = varDataLen(cv.val);
|
||||
value.pData = varDataVal(cv.val);
|
||||
} else {
|
||||
tGetValue(cv.val, &value, pTColumn->type);
|
||||
}
|
||||
pColVal->cid = pTColumn->colId;
|
||||
pColVal->type = pTColumn->type;
|
||||
pColVal->flag = CV_FLAG_VALUE;
|
||||
|
||||
*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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -607,7 +607,7 @@ void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
|||
SColVal *tRowIterNext(SRowIter *pIter) {
|
||||
if (pIter->pRow->type == 0) {
|
||||
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++;
|
||||
|
||||
return &pIter->colVal;
|
||||
|
|
Loading…
Reference in New Issue