提交 f1181384 编写于 作者: A Alex Duan

feat(query): change config to tsAggAlways and apply code

上级 4aa7802e
......@@ -219,7 +219,7 @@ extern int32_t cqDebugFlag;
extern int32_t debugFlag;
extern int8_t tsClientMerge;
extern int8_t tsCountAlwaysReturnValue;
extern int8_t tsAggAlways;
// probe alive connection
extern int32_t tsProbeSeconds;
......
......@@ -273,7 +273,7 @@ int32_t cqDebugFlag = 131;
int32_t fsDebugFlag = 135;
int8_t tsClientMerge = 0;
int8_t tsCountAlwaysReturnValue = 0;
int8_t tsAggAlways = 0; // Agg function always return value even if zero row
// probe alive connection
int32_t tsProbeSeconds = 5 * 60; // start probe link alive after tsProbeSeconds from starting query
......@@ -1691,8 +1691,8 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "countAlwaysReturnValue";
cfg.ptr = &tsCountAlwaysReturnValue;
cfg.option = "aggAlways";
cfg.ptr = &tsAggAlways;
cfg.valType = TAOS_CFG_VTYPE_INT8;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0;
......
......@@ -30,6 +30,7 @@
#include "qUdf.h"
#include "tcompare.h"
#include "hashfunc.h"
#include "tglobal.h"
#define GET_INPUT_DATA_LIST(x) ((char *)((x)->pInput))
#define GET_INPUT_DATA(x, y) (GET_INPUT_DATA_LIST(x) + (y) * (x)->inputBytes)
......@@ -936,7 +937,7 @@ static void count_function(SQLFunctionCtx *pCtx) {
}
}
if (numOfElem > 0 || tsCountAlwaysReturnValue) {
if (numOfElem > 0 || tsAggAlways) {
GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG;
*((int64_t *)pCtx->pOutput) += numOfElem;
pCtx->resultInfo->numOfRes = 1;
......@@ -1156,6 +1157,11 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) {
}
}
// support always return value option
if(notNullElems == 0 && tsAggAlways) {
notNullElems = 1;
}
SET_VAL(pCtx, notNullElems, 1);
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
......
......@@ -338,6 +338,27 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
return code;
}
bool qFitAlwaysValue(SQInfo * pQInfo) {
// must agg query
if (pQInfo->query.simpleAgg)
return false;
// must not include ts column
SSDataBlock* pBlock = pQInfo->runtimeEnv.outputBuf;
if (pBlock == NULL || pBlock->pDataBlock == NULL)
return false;
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, 0);
if (pColInfoData == NULL)
return false;
// must not first column is timestamp
if (pColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP)
return false;
// fit ok
return true;
}
int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *contLen, bool* continueExec) {
SQInfo *pQInfo = (SQInfo *)qinfo;
int32_t compLen = 0;
......@@ -350,6 +371,11 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
int32_t s = GET_NUM_OF_RESULTS(pRuntimeEnv);
if (s == 0 && tsAggAlways) {
if (qFitAlwaryValue(pQInfo))
s = 1;
}
size_t size = pQueryAttr->resultRowSize * s;
size += sizeof(int32_t);
size += sizeof(STableIdInfo) * taosHashGetSize(pRuntimeEnv->pTableRetrieveTsMap);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册