From 8249d5f694e67c984d1a72b58fa094c0ddc50e07 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 6 Feb 2021 13:59:21 +0800 Subject: [PATCH] [TD-225] refactor --- src/query/inc/qExecutor.h | 6 +++--- src/query/src/qExecutor.c | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 6145666498..5c27aed625 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -318,11 +318,11 @@ typedef struct STableScanInfo { int32_t numOfBlockStatis; int64_t numOfRows; - int32_t order; - bool completed; + + int32_t order; // scan order + int32_t times; // repeat counts SSDataBlock block; - int64_t elapsedTime; SSDataBlock* (*apply)(void* param); } STableScanInfo; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index e4ee3221c9..3f22a132e8 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5608,25 +5608,34 @@ static SSDataBlock* doTableScan(void* param) { } return pBlock; -// int32_t ret = loadDataBlockOnDemand(pRuntimeEnv, &pRuntimeEnv->resultRowInfo, pQueryHandle, &blockInfo, &pStatis, &pDataBlock, &status); -// if (ret != TSDB_CODE_SUCCESS) { -// break; -// } - -// if (status == BLK_DATA_DISCARD) { -// pQuery->current->lastKey = -// QUERY_IS_ASC_QUERY(pQuery) ? blockInfo.window.ekey + step : blockInfo.window.skey + step; -// continue; -// } } + STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window); + pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo, &pQInfo->memRef); + if (pRuntimeEnv->pSecQueryHandle == NULL) { + longjmp(pRuntimeEnv->env, terrno); + } + + pRuntimeEnv->resultRowInfo.curIndex = qstatus.windowIndex; + setQueryStatus(pQuery, QUERY_NOT_COMPLETED); + pRuntimeEnv->scanFlag = REPEAT_SCAN; + + if (pRuntimeEnv->pTsBuf) { + bool ret = tsBufNextPos(pRuntimeEnv->pTsBuf); + assert(ret); + } + + qDebug("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%"PRId64"-%"PRId64, pQInfo, + cond.twindow.skey, cond.twindow.ekey); + return NULL; } -static UNUSED_FUNC STableScanInfo* createTableScanInfo(void* pTsdbQueryHandle) { +static UNUSED_FUNC STableScanInfo* createTableScanInfo(void* pTsdbQueryHandle, int32_t repeatTime) { STableScanInfo* pInfo = calloc(1, sizeof(STableScanInfo)); pInfo->pQueryHandle = pTsdbQueryHandle; pInfo->apply = doTableScan; + pInfo->times = repeatTime; return pInfo; }