refactor: optimize the build block perf.
This commit is contained in:
parent
7db6497d28
commit
a2a2dbd68a
|
@ -184,6 +184,7 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
||||||
int32_t getJsonValueLen(const char* data);
|
int32_t getJsonValueLen(const char* data);
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
|
int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize);
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||||
const SColumnInfoData* pSource, int32_t numOfRow2);
|
const SColumnInfoData* pSource, int32_t numOfRow2);
|
||||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
||||||
|
|
|
@ -118,6 +118,28 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) {
|
||||||
|
if (!IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pColumnInfoData->varmeta.allocLen >= newSize) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pColumnInfoData->varmeta.allocLen < newSize) {
|
||||||
|
char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||||
|
if (buf == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pColumnInfoData->pData = buf;
|
||||||
|
pColumnInfoData->varmeta.allocLen = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, const SColumnInfoData* pSource,
|
static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, const SColumnInfoData* pSource,
|
||||||
int32_t numOfRow2) {
|
int32_t numOfRow2) {
|
||||||
if (numOfRow2 <= 0) return;
|
if (numOfRow2 <= 0) return;
|
||||||
|
|
|
@ -399,8 +399,15 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int
|
||||||
const char* p = metaGetTableTagVal(&mr.me, pColInfoData->info.type, &tagVal);
|
const char* p = metaGetTableTagVal(&mr.me, pColInfoData->info.type, &tagVal);
|
||||||
|
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
if (pColInfoData->info.type != TSDB_DATA_TYPE_JSON && p != NULL) {
|
if (pColInfoData->info.type != TSDB_DATA_TYPE_JSON && p != NULL) {
|
||||||
data = tTagValToData((const STagVal*)p, false);
|
data = tTagValToData((const STagVal*)p, false);
|
||||||
|
len = varDataTLen(data);
|
||||||
|
code = colDataReserve(pColInfoData, len * pBlock->info.rows);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = code;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
data = (char*)p;
|
data = (char*)p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1728,6 +1728,7 @@ int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO
|
||||||
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
metaGetTableNameByUid(pInput->param, uid, str);
|
metaGetTableNameByUid(pInput->param, uid, str);
|
||||||
|
|
||||||
|
colDataReserve(pOutput->columnData, varDataTLen(str) * (pInput->numOfRows + pOutput->numOfRows));
|
||||||
for(int32_t i = 0; i < pInput->numOfRows; ++i) {
|
for(int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||||
colDataAppend(pOutput->columnData, pOutput->numOfRows + i, str, false);
|
colDataAppend(pOutput->columnData, pOutput->numOfRows + i, str, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue