提交 9fa5b304 编写于 作者: H Hongze Cheng

Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/alter_table

......@@ -2114,6 +2114,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
}
}
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep);
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
if (pFilterNode == NULL) {
return;
......@@ -2128,43 +2129,60 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
code = filterSetDataFromSlotId(filter, &param1);
int8_t* rowRes = NULL;
// todo the keep seems never to be True??
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
filterFreeInfo(filter);
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
blockDataUpdateTsWindow(pBlock);
}
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) {
if (keep) {
return;
}
if (rowRes != NULL) {
SSDataBlock* px = createOneDataBlock(pBlock, false);
blockDataEnsureCapacity(px, pBlock->info.rows);
// todo extract method
int32_t numOfRow = 0;
int32_t totalRows = pBlock->info.rows;
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i);
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i);
if (keep) {
colDataAssign(pDst, pSrc, pBlock->info.rows);
numOfRow = pBlock->info.rows;
} else if (NULL != rowRes) {
numOfRow = 0;
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
// For the reserved column, the value is not filled yet, so the whole column data may be NULL.
if (pSrc->pData == NULL) {
continue;
}
int32_t numOfRows = 0;
for (int32_t j = 0; j < totalRows; ++j) {
if (rowRes[j] == 0) {
continue;
}
if (colDataIsNull_s(pSrc, j)) {
colDataAppendNULL(pDst, numOfRow);
colDataAppendNULL(pDst, numOfRows);
} else {
colDataAppend(pDst, numOfRow, colDataGetData(pSrc, j), false);
colDataAppend(pDst, numOfRows, colDataGetData(pSrc, j), false);
}
numOfRow += 1;
numOfRows += 1;
}
if (pBlock->info.rows == totalRows) {
pBlock->info.rows = numOfRows;
} else {
numOfRow = 0;
ASSERT(pBlock->info.rows == numOfRows);
}
*pSrc = *pDst;
}
pBlock->info.rows = numOfRow;
blockDataUpdateTsWindow(pBlock);
} else {
// do nothing
pBlock->info.rows = 0;
}
}
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册