提交 92d6d0af 编写于 作者: H Haojun Liao

[td-2895] refactor.

上级 e8ff71f7
...@@ -379,28 +379,24 @@ int16_t getGroupbyColumnType(SQuery *pQuery, SSqlGroupbyExpr *pGroupbyExpr) { ...@@ -379,28 +379,24 @@ int16_t getGroupbyColumnType(SQuery *pQuery, SSqlGroupbyExpr *pGroupbyExpr) {
return type; return type;
} }
//static bool isSelectivityWithTagsQuery(SQuery *pQuery) { static bool isSelectivityWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
// bool hasTags = false; bool hasTags = false;
// int32_t numOfSelectivity = 0; int32_t numOfSelectivity = 0;
//
// for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { for (int32_t i = 0; i < numOfOutput; ++i) {
// int32_t functId = pQuery->pExpr1[i].base.functionId; int32_t functId = pCtx[i].functionId;
// if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) { if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) {
// hasTags = true; hasTags = true;
// continue; continue;
// } }
//
// if ((aAggs[functId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { if ((aAggs[functId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
// numOfSelectivity++; numOfSelectivity++;
// } }
// } }
//
// if (numOfSelectivity > 0 && hasTags) { return (numOfSelectivity > 0 && hasTags);
// return true; }
// }
//
// return false;
//}
static bool isProjQuery(SQuery *pQuery) { static bool isProjQuery(SQuery *pQuery) {
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
...@@ -1982,47 +1978,47 @@ void UNUSED_FUNC setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inpu ...@@ -1982,47 +1978,47 @@ void UNUSED_FUNC setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inpu
// } // }
} }
//// set the output buffer for the selectivity + tag query // set the output buffer for the selectivity + tag query
//static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx) { static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
// SQuery* pQuery = pRuntimeEnv->pQuery; if (!isSelectivityWithTagsQuery(pCtx, numOfOutput)) {
// return TSDB_CODE_SUCCESS;
// if (isSelectivityWithTagsQuery(pQuery)) { }
// int32_t num = 0;
// int16_t tagLen = 0; int32_t num = 0;
// int16_t tagLen = 0;
// SQLFunctionCtx *p = NULL;
// SQLFunctionCtx **pTagCtx = calloc(pQuery->numOfOutput, POINTER_BYTES); SQLFunctionCtx* p = NULL;
// if (pTagCtx == NULL) { SQLFunctionCtx** pTagCtx = calloc(numOfOutput, POINTER_BYTES);
// return TSDB_CODE_QRY_OUT_OF_MEMORY; if (pTagCtx == NULL) {
// } return TSDB_CODE_QRY_OUT_OF_MEMORY;
// }
// for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
// SSqlFuncMsg *pSqlFuncMsg = &pQuery->pExpr1[i].base; for (int32_t i = 0; i < numOfOutput; ++i) {
// int32_t functionId = pCtx[i].functionId;
// if (pSqlFuncMsg->functionId == TSDB_FUNC_TAG_DUMMY || pSqlFuncMsg->functionId == TSDB_FUNC_TS_DUMMY) {
// tagLen += pCtx[i].outputBytes; if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
// pTagCtx[num++] = &pCtx[i]; tagLen += pCtx[i].outputBytes;
// } else if ((aAggs[pSqlFuncMsg->functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { pTagCtx[num++] = &pCtx[i];
// p = &pCtx[i]; } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
// } else if (pSqlFuncMsg->functionId == TSDB_FUNC_TS || pSqlFuncMsg->functionId == TSDB_FUNC_TAG) { p = &pCtx[i];
// // tag function may be the group by tag column } else if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TAG) {
// // ts may be the required primary timestamp column // tag function may be the group by tag column
// continue; // ts may be the required primary timestamp column
// } else { continue;
// // the column may be the normal column, group by normal_column, the functionId is TSDB_FUNC_PRJ } else {
// } // the column may be the normal column, group by normal_column, the functionId is TSDB_FUNC_PRJ
// } }
// if (p != NULL) { }
// p->tagInfo.pTagCtxList = pTagCtx; if (p != NULL) {
// p->tagInfo.numOfTagCols = num; p->tagInfo.pTagCtxList = pTagCtx;
// p->tagInfo.tagsLen = tagLen; p->tagInfo.numOfTagCols = num;
// } else { p->tagInfo.tagsLen = tagLen;
// tfree(pTagCtx); } else {
// } tfree(pTagCtx);
// } }
//
// return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
//} }
static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput, static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput,
int32_t** rowCellInfoOffset) { int32_t** rowCellInfoOffset) {
...@@ -2123,6 +2119,8 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr ...@@ -2123,6 +2119,8 @@ static SQLFunctionCtx* createSQLFunctionCtx(SQueryRuntimeEnv* pRuntimeEnv, SExpr
} }
} }
setCtxTagColumnInfo(pFuncCtx, numOfOutput);
return pFuncCtx; return pFuncCtx;
} }
...@@ -2175,10 +2173,6 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf ...@@ -2175,10 +2173,6 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
*(int64_t*) pRuntimeEnv->prevRow[0] = INT64_MIN; *(int64_t*) pRuntimeEnv->prevRow[0] = INT64_MIN;
// if (setCtxTagColumnInfo(pRuntimeEnv, pRuntimeEnv->pCtx) != TSDB_CODE_SUCCESS) {
// goto _clean;
// }
qDebug("QInfo:%p init runtime completed", GET_QINFO_ADDR(pRuntimeEnv)); qDebug("QInfo:%p init runtime completed", GET_QINFO_ADDR(pRuntimeEnv));
// group by normal column, sliding window query, interval query are handled by interval query processor // group by normal column, sliding window query, interval query are handled by interval query processor
...@@ -6531,7 +6525,6 @@ static SSDataBlock* doSTableIntervalAgg(void* param) { ...@@ -6531,7 +6525,6 @@ static SSDataBlock* doSTableIntervalAgg(void* param) {
SQuery* pQuery = pRuntimeEnv->pQuery; SQuery* pQuery = pRuntimeEnv->pQuery;
int32_t order = pQuery->order.order; int32_t order = pQuery->order.order;
assert(order == 1);
SOperatorInfo* upstream = pOperator->upstream; SOperatorInfo* upstream = pOperator->upstream;
pQuery->pos = 0; pQuery->pos = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册