enh: improve filter performance
This commit is contained in:
parent
ddd3a53e56
commit
532e02fb2a
|
@ -178,6 +178,7 @@ int32_t getJsonValueLen(const char* data);
|
||||||
|
|
||||||
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||||
|
int32_t colDataReassignVal(SColumnInfoData* pColumnInfoData, uint32_t dstRowIdx, uint32_t srcRowIdx, const char* pData);
|
||||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue);
|
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue);
|
||||||
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);
|
||||||
|
|
|
@ -126,6 +126,29 @@ int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t colDataReassignVal(SColumnInfoData* pColumnInfoData, uint32_t dstRowIdx, uint32_t srcRowIdx, const char* pData) {
|
||||||
|
int32_t type = pColumnInfoData->info.type;
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
int32_t dataLen = 0;
|
||||||
|
if (type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
dataLen = getJsonValueLen(pData);
|
||||||
|
} else {
|
||||||
|
dataLen = varDataTLen(pData);
|
||||||
|
}
|
||||||
|
|
||||||
|
SVarColAttr* pAttr = &pColumnInfoData->varmeta;
|
||||||
|
|
||||||
|
uint32_t len = pColumnInfoData->varmeta.length;
|
||||||
|
pColumnInfoData->varmeta.offset[dstRowIdx] = pColumnInfoData->varmeta.offset[srcRowIdx];
|
||||||
|
} else {
|
||||||
|
memcpy(pColumnInfoData->pData + pColumnInfoData->info.bytes * dstRowIdx, pData, pColumnInfoData->info.bytes);
|
||||||
|
colDataClearNull_f(pColumnInfoData->nullbitmap, dstRowIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) {
|
int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) {
|
||||||
if (!IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (!IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -573,18 +573,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
|
||||||
if (colDataIsNull_var(pDst, j)) {
|
if (colDataIsNull_var(pDst, j)) {
|
||||||
colDataSetNull_var(pDst, numOfRows);
|
colDataSetNull_var(pDst, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
// fix address sanitizer error. p1 may point to memory that will change during realloc of colDataSetVal, first copy it to p2
|
|
||||||
char* p1 = colDataGetVarData(pDst, j);
|
char* p1 = colDataGetVarData(pDst, j);
|
||||||
int32_t len = 0;
|
colDataReassignVal(pDst, numOfRows, j, p1);
|
||||||
if (pDst->info.type == TSDB_DATA_TYPE_JSON) {
|
|
||||||
len = getJsonValueLen(p1);
|
|
||||||
} else {
|
|
||||||
len = varDataTLen(p1);
|
|
||||||
}
|
|
||||||
char* p2 = taosMemoryMalloc(len);
|
|
||||||
memcpy(p2, p1, len);
|
|
||||||
colDataSetVal(pDst, numOfRows, p2, false);
|
|
||||||
taosMemoryFree(p2);
|
|
||||||
}
|
}
|
||||||
numOfRows += 1;
|
numOfRows += 1;
|
||||||
j += 1;
|
j += 1;
|
||||||
|
|
Loading…
Reference in New Issue