提交 df667dea 编写于 作者: H Haojun Liao

[td-2895] refactor query processing model.

上级 7170a716
...@@ -883,7 +883,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -883,7 +883,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
assert(pField->pArithExprInfo != NULL); assert(pField->pArithExprInfo != NULL);
SExprInfo* pExprInfo = pField->pArithExprInfo; SExprInfo* pExprInfo = pField->pArithExprInfo;
pSqlFuncExpr1->colInfo.colId = htons(pExprInfo->base.colInfo.colId); pSqlFuncExpr1->colInfo.colId = htons(pExprInfo->base.colInfo.colId);
pSqlFuncExpr1->functionId = htons(pExprInfo->base.functionId); pSqlFuncExpr1->functionId = htons(pExprInfo->base.functionId);
pSqlFuncExpr1->numOfParams = htons(pExprInfo->base.numOfParams); pSqlFuncExpr1->numOfParams = htons(pExprInfo->base.numOfParams);
pMsg += sizeof(SSqlFuncMsg); pMsg += sizeof(SSqlFuncMsg);
......
...@@ -258,14 +258,14 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha ...@@ -258,14 +258,14 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
(_r)->initialized = false; \ (_r)->initialized = false; \
} while (0) } while (0)
static FORCE_INLINE void initResultInfo(SResultRowCellInfo *pResInfo, uint32_t bufLen) { static FORCE_INLINE void initResultInfo(SResultRowCellInfo *pResInfo, int32_t bufLen) {
pResInfo->initialized = true; // the this struct has been initialized flag pResInfo->initialized = true; // the this struct has been initialized flag
pResInfo->complete = false; pResInfo->complete = false;
pResInfo->hasResult = false; pResInfo->hasResult = false;
pResInfo->numOfRes = 0; pResInfo->numOfRes = 0;
memset(GET_ROWCELL_INTERBUF(pResInfo), 0, (size_t)bufLen); memset(GET_ROWCELL_INTERBUF(pResInfo), 0, bufLen);
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -259,14 +259,12 @@ typedef struct SQueryRuntimeEnv { ...@@ -259,14 +259,12 @@ typedef struct SQueryRuntimeEnv {
SQuery* pQuery; SQuery* pQuery;
void* qinfo; void* qinfo;
SQLFunctionCtx* pCtx; // SQLFunctionCtx* pCtx;
int32_t numOfRowsPerPage; int32_t numOfRowsPerPage;
uint16_t* offset; uint16_t* offset;
uint16_t scanFlag; // denotes reversed scan of data or not uint16_t scanFlag; // denotes reversed scan of data or not
SFillInfo* pFillInfo; SFillInfo* pFillInfo;
SResultRowInfo resultRowInfo;
void* pQueryHandle; void* pQueryHandle;
void* pSecQueryHandle; // another thread for
int32_t prevGroupId; // previous executed group id int32_t prevGroupId; // previous executed group id
SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file
...@@ -375,6 +373,8 @@ typedef struct SAggOperatorInfo { ...@@ -375,6 +373,8 @@ typedef struct SAggOperatorInfo {
STableQueryInfo *pTableQueryInfo; STableQueryInfo *pTableQueryInfo;
SQueryRuntimeEnv *pRuntimeEnv; SQueryRuntimeEnv *pRuntimeEnv;
SQLFunctionCtx *pCtx; SQLFunctionCtx *pCtx;
SSDataBlock* pRes;
} SAggOperatorInfo; } SAggOperatorInfo;
typedef struct SArithOperatorInfo { typedef struct SArithOperatorInfo {
...@@ -383,6 +383,7 @@ typedef struct SArithOperatorInfo { ...@@ -383,6 +383,7 @@ typedef struct SArithOperatorInfo {
SQLFunctionCtx *pCtx; SQLFunctionCtx *pCtx;
SResultRowInfo resultRowInfo; SResultRowInfo resultRowInfo;
SSDataBlock *pOutput; SSDataBlock *pOutput;
int32_t bufCapacity;
} SArithOperatorInfo; } SArithOperatorInfo;
typedef struct SLimitOperatorInfo { typedef struct SLimitOperatorInfo {
...@@ -411,7 +412,6 @@ typedef struct SFillOperatorInfo { ...@@ -411,7 +412,6 @@ typedef struct SFillOperatorInfo {
} SFillOperatorInfo; } SFillOperatorInfo;
typedef struct SHashGroupbyOperatorInfo { typedef struct SHashGroupbyOperatorInfo {
SResultRowInfo *pResultRowInfo;
STableQueryInfo *pTableQueryInfo; STableQueryInfo *pTableQueryInfo;
SQueryRuntimeEnv *pRuntimeEnv; SQueryRuntimeEnv *pRuntimeEnv;
SQLFunctionCtx *pCtx; SQLFunctionCtx *pCtx;
......
...@@ -2005,13 +2005,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) { ...@@ -2005,13 +2005,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) {
return; return;
} }
// data block is discard, not loaded, do not need to check it
if (!pCtx->preAggVals.dataBlockLoaded) {
return;
}
int32_t notNullElems = 0; int32_t notNullElems = 0;
for (int32_t i = pCtx->size - 1; i >= 0; --i) { for (int32_t i = pCtx->size - 1; i >= 0; --i) {
char *data = GET_INPUT_DATA(pCtx, i); char *data = GET_INPUT_DATA(pCtx, i);
if (pCtx->hasNull && isNull(data, pCtx->inputType)) { if (pCtx->hasNull && isNull(data, pCtx->inputType)) {
...@@ -3174,8 +3168,6 @@ static void col_project_function(SQLFunctionCtx *pCtx) { ...@@ -3174,8 +3168,6 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
pCtx->inputBytes); pCtx->inputBytes);
} }
} }
pCtx->pOutput += pCtx->size * pCtx->outputBytes;
} }
static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) { static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...@@ -3574,7 +3566,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) { ...@@ -3574,7 +3566,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
SArithmeticSupport *sas = (SArithmeticSupport *)pCtx->param[1].pz; SArithmeticSupport *sas = (SArithmeticSupport *)pCtx->param[1].pz;
arithmeticTreeTraverse(sas->pArithExpr->pExpr, pCtx->size, pCtx->pOutput, sas, pCtx->order, getArithColumnData); arithmeticTreeTraverse(sas->pArithExpr->pExpr, pCtx->size, pCtx->pOutput, sas, pCtx->order, getArithColumnData);
pCtx->pOutput += pCtx->outputBytes * pCtx->size; // pCtx->pOutput += pCtx->outputBytes * pCtx->size;
} }
static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) { static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
......
此差异已折叠。
...@@ -297,13 +297,13 @@ static void resetCheckInfo(STsdbQueryHandle* pQueryHandle) { ...@@ -297,13 +297,13 @@ static void resetCheckInfo(STsdbQueryHandle* pQueryHandle) {
pCheckInfo->lastKey = pQueryHandle->window.skey; pCheckInfo->lastKey = pQueryHandle->window.skey;
pCheckInfo->iter = tSkipListDestroyIter(pCheckInfo->iter); pCheckInfo->iter = tSkipListDestroyIter(pCheckInfo->iter);
pCheckInfo->iiter = tSkipListDestroyIter(pCheckInfo->iiter); pCheckInfo->iiter = tSkipListDestroyIter(pCheckInfo->iiter);
pCheckInfo->initBuf = false;
if (ASCENDING_TRAVERSE(pQueryHandle->order)) { if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
assert(pCheckInfo->lastKey >= pQueryHandle->window.skey); assert(pCheckInfo->lastKey >= pQueryHandle->window.skey);
} else { } else {
assert(pCheckInfo->lastKey <= pQueryHandle->window.skey); assert(pCheckInfo->lastKey <= pQueryHandle->window.skey);
} }
} }
} }
...@@ -2035,7 +2035,8 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) { ...@@ -2035,7 +2035,8 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) {
} }
// no data in memtable or imemtable, decrease the memory reference. // no data in memtable or imemtable, decrease the memory reference.
tsdbMayUnTakeMemSnapshot(pQueryHandle); // TODO !!
// tsdbMayUnTakeMemSnapshot(pQueryHandle);
return false; return false;
} }
......
...@@ -93,6 +93,7 @@ $halfTbNum = $tbNum / 2 ...@@ -93,6 +93,7 @@ $halfTbNum = $tbNum / 2
$nchar = 'nchar . $c $nchar = 'nchar . $c
$nchar = $nchar . ' $nchar = $nchar . '
$ts = $ts + 1
sql insert into $tb5 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb6 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb7 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb8 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb9 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) sql insert into $tb5 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb6 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb7 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb8 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb9 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar )
$x = $x + 1 $x = $x + 1
endw endw
......
...@@ -426,7 +426,7 @@ if $data02 != 9.000000020 then ...@@ -426,7 +426,7 @@ if $data02 != 9.000000020 then
endi endi
# all possible function in the arithmetic expression, add more # all possible function in the arithmetic expression, add more
sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:00.000'; sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:01.000';
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
...@@ -462,7 +462,7 @@ if $rows != 0 then ...@@ -462,7 +462,7 @@ if $rows != 0 then
endi endi
# no result return [d.3] # no result return [d.3]
sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:00.000' sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:01.000'
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
...@@ -520,35 +520,35 @@ if $data91 != 9 then ...@@ -520,35 +520,35 @@ if $data91 != 9 then
endi endi
# in group by column # in group by column
sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2; #sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2;
if $rows != 10 then #if $rows != 10 then
return -1 # return -1
endi #endi
#
if $data00 != 0.000000000 then #if $data00 != 0.000000000 then
return -1 # return -1
endi #endi
#
if $data01 != 0.000000000 then #if $data01 != 0.000000000 then
return -1 # return -1
endi #endi
#
if $data10 != 12.000000000 then #if $data10 != 12.000000000 then
return -1 # return -1
endi #endi
#
if $data11 != 12.000000000 then #if $data11 != 12.000000000 then
return -1 # return -1
endi #endi
#
if $data20 != 24.000000000 then #if $data20 != 24.000000000 then
return -1 # return -1
endi #endi
#
if $data21 != 24.000000000 then #if $data21 != 24.000000000 then
return -1 # return -1
endi #endi
#
sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3; sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3;
sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5; sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5;
......
...@@ -313,6 +313,7 @@ if $rows != 9 then ...@@ -313,6 +313,7 @@ if $rows != 9 then
return -1 return -1
endi endi
if $data01 != 0 then if $data01 != 0 then
print expect 0, actual:$data01
return -1 return -1
endi endi
if $data11 != 6 then if $data11 != 6 then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册