提交 00c2d382 编写于 作者: H Haojun Liao

fix(query): opt filter perf.

上级 5c0fd801
...@@ -111,7 +111,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con ...@@ -111,7 +111,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
uint32_t len = pColumnInfoData->varmeta.length; uint32_t len = pColumnInfoData->varmeta.length;
pColumnInfoData->varmeta.offset[currentRow] = len; pColumnInfoData->varmeta.offset[currentRow] = len;
memcpy(pColumnInfoData->pData + len, pData, dataLen); memmove(pColumnInfoData->pData + len, pData, dataLen);
pColumnInfoData->varmeta.length += dataLen; pColumnInfoData->varmeta.length += dataLen;
} else { } else {
memcpy(pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow, pData, pColumnInfoData->info.bytes); memcpy(pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow, pData, pColumnInfoData->info.bytes);
......
...@@ -847,7 +847,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD ...@@ -847,7 +847,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
return; return;
} }
int8_t* pIndicator = p->pData; int8_t* pIndicator = (int8_t*)p->pData;
int32_t totalRows = pBlock->info.rows; int32_t totalRows = pBlock->info.rows;
if (status == FILTER_RESULT_ALL_QUALIFIED) { if (status == FILTER_RESULT_ALL_QUALIFIED) {
...@@ -856,7 +856,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD ...@@ -856,7 +856,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
pBlock->info.rows = 0; pBlock->info.rows = 0;
} else { } else {
int32_t bmLen = BitmapLen(totalRows); int32_t bmLen = BitmapLen(totalRows);
char* pBitmap = NULL; char* pBitmap = NULL;
int32_t maxRows = 0;
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
...@@ -868,100 +869,115 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD ...@@ -868,100 +869,115 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
int32_t numOfRows = 0; int32_t numOfRows = 0;
switch (pDst->info.type) { if (IS_VAR_DATA_TYPE(pDst->info.type)) {
case TSDB_DATA_TYPE_VARCHAR: int32_t j = 0;
case TSDB_DATA_TYPE_NCHAR: while(j < totalRows) {
break; if (pIndicator[j] == 0) {
default: continue;
if (pBitmap == NULL) { }
pBitmap = taosMemoryCalloc(1, bmLen);
if (colDataIsNull_var(pDst, j)) {
colDataSetNull_var(pDst, numOfRows);
} else {
char* p1 = colDataGetVarData(pDst, j);
colDataAppend(pDst, numOfRows, p1, false);
} }
memcpy(pBitmap, pDst->nullbitmap, bmLen); numOfRows += 1;
memset(pDst->nullbitmap, 0, bmLen); j += 1;
}
int32_t j = 0;
if (maxRows < numOfRows) {
switch (pDst->info.type) { maxRows = numOfRows;
case TSDB_DATA_TYPE_BIGINT: }
case TSDB_DATA_TYPE_UBIGINT: } else {
case TSDB_DATA_TYPE_DOUBLE: if (pBitmap == NULL) {
case TSDB_DATA_TYPE_TIMESTAMP: pBitmap = taosMemoryCalloc(1, bmLen);
while (j < totalRows) { }
if (pIndicator[j] == 0) {
j += 1; memcpy(pBitmap, pDst->nullbitmap, bmLen);
continue; memset(pDst->nullbitmap, 0, bmLen);
}
int32_t j = 0;
if (colDataIsNull_f(pBitmap, j)) {
colDataAppendNULL(pDst, numOfRows); switch (pDst->info.type) {
} else { case TSDB_DATA_TYPE_BIGINT:
((int64_t*)pDst->pData)[numOfRows] = ((int64_t*)pDst->pData)[j]; case TSDB_DATA_TYPE_UBIGINT:
} case TSDB_DATA_TYPE_DOUBLE:
numOfRows += 1; case TSDB_DATA_TYPE_TIMESTAMP:
while (j < totalRows) {
if (pIndicator[j] == 0) {
j += 1; j += 1;
continue;
}
if (colDataIsNull_f(pBitmap, j)) {
colDataSetNull_f(pDst->nullbitmap, numOfRows);
} else {
((int64_t*)pDst->pData)[numOfRows] = ((int64_t*)pDst->pData)[j];
} }
break; numOfRows += 1;
case TSDB_DATA_TYPE_FLOAT: j += 1;
case TSDB_DATA_TYPE_INT: }
case TSDB_DATA_TYPE_UINT: break;
while (j < totalRows) { case TSDB_DATA_TYPE_FLOAT:
if (pIndicator[j] == 0) { case TSDB_DATA_TYPE_INT:
j += 1; case TSDB_DATA_TYPE_UINT:
continue; while (j < totalRows) {
} if (pIndicator[j] == 0) {
if (colDataIsNull_f(pBitmap, j)) {
colDataAppendNULL(pDst, numOfRows);
} else {
((int32_t*)pDst->pData)[numOfRows++] = ((int32_t*)pDst->pData)[j];
}
numOfRows += 1;
j += 1; j += 1;
continue;
} }
break; if (colDataIsNull_f(pBitmap, j)) {
case TSDB_DATA_TYPE_SMALLINT: colDataSetNull_f(pDst->nullbitmap, numOfRows);
case TSDB_DATA_TYPE_USMALLINT: } else {
while (j < totalRows) { ((int32_t*)pDst->pData)[numOfRows++] = ((int32_t*)pDst->pData)[j];
if (pIndicator[j] == 0) { }
j += 1; numOfRows += 1;
continue; j += 1;
} }
if (colDataIsNull_f(pBitmap, j)) { break;
colDataAppendNULL(pDst, numOfRows); case TSDB_DATA_TYPE_SMALLINT:
} else { case TSDB_DATA_TYPE_USMALLINT:
((int16_t*)pDst->pData)[numOfRows++] = ((int16_t*)pDst->pData)[j]; while (j < totalRows) {
} if (pIndicator[j] == 0) {
numOfRows += 1;
j += 1; j += 1;
continue;
}
if (colDataIsNull_f(pBitmap, j)) {
colDataSetNull_f(pDst->nullbitmap, numOfRows);
} else {
((int16_t*)pDst->pData)[numOfRows++] = ((int16_t*)pDst->pData)[j];
} }
break; numOfRows += 1;
case TSDB_DATA_TYPE_BOOL: j += 1;
case TSDB_DATA_TYPE_TINYINT: }
case TSDB_DATA_TYPE_UTINYINT: break;
while (j < totalRows) { case TSDB_DATA_TYPE_BOOL:
if (pIndicator[j] == 0) { case TSDB_DATA_TYPE_TINYINT:
j += 1; case TSDB_DATA_TYPE_UTINYINT:
continue; while (j < totalRows) {
} if (pIndicator[j] == 0) {
if (colDataIsNull_f(pBitmap, j)) {
colDataAppendNULL(pDst, numOfRows);
} else {
((int8_t*)pDst->pData)[numOfRows] = ((int8_t*)pDst->pData)[j];
}
numOfRows += 1;
j += 1; j += 1;
continue;
} }
break; if (colDataIsNull_f(pBitmap, j)) {
} colDataSetNull_f(pDst->nullbitmap, numOfRows);
}; } else {
((int8_t*)pDst->pData)[numOfRows] = ((int8_t*)pDst->pData)[j];
}
numOfRows += 1;
j += 1;
}
break;
}
}
// todo this value can be assigned directly if (maxRows < numOfRows) {
if (pBlock->info.rows == totalRows) { maxRows = numOfRows;
pBlock->info.rows = numOfRows;
} else {
ASSERT(pBlock->info.rows == numOfRows);
} }
} }
pBlock->info.rows = maxRows;
if (pBitmap != NULL) { if (pBitmap != NULL) {
taosMemoryFree(pBitmap); taosMemoryFree(pBitmap);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册