refactor codes.
This commit is contained in:
parent
08854f86ae
commit
08df5bf992
|
@ -112,7 +112,7 @@ typedef struct SLimitVal {
|
||||||
} SLimitVal;
|
} SLimitVal;
|
||||||
|
|
||||||
typedef struct SOrderVal {
|
typedef struct SOrderVal {
|
||||||
int32_t order;
|
uint32_t order;
|
||||||
int32_t orderColId;
|
int32_t orderColId;
|
||||||
} SOrderVal;
|
} SOrderVal;
|
||||||
|
|
||||||
|
|
|
@ -697,12 +697,15 @@ static int32_t first_dist_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY
|
||||||
return BLK_DATA_NO_NEEDED;
|
return BLK_DATA_NO_NEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
// result buffer has not been set yet.
|
||||||
if (pInfo->hasResult != DATA_SET_FLAG) {
|
|
||||||
return BLK_DATA_ALL_NEEDED;
|
return BLK_DATA_ALL_NEEDED;
|
||||||
} else { // data in current block is not earlier than current result
|
//todo optimize the filter info
|
||||||
return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
|
||||||
}
|
// if (pInfo->hasResult != DATA_SET_FLAG) {
|
||||||
|
// return BLK_DATA_ALL_NEEDED;
|
||||||
|
// } else { // data in current block is not earlier than current result
|
||||||
|
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t last_dist_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId,
|
static int32_t last_dist_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId,
|
||||||
|
@ -1416,6 +1419,8 @@ static void stddev_next_step(SQLFunctionCtx *pCtx) {
|
||||||
pStd->stage++;
|
pStd->stage++;
|
||||||
avg_finalizer(pCtx);
|
avg_finalizer(pCtx);
|
||||||
|
|
||||||
|
pResInfo->initialized = true; // set it initialized to avoid re-initialization
|
||||||
|
|
||||||
// save average value into tmpBuf, for second stage scan
|
// save average value into tmpBuf, for second stage scan
|
||||||
SAvgInfo *pAvg = pResInfo->interResultBuf;
|
SAvgInfo *pAvg = pResInfo->interResultBuf;
|
||||||
|
|
||||||
|
@ -2078,6 +2083,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
|
||||||
TSKEY *output = pCtx->ptsOutputBuf;
|
TSKEY *output = pCtx->ptsOutputBuf;
|
||||||
for (int32_t i = 0; i < len; ++i, output += step) {
|
for (int32_t i = 0; i < len; ++i, output += step) {
|
||||||
*output = tvp[i]->timestamp;
|
*output = tvp[i]->timestamp;
|
||||||
|
printf("-------------%lld\n", *output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the corresponding tag data for each record
|
// set the corresponding tag data for each record
|
||||||
|
|
|
@ -765,22 +765,22 @@ void savePrevRecordAndSetupInterpoInfo(SLocalReducer *pLocalReducer, SQueryInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo merge with following function
|
// todo merge with following function
|
||||||
static void reversedCopyResultToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage *pFinalDataPage) {
|
//static void reversedCopyResultToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage *pFinalDataPage) {
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
|
// for (int32_t i = 0; i < pQueryInfo->exprsInfo.numOfExprs; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
// TAOS_FIELD *pField = tscFieldInfoGetField(pQueryInfo, i);
|
||||||
|
//
|
||||||
int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
|
// int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
|
||||||
char * src = pFinalDataPage->data + (pRes->numOfRows - 1) * pField->bytes + pRes->numOfRows * offset;
|
// char * src = pFinalDataPage->data + (pRes->numOfRows - 1) * pField->bytes + pRes->numOfRows * offset;
|
||||||
char * dst = pRes->data + pRes->numOfRows * offset;
|
// char * dst = pRes->data + pRes->numOfRows * offset;
|
||||||
|
//
|
||||||
for (int32_t j = 0; j < pRes->numOfRows; ++j) {
|
// for (int32_t j = 0; j < pRes->numOfRows; ++j) {
|
||||||
memcpy(dst, src, (size_t)pField->bytes);
|
// memcpy(dst, src, (size_t)pField->bytes);
|
||||||
dst += pField->bytes;
|
// dst += pField->bytes;
|
||||||
src -= pField->bytes;
|
// src -= pField->bytes;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
static void reversedCopyFromInterpolationToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage **pResPages, SLocalReducer *pLocalReducer) {
|
static void reversedCopyFromInterpolationToDstBuf(SQueryInfo* pQueryInfo, SSqlRes *pRes, tFilePage **pResPages, SLocalReducer *pLocalReducer) {
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -120,7 +120,7 @@ typedef enum {
|
||||||
typedef int (*__block_search_fn_t)(char* data, int num, int64_t key, int order);
|
typedef int (*__block_search_fn_t)(char* data, int num, int64_t key, int order);
|
||||||
|
|
||||||
static FORCE_INLINE SMeterObj* getMeterObj(void* hashHandle, int32_t sid) {
|
static FORCE_INLINE SMeterObj* getMeterObj(void* hashHandle, int32_t sid) {
|
||||||
return *(SMeterObj**)taosGetDataFromHashTable(hashHandle, (const char*) &sid, sizeof(sid));
|
return *(SMeterObj**)taosGetDataFromHashTable(hashHandle, (const char*)&sid, sizeof(sid));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isQueryKilled(SQuery* pQuery);
|
bool isQueryKilled(SQuery* pQuery);
|
||||||
|
@ -129,7 +129,7 @@ bool isPointInterpoQuery(SQuery* pQuery);
|
||||||
bool isTopBottomQuery(SQuery* pQuery);
|
bool isTopBottomQuery(SQuery* pQuery);
|
||||||
bool isFirstLastRowQuery(SQuery* pQuery);
|
bool isFirstLastRowQuery(SQuery* pQuery);
|
||||||
bool isTSCompQuery(SQuery* pQuery);
|
bool isTSCompQuery(SQuery* pQuery);
|
||||||
bool notHasQueryTimeRange(SQuery *pQuery);
|
bool notHasQueryTimeRange(SQuery* pQuery);
|
||||||
|
|
||||||
bool needSupplementaryScan(SQuery* pQuery);
|
bool needSupplementaryScan(SQuery* pQuery);
|
||||||
bool onDemandLoadDatablock(SQuery* pQuery, int16_t queryRangeSet);
|
bool onDemandLoadDatablock(SQuery* pQuery, int16_t queryRangeSet);
|
||||||
|
@ -148,16 +148,16 @@ void vnodeScanAllData(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
|
|
||||||
int32_t vnodeQueryResultInterpolate(SQInfo* pQInfo, tFilePage** pDst, tFilePage** pDataSrc, int32_t numOfRows,
|
int32_t vnodeQueryResultInterpolate(SQInfo* pQInfo, tFilePage** pDst, tFilePage** pDataSrc, int32_t numOfRows,
|
||||||
int32_t* numOfInterpo);
|
int32_t* numOfInterpo);
|
||||||
void copyResToQueryResultBuf(SMeterQuerySupportObj* pSupporter, SQuery* pQuery);
|
void copyResToQueryResultBuf(STableQuerySupportObj* pSupporter, SQuery* pQuery);
|
||||||
|
|
||||||
void doSkipResults(SQueryRuntimeEnv* pRuntimeEnv);
|
void doSkipResults(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
void doFinalizeResult(SQueryRuntimeEnv* pRuntimeEnv);
|
void doFinalizeResult(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
int64_t getNumOfResult(SQueryRuntimeEnv* pRuntimeEnv);
|
int64_t getNumOfResult(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
|
|
||||||
void forwardIntervalQueryRange(SMeterQuerySupportObj* pSupporter, SQueryRuntimeEnv* pRuntimeEnv);
|
void forwardIntervalQueryRange(STableQuerySupportObj* pSupporter, SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
void forwardQueryStartPosition(SQueryRuntimeEnv* pRuntimeEnv);
|
void forwardQueryStartPosition(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
|
|
||||||
bool normalizedFirstQueryRange(bool dataInDisk, bool dataInCache, SMeterQuerySupportObj* pSupporter,
|
bool normalizedFirstQueryRange(bool dataInDisk, bool dataInCache, STableQuerySupportObj* pSupporter,
|
||||||
SPointInterpoSupporter* pPointInterpSupporter, int64_t* key);
|
SPointInterpoSupporter* pPointInterpSupporter, int64_t* key);
|
||||||
|
|
||||||
void pointInterpSupporterInit(SQuery* pQuery, SPointInterpoSupporter* pInterpoSupport);
|
void pointInterpSupporterInit(SQuery* pQuery, SPointInterpoSupporter* pInterpoSupport);
|
||||||
|
@ -165,21 +165,25 @@ void pointInterpSupporterDestroy(SPointInterpoSupporter* pPointInterpSupport);
|
||||||
void pointInterpSupporterSetData(SQInfo* pQInfo, SPointInterpoSupporter* pPointInterpSupport);
|
void pointInterpSupporterSetData(SQInfo* pQInfo, SPointInterpoSupporter* pPointInterpSupport);
|
||||||
|
|
||||||
int64_t loadRequiredBlockIntoMem(SQueryRuntimeEnv* pRuntimeEnv, SPositionInfo* position);
|
int64_t loadRequiredBlockIntoMem(SQueryRuntimeEnv* pRuntimeEnv, SPositionInfo* position);
|
||||||
int32_t doCloseAllOpenedResults(SMeterQuerySupportObj* pSupporter);
|
int32_t doCloseAllOpenedResults(STableQuerySupportObj* pSupporter);
|
||||||
void disableFunctForSuppleScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
void disableFunctForSuppleScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
||||||
void enableFunctForMasterScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
void enableFunctForMasterScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
||||||
|
|
||||||
int32_t mergeMetersResultToOneGroups(SMeterQuerySupportObj* pSupporter);
|
int32_t mergeMetersResultToOneGroups(STableQuerySupportObj* pSupporter);
|
||||||
void copyFromGroupBuf(SQInfo* pQInfo, SWindowResult* result);
|
void copyFromGroupBuf(SQInfo* pQInfo, SWindowResult* result);
|
||||||
|
|
||||||
SBlockInfo getBlockBasicInfo(SQueryRuntimeEnv* pRuntimeEnv, void* pBlock, int32_t blockType);
|
SBlockInfo getBlockBasicInfo(SQueryRuntimeEnv* pRuntimeEnv, void* pBlock, int32_t blockType);
|
||||||
SCacheBlock* getCacheDataBlock(SMeterObj* pMeterObj, SQueryRuntimeEnv* pRuntimeEnv, int32_t slot);
|
SCacheBlock* getCacheDataBlock(SMeterObj* pMeterObj, SQueryRuntimeEnv* pRuntimeEnv, int32_t slot);
|
||||||
|
|
||||||
void queryOnBlock(SMeterQuerySupportObj* pSupporter, int32_t blockStatus, SBlockInfo* pBlockBasicInfo, SMeterDataInfo* pDataHeadInfoEx, SField* pFields,
|
// void queryOnBlock(STableQuerySupportObj* pSupporter, int32_t blockStatus, SBlockInfo* pBlockBasicInfo,
|
||||||
__block_search_fn_t searchFn);
|
// SMeterDataInfo* pDataHeadInfoEx, SField* pFields,
|
||||||
|
// __block_search_fn_t searchFn);
|
||||||
|
|
||||||
int32_t vnodeFilterQualifiedMeters(SQInfo *pQInfo, int32_t vid, tSidSet *pSidSet, SMeterDataInfo *pMeterDataInfo,
|
void applyIntervalQueryOnBlock(STableQuerySupportObj* pSupporter, SMeterDataInfo* pMeterDataInfo,
|
||||||
int32_t *numOfMeters, SMeterDataInfo ***pReqMeterDataInfo);
|
SBlockInfo* pBlockInfo, SField* pFields, __block_search_fn_t searchFn);
|
||||||
|
|
||||||
|
int32_t vnodeFilterQualifiedMeters(SQInfo* pQInfo, int32_t vid, tSidSet* pSidSet, SMeterDataInfo* pMeterDataInfo,
|
||||||
|
int32_t* numOfMeters, SMeterDataInfo*** pReqMeterDataInfo);
|
||||||
int32_t vnodeGetVnodeHeaderFileIndex(int32_t* fid, SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
int32_t vnodeGetVnodeHeaderFileIndex(int32_t* fid, SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
||||||
|
|
||||||
int32_t createDataBlocksInfoEx(SMeterDataInfo** pMeterDataInfo, int32_t numOfMeters,
|
int32_t createDataBlocksInfoEx(SMeterDataInfo** pMeterDataInfo, int32_t numOfMeters,
|
||||||
|
@ -187,20 +191,20 @@ int32_t createDataBlocksInfoEx(SMeterDataInfo** pMeterDataInfo, int32_t numOfMet
|
||||||
int32_t* nAllocBlocksInfoSize, int64_t addr);
|
int32_t* nAllocBlocksInfoSize, int64_t addr);
|
||||||
void freeMeterBlockInfoEx(SMeterDataBlockInfoEx* pDataBlockInfoEx, int32_t len);
|
void freeMeterBlockInfoEx(SMeterDataBlockInfoEx* pDataBlockInfoEx, int32_t len);
|
||||||
|
|
||||||
void setExecutionContext(SMeterQuerySupportObj* pSupporter, SWindowResult* outputRes, int32_t meterIdx, int32_t groupIdx,
|
void setExecutionContext(STableQuerySupportObj* pSupporter, SWindowResult* outputRes, int32_t meterIdx,
|
||||||
SMeterQueryInfo* sqinfo);
|
int32_t groupIdx, SMeterQueryInfo* sqinfo);
|
||||||
int32_t setIntervalQueryExecutionContext(SMeterQuerySupportObj* pSupporter, int32_t meterIdx, SMeterQueryInfo* sqinfo);
|
int32_t setIntervalQueryExecutionContext(STableQuerySupportObj* pSupporter, int32_t meterIdx, SMeterQueryInfo* sqinfo);
|
||||||
void doGetAlignedIntervalQueryRangeImpl(SQuery *pQuery, int64_t pKey, int64_t keyFirst, int64_t keyLast,
|
void doGetAlignedIntervalQueryRangeImpl(SQuery* pQuery, int64_t pKey, int64_t keyFirst, int64_t keyLast,
|
||||||
int64_t *actualSkey, int64_t *actualEkey, int64_t *skey, int64_t *ekey);
|
int64_t* actualSkey, int64_t* actualEkey, int64_t* skey, int64_t* ekey);
|
||||||
|
|
||||||
int64_t getQueryStartPositionInCache(SQueryRuntimeEnv* pRuntimeEnv, int32_t* slot, int32_t* pos, bool ignoreQueryRange);
|
int64_t getQueryStartPositionInCache(SQueryRuntimeEnv* pRuntimeEnv, int32_t* slot, int32_t* pos, bool ignoreQueryRange);
|
||||||
int64_t getNextAccessedKeyInData(SQuery* pQuery, int64_t* pPrimaryCol, SBlockInfo* pBlockInfo, int32_t blockStatus);
|
int64_t getNextAccessedKeyInData(SQuery* pQuery, int64_t* pPrimaryCol, SBlockInfo* pBlockInfo, int32_t blockStatus);
|
||||||
|
|
||||||
int32_t getDataBlocksForMeters(SMeterQuerySupportObj* pSupporter, SQuery* pQuery, int32_t numOfMeters,
|
int32_t getDataBlocksForMeters(STableQuerySupportObj* pSupporter, SQuery* pQuery, int32_t numOfMeters,
|
||||||
const char* filePath, SMeterDataInfo** pMeterDataInfo, uint32_t* numOfBlocks);
|
const char* filePath, SMeterDataInfo** pMeterDataInfo, uint32_t* numOfBlocks);
|
||||||
int32_t LoadDatablockOnDemand(SCompBlock* pBlock, SField** pFields, uint8_t* blkStatus, SQueryRuntimeEnv* pRuntimeEnv,
|
int32_t LoadDatablockOnDemand(SCompBlock* pBlock, SField** pFields, uint8_t* blkStatus, SQueryRuntimeEnv* pRuntimeEnv,
|
||||||
int32_t fileIdx, int32_t slotIdx, __block_search_fn_t searchFn, bool onDemand);
|
int32_t fileIdx, int32_t slotIdx, __block_search_fn_t searchFn, bool onDemand);
|
||||||
int32_t vnodeGetHeaderFile(SQueryRuntimeEnv *pRuntimeEnv, int32_t fileIndex);
|
int32_t vnodeGetHeaderFile(SQueryRuntimeEnv* pRuntimeEnv, int32_t fileIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SMeterQueryInfo.
|
* Create SMeterQueryInfo.
|
||||||
|
@ -210,14 +214,14 @@ int32_t vnodeGetHeaderFile(SQueryRuntimeEnv *pRuntimeEnv, int32_t fileIndex);
|
||||||
* @param ekey
|
* @param ekey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SMeterQueryInfo* createMeterQueryInfo(SMeterQuerySupportObj *pSupporter, int32_t sid, TSKEY skey, TSKEY ekey);
|
SMeterQueryInfo* createMeterQueryInfo(STableQuerySupportObj* pSupporter, int32_t sid, TSKEY skey, TSKEY ekey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy meter query info
|
* Destroy meter query info
|
||||||
* @param pMeterQInfo
|
* @param pMeterQInfo
|
||||||
* @param numOfCols
|
* @param numOfCols
|
||||||
*/
|
*/
|
||||||
void destroyMeterQueryInfo(SMeterQueryInfo *pMeterQueryInfo, int32_t numOfCols);
|
void destroyMeterQueryInfo(SMeterQueryInfo* pMeterQueryInfo, int32_t numOfCols);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* change the meter query info for supplement scan
|
* change the meter query info for supplement scan
|
||||||
|
@ -225,7 +229,8 @@ void destroyMeterQueryInfo(SMeterQueryInfo *pMeterQueryInfo, int32_t numOfCols);
|
||||||
* @param skey
|
* @param skey
|
||||||
* @param ekey
|
* @param ekey
|
||||||
*/
|
*/
|
||||||
void changeMeterQueryInfoForSuppleQuery(SQueryDiskbasedResultBuf* pResultBuf, SMeterQueryInfo *pMeterQueryInfo, TSKEY skey, TSKEY ekey);
|
void changeMeterQueryInfoForSuppleQuery(SQueryDiskbasedResultBuf* pResultBuf, SMeterQueryInfo* pMeterQueryInfo,
|
||||||
|
TSKEY skey, TSKEY ekey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add the new allocated disk page to meter query info
|
* add the new allocated disk page to meter query info
|
||||||
|
@ -234,7 +239,8 @@ void changeMeterQueryInfoForSuppleQuery(SQueryDiskbasedResultBuf* pResultBuf, SM
|
||||||
* @param pMeterQueryInfo
|
* @param pMeterQueryInfo
|
||||||
* @param pSupporter
|
* @param pSupporter
|
||||||
*/
|
*/
|
||||||
tFilePage* addDataPageForMeterQueryInfo(SQuery* pQuery, SMeterQueryInfo *pMeterQueryInfo, SMeterQuerySupportObj *pSupporter);
|
tFilePage* addDataPageForMeterQueryInfo(SQuery* pQuery, SMeterQueryInfo* pMeterQueryInfo,
|
||||||
|
STableQuerySupportObj* pSupporter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save the query range data into SMeterQueryInfo
|
* save the query range data into SMeterQueryInfo
|
||||||
|
@ -258,7 +264,7 @@ void restoreIntervalQueryRange(SQueryRuntimeEnv* pRuntimeEnv, SMeterQueryInfo* p
|
||||||
* @param pSupporter
|
* @param pSupporter
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
void setIntervalQueryRange(SMeterQueryInfo *pMeterQueryInfo, SMeterQuerySupportObj* pSupporter, int64_t key);
|
void setIntervalQueryRange(SMeterQueryInfo* pMeterQueryInfo, STableQuerySupportObj* pSupporter, int64_t key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the meter data information
|
* set the meter data information
|
||||||
|
@ -275,15 +281,16 @@ void vnodeCheckIfDataExists(SQueryRuntimeEnv* pRuntimeEnv, SMeterObj* pMeterObj,
|
||||||
|
|
||||||
void displayInterResult(SData** pdata, SQuery* pQuery, int32_t numOfRows);
|
void displayInterResult(SData** pdata, SQuery* pQuery, int32_t numOfRows);
|
||||||
|
|
||||||
void vnodePrintQueryStatistics(SMeterQuerySupportObj* pSupporter);
|
void vnodePrintQueryStatistics(STableQuerySupportObj* pSupporter);
|
||||||
|
|
||||||
void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pOneOutputRes);
|
void clearTimeWindowResBuf(SQueryRuntimeEnv* pRuntimeEnv, SWindowResult* pOneOutputRes);
|
||||||
void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult* dst, const SWindowResult* src);
|
void copyTimeWindowResBuf(SQueryRuntimeEnv* pRuntimeEnv, SWindowResult* dst, const SWindowResult* src);
|
||||||
|
|
||||||
int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRuntimeEnv, int32_t size, int32_t threshold, int16_t type);
|
int32_t initWindowResInfo(SWindowResInfo* pWindowResInfo, SQueryRuntimeEnv* pRuntimeEnv, int32_t size,
|
||||||
|
int32_t threshold, int16_t type);
|
||||||
|
|
||||||
void cleanupTimeWindowInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRuntimeEnv);
|
void cleanupTimeWindowInfo(SWindowResInfo* pWindowResInfo, SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
void resetTimeWindowInfo(SQueryRuntimeEnv *pRuntimeEnv, SWindowResInfo* pWindowResInfo);
|
void resetTimeWindowInfo(SQueryRuntimeEnv* pRuntimeEnv, SWindowResInfo* pWindowResInfo);
|
||||||
void clearClosedTimeWindow(SQueryRuntimeEnv* pRuntimeEnv);
|
void clearClosedTimeWindow(SQueryRuntimeEnv* pRuntimeEnv);
|
||||||
int32_t numOfClosedTimeWindow(SWindowResInfo* pWindowResInfo);
|
int32_t numOfClosedTimeWindow(SWindowResInfo* pWindowResInfo);
|
||||||
void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
|
void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
|
||||||
|
|
|
@ -101,7 +101,6 @@ typedef struct SWindowStatus {
|
||||||
|
|
||||||
typedef struct SWindowResult {
|
typedef struct SWindowResult {
|
||||||
uint16_t numOfRows;
|
uint16_t numOfRows;
|
||||||
int16_t nAlloc;
|
|
||||||
SPosInfo pos; // Position of current result in disk-based output buffer
|
SPosInfo pos; // Position of current result in disk-based output buffer
|
||||||
SResultInfo* resultInfo; // For each result column, there is a resultInfo
|
SResultInfo* resultInfo; // For each result column, there is a resultInfo
|
||||||
STimeWindow window; // The time window that current result covers.
|
STimeWindow window; // The time window that current result covers.
|
||||||
|
@ -191,8 +190,8 @@ typedef struct SMeterQueryInfo {
|
||||||
int64_t skey;
|
int64_t skey;
|
||||||
int64_t ekey;
|
int64_t ekey;
|
||||||
int32_t numOfRes;
|
int32_t numOfRes;
|
||||||
int32_t reverseIndex; // reversed output indicator, start from (numOfRes-1)
|
// int32_t reverseIndex; // reversed output indicator, start from (numOfRes-1)
|
||||||
int16_t reverseFillRes; // denote if reverse fill the results in supplementary scan required or not
|
// int16_t reverseFillRes; // denote if reverse fill the results in supplementary scan required or not
|
||||||
int16_t queryRangeSet; // denote if the query range is set, only available for interval query
|
int16_t queryRangeSet; // denote if the query range is set, only available for interval query
|
||||||
int16_t lastResRows;
|
int16_t lastResRows;
|
||||||
int64_t tag;
|
int64_t tag;
|
||||||
|
@ -213,7 +212,7 @@ typedef struct SMeterDataInfo {
|
||||||
SMeterQueryInfo* pMeterQInfo;
|
SMeterQueryInfo* pMeterQInfo;
|
||||||
} SMeterDataInfo;
|
} SMeterDataInfo;
|
||||||
|
|
||||||
typedef struct SMeterQuerySupportObj {
|
typedef struct STableQuerySupportObj {
|
||||||
void* pMetersHashTable; // meter table hash list
|
void* pMetersHashTable; // meter table hash list
|
||||||
|
|
||||||
SMeterSidExtInfo** pMeterSidExtInfo;
|
SMeterSidExtInfo** pMeterSidExtInfo;
|
||||||
|
@ -248,7 +247,7 @@ typedef struct SMeterQuerySupportObj {
|
||||||
SMeterDataInfo* pMeterDataInfo;
|
SMeterDataInfo* pMeterDataInfo;
|
||||||
|
|
||||||
TSKEY* tsList;
|
TSKEY* tsList;
|
||||||
} SMeterQuerySupportObj;
|
} STableQuerySupportObj;
|
||||||
|
|
||||||
typedef struct _qinfo {
|
typedef struct _qinfo {
|
||||||
uint64_t signature;
|
uint64_t signature;
|
||||||
|
@ -274,18 +273,18 @@ typedef struct _qinfo {
|
||||||
SMeterObj* pObj;
|
SMeterObj* pObj;
|
||||||
sem_t dataReady;
|
sem_t dataReady;
|
||||||
|
|
||||||
SMeterQuerySupportObj* pMeterQuerySupporter;
|
STableQuerySupportObj* pTableQuerySupporter;
|
||||||
int (*fp)(SMeterObj*, SQuery*);
|
int (*fp)(SMeterObj*, SQuery*);
|
||||||
} SQInfo;
|
} SQInfo;
|
||||||
|
|
||||||
int32_t vnodeQuerySingleTablePrepare(SQInfo* pQInfo, SMeterObj* pMeterObj, SMeterQuerySupportObj* pSMultiMeterObj,
|
int32_t vnodeQueryTablePrepare(SQInfo* pQInfo, SMeterObj* pMeterObj, STableQuerySupportObj* pSMultiMeterObj,
|
||||||
void* param);
|
void* param);
|
||||||
|
|
||||||
void vnodeQueryFreeQInfoEx(SQInfo* pQInfo);
|
void vnodeQueryFreeQInfoEx(SQInfo* pQInfo);
|
||||||
|
|
||||||
bool vnodeParametersSafetyCheck(SQuery* pQuery);
|
bool vnodeParametersSafetyCheck(SQuery* pQuery);
|
||||||
|
|
||||||
int32_t vnodeMultiMeterQueryPrepare(SQInfo* pQInfo, SQuery* pQuery, void* param);
|
int32_t vnodeSTableQueryPrepare(SQInfo* pQInfo, SQuery* pQuery, void* param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decrease the numofQuery of each table that is queried, enable the
|
* decrease the numofQuery of each table that is queried, enable the
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,7 +27,8 @@
|
||||||
#include "vnodeQueryImpl.h"
|
#include "vnodeQueryImpl.h"
|
||||||
|
|
||||||
#define ALL_CACHE_BLOCKS_CHECKED(q) \
|
#define ALL_CACHE_BLOCKS_CHECKED(q) \
|
||||||
(((q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q)) || ((q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q))))
|
(((q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q)) || \
|
||||||
|
((q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q))))
|
||||||
|
|
||||||
#define FORWARD_CACHE_BLOCK_CHECK_SLOT(slot, step, maxblocks) (slot) = ((slot) + (step) + (maxblocks)) % (maxblocks);
|
#define FORWARD_CACHE_BLOCK_CHECK_SLOT(slot, step, maxblocks) (slot) = ((slot) + (step) + (maxblocks)) % (maxblocks);
|
||||||
|
|
||||||
|
@ -47,23 +48,10 @@ static bool isGroupbyEachTable(SSqlGroupbyExpr *pGroupbyExpr, tSidSet *pSidset)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doCheckWithPrevQueryRange(SQInfo *pQInfo, TSKEY nextKey, SMeterDataInfo *pMeterInfo) {
|
static bool doCheckWithPrevQueryRange(SQuery *pQuery, TSKEY nextKey) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
|
||||||
SQuery * pQuery = &pQInfo->query;
|
|
||||||
SMeterObj * pMeterObj = pMeterInfo->pMeterObj;
|
|
||||||
|
|
||||||
/* no data for current query */
|
|
||||||
if ((nextKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
if ((nextKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||||
(nextKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
(nextKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||||
if (((nextKey > pSupporter->rawEKey) && QUERY_IS_ASC_QUERY(pQuery)) ||
|
|
||||||
((nextKey < pSupporter->rawEKey) && (!QUERY_IS_ASC_QUERY(pQuery)))) {
|
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, no data qualified in block, ignore", pQInfo, pMeterObj->vnode,
|
|
||||||
pMeterObj->sid, pMeterObj->meterId);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else { // in case of interval query, forward the query range
|
|
||||||
setIntervalQueryRange(pMeterInfo->pMeterQInfo, pSupporter, nextKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,7 +74,7 @@ static void setStartPositionForCacheBlock(SQuery *pQuery, SCacheBlock *pBlock, b
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
|
static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
SQuery* pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQuery->numOfOutputCols; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfOutputCols; ++i) {
|
||||||
SResultInfo *pResInfo = GET_RES_INFO(&pRuntimeEnv->pCtx[i]);
|
SResultInfo *pResInfo = GET_RES_INFO(&pRuntimeEnv->pCtx[i]);
|
||||||
|
@ -98,8 +86,8 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
|
|
||||||
static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pQInfo->pMeterQuerySupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pQInfo->pTableQuerySupporter->runtimeEnv;
|
||||||
|
|
||||||
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
||||||
|
|
||||||
|
@ -132,7 +120,8 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
pRuntimeEnv->pMeterObj = pMeterObj;
|
pRuntimeEnv->pMeterObj = pMeterObj;
|
||||||
|
|
||||||
if (pMeterInfo[k].pMeterQInfo == NULL) {
|
if (pMeterInfo[k].pMeterQInfo == NULL) {
|
||||||
pMeterInfo[k].pMeterQInfo = createMeterQueryInfo(pSupporter, pMeterObj->sid, pSupporter->rawSKey, pSupporter->rawEKey);
|
pMeterInfo[k].pMeterQInfo =
|
||||||
|
createMeterQueryInfo(pSupporter, pMeterObj->sid, pSupporter->rawSKey, pSupporter->rawEKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMeterInfo[k].pMeterObj == NULL) { // no data in disk for this meter, set its pointer
|
if (pMeterInfo[k].pMeterObj == NULL) { // no data in disk for this meter, set its pointer
|
||||||
|
@ -154,29 +143,18 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
vnodeUpdateQueryColumnIndex(pQuery, pMeterObj);
|
vnodeUpdateQueryColumnIndex(pQuery, pMeterObj);
|
||||||
vnodeUpdateFilterColumnIndex(pQuery);
|
vnodeUpdateFilterColumnIndex(pQuery);
|
||||||
|
|
||||||
if (pQuery->intervalTime == 0) {
|
|
||||||
if ((pQuery->lastKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
if ((pQuery->lastKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||||
(pQuery->lastKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
(pQuery->lastKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||||
dTrace(
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, query completed, ignore data in cache. qrange:%" PRId64 "-%" PRId64
|
||||||
"QInfo:%p vid:%d sid:%d id:%s, query completed, ignore data in cache. qrange:%" PRId64 "-%" PRId64 ", "
|
", lastKey:%" PRId64,
|
||||||
"lastKey:%" PRId64,
|
|
||||||
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey,
|
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey,
|
||||||
pQuery->lastKey);
|
pQuery->lastKey);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setExecutionContext(pSupporter, pRuntimeEnv->windowResInfo.pResult, k, pMeterInfo[k].groupIdx, pMeterQueryInfo);
|
qTrace("QInfo:%p vid:%d sid:%d id:%s, query in cache, qrange:%" PRId64 "-%" PRId64 ", lastKey:%" PRId64, pQInfo,
|
||||||
} else {
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey, pQuery->lastKey);
|
||||||
int32_t ret = setIntervalQueryExecutionContext(pSupporter, k, pMeterQueryInfo);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
|
||||||
pQInfo->killed = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qTrace("QInfo:%p vid:%d sid:%d id:%s, query in cache, qrange:%" PRId64 "-%" PRId64 ", lastKey:%" PRId64, pQInfo, pMeterObj->vnode,
|
|
||||||
pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey, pQuery->lastKey);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find the appropriated start position in cache
|
* find the appropriated start position in cache
|
||||||
|
@ -186,7 +164,7 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
* should be ignored (the fourth parameter).
|
* should be ignored (the fourth parameter).
|
||||||
*/
|
*/
|
||||||
TSKEY nextKey = getQueryStartPositionInCache(pRuntimeEnv, &pQuery->slot, &pQuery->pos, true);
|
TSKEY nextKey = getQueryStartPositionInCache(pRuntimeEnv, &pQuery->slot, &pQuery->pos, true);
|
||||||
if (nextKey < 0) {
|
if (nextKey < 0 || !doCheckWithPrevQueryRange(pQuery, nextKey)) {
|
||||||
qTrace("QInfo:%p vid:%d sid:%d id:%s, no data qualified in cache, cache blocks:%d, lastKey:%" PRId64, pQInfo,
|
qTrace("QInfo:%p vid:%d sid:%d id:%s, no data qualified in cache, cache blocks:%d, lastKey:%" PRId64, pQInfo,
|
||||||
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->numOfBlocks, pQuery->lastKey);
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->numOfBlocks, pQuery->lastKey);
|
||||||
continue;
|
continue;
|
||||||
|
@ -199,10 +177,6 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doCheckWithPrevQueryRange(pQInfo, nextKey, &pMeterInfo[k])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool firstCheckSlot = true;
|
bool firstCheckSlot = true;
|
||||||
SCacheInfo *pCacheInfo = (SCacheInfo *)pMeterObj->pCache;
|
SCacheInfo *pCacheInfo = (SCacheInfo *)pMeterObj->pCache;
|
||||||
|
|
||||||
|
@ -224,14 +198,29 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
|
|
||||||
setStartPositionForCacheBlock(pQuery, pBlock, &firstCheckSlot);
|
setStartPositionForCacheBlock(pQuery, pBlock, &firstCheckSlot);
|
||||||
|
|
||||||
TSKEY* primaryKeys = (TSKEY*) pRuntimeEnv->primaryColBuffer->data;
|
TSKEY *primaryKeys = (TSKEY *)pRuntimeEnv->primaryColBuffer->data;
|
||||||
|
TSKEY key = primaryKeys[pQuery->pos];
|
||||||
|
|
||||||
// in handling file data block, the timestamp range validation is done during fetching candidate file blocks
|
// in handling file data block, the timestamp range validation is done during fetching candidate file blocks
|
||||||
if ((primaryKeys[pQuery->pos] > pSupporter->rawEKey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
if ((key > pSupporter->rawEKey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||||
(primaryKeys[pQuery->pos] < pSupporter->rawEKey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
(key < pSupporter->rawEKey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pQuery->intervalTime == 0) {
|
||||||
|
setExecutionContext(pSupporter, pRuntimeEnv->windowResInfo.pResult, k, pMeterInfo[k].groupIdx,
|
||||||
|
pMeterQueryInfo);
|
||||||
|
} else {
|
||||||
|
int32_t ret = setIntervalQueryExecutionContext(pSupporter, k, pMeterQueryInfo);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
pQInfo->killed = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qTrace("QInfo:%p vid:%d sid:%d id:%s, query in cache, qrange:%" PRId64 "-%" PRId64 ", lastKey:%" PRId64, pQInfo,
|
||||||
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey, pQuery->lastKey);
|
||||||
|
|
||||||
// only record the key on last block
|
// only record the key on last block
|
||||||
SET_CACHE_BLOCK_FLAG(pRuntimeEnv->blockStatus);
|
SET_CACHE_BLOCK_FLAG(pRuntimeEnv->blockStatus);
|
||||||
SBlockInfo binfo = getBlockBasicInfo(pRuntimeEnv, pBlock, BLK_CACHE_BLOCK);
|
SBlockInfo binfo = getBlockBasicInfo(pRuntimeEnv, pBlock, BLK_CACHE_BLOCK);
|
||||||
|
@ -241,7 +230,7 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
pRuntimeEnv->blockStatus);
|
pRuntimeEnv->blockStatus);
|
||||||
|
|
||||||
totalBlocks++;
|
totalBlocks++;
|
||||||
queryOnBlock(pSupporter, pRuntimeEnv->blockStatus, &binfo, &pMeterInfo[k], NULL, searchFn);
|
applyIntervalQueryOnBlock(pSupporter, &pMeterInfo[k], &binfo, NULL, searchFn);
|
||||||
|
|
||||||
if (ALL_CACHE_BLOCKS_CHECKED(pQuery)) {
|
if (ALL_CACHE_BLOCKS_CHECKED(pQuery)) {
|
||||||
break;
|
break;
|
||||||
|
@ -266,7 +255,7 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterInfo) {
|
||||||
|
|
||||||
static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo) {
|
static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo) {
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
SMeterDataBlockInfoEx *pDataBlockInfoEx = NULL;
|
SMeterDataBlockInfoEx *pDataBlockInfoEx = NULL;
|
||||||
int32_t nAllocBlocksInfoSize = 0;
|
int32_t nAllocBlocksInfoSize = 0;
|
||||||
|
@ -275,7 +264,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
__block_search_fn_t searchFn = vnodeSearchKeyFunc[pTempMeter->searchAlgorithm];
|
__block_search_fn_t searchFn = vnodeSearchKeyFunc[pTempMeter->searchAlgorithm];
|
||||||
|
|
||||||
int32_t vnodeId = pTempMeter->vnode;
|
int32_t vnodeId = pTempMeter->vnode;
|
||||||
SQueryFilesInfo* pVnodeFileInfo = &pRuntimeEnv->vnodeFileInfo;
|
SQueryFilesInfo *pVnodeFileInfo = &pRuntimeEnv->vnodeFileInfo;
|
||||||
|
|
||||||
dTrace("QInfo:%p start to check data blocks in %d files", pQInfo, pVnodeFileInfo->numOfFiles);
|
dTrace("QInfo:%p start to check data blocks in %d files", pQInfo, pVnodeFileInfo->numOfFiles);
|
||||||
|
|
||||||
|
@ -383,8 +372,8 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
stimeUnit = taosGetTimestampMs();
|
stimeUnit = taosGetTimestampMs();
|
||||||
} else if ((j % TRACE_OUTPUT_BLOCK_CNT) == 0) {
|
} else if ((j % TRACE_OUTPUT_BLOCK_CNT) == 0) {
|
||||||
etimeUnit = taosGetTimestampMs();
|
etimeUnit = taosGetTimestampMs();
|
||||||
dTrace("QInfo:%p load and check %" PRId64 " blocks, and continue. elapsed:%" PRId64 " ms", pQInfo, TRACE_OUTPUT_BLOCK_CNT,
|
dTrace("QInfo:%p load and check %" PRId64 " blocks, and continue. elapsed:%" PRId64 " ms", pQInfo,
|
||||||
etimeUnit - stimeUnit);
|
TRACE_OUTPUT_BLOCK_CNT, etimeUnit - stimeUnit);
|
||||||
stimeUnit = taosGetTimestampMs();
|
stimeUnit = taosGetTimestampMs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,29 +387,16 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
|
|
||||||
restoreIntervalQueryRange(pRuntimeEnv, pMeterQueryInfo);
|
restoreIntervalQueryRange(pRuntimeEnv, pMeterQueryInfo);
|
||||||
|
|
||||||
if (pQuery->intervalTime == 0) { // normal query
|
|
||||||
if ((pQuery->lastKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
if ((pQuery->lastKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||||
(pQuery->lastKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
(pQuery->lastKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||||
qTrace(
|
qTrace("QInfo:%p vid:%d sid:%d id:%s, query completed, no need to scan this data block. qrange:%" PRId64
|
||||||
"QInfo:%p vid:%d sid:%d id:%s, query completed, no need to scan this data block. qrange:%" PRId64 "-%" PRId64 ", "
|
"-%" PRId64 ", lastKey:%" PRId64,
|
||||||
"lastKey:%" PRId64,
|
|
||||||
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey,
|
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey,
|
||||||
pQuery->lastKey);
|
pQuery->lastKey);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setExecutionContext(pSupporter, pRuntimeEnv->windowResInfo.pResult, pOneMeterDataInfo->meterOrderIdx,
|
|
||||||
pOneMeterDataInfo->groupIdx, pMeterQueryInfo);
|
|
||||||
} else if (pQuery->intervalTime > 0 && pQuery->slidingTime == -1){ // interval query
|
|
||||||
ret = setIntervalQueryExecutionContext(pSupporter, pOneMeterDataInfo->meterOrderIdx, pMeterQueryInfo);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
|
||||||
tfree(pReqMeterDataInfo); // error code has been set
|
|
||||||
pQInfo->killed = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SCompBlock *pBlock = pInfoEx->pBlock.compBlock;
|
SCompBlock *pBlock = pInfoEx->pBlock.compBlock;
|
||||||
bool ondemandLoad = onDemandLoadDatablock(pQuery, pMeterQueryInfo->queryRangeSet);
|
bool ondemandLoad = onDemandLoadDatablock(pQuery, pMeterQueryInfo->queryRangeSet);
|
||||||
int32_t ret = LoadDatablockOnDemand(pBlock, &pInfoEx->pBlock.fields, &pRuntimeEnv->blockStatus, pRuntimeEnv,
|
int32_t ret = LoadDatablockOnDemand(pBlock, &pInfoEx->pBlock.fields, &pRuntimeEnv->blockStatus, pRuntimeEnv,
|
||||||
|
@ -438,7 +414,10 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
|
|
||||||
if (IS_DATA_BLOCK_LOADED(pRuntimeEnv->blockStatus) && needPrimaryTimestampCol(pQuery, &binfo)) {
|
if (IS_DATA_BLOCK_LOADED(pRuntimeEnv->blockStatus) && needPrimaryTimestampCol(pQuery, &binfo)) {
|
||||||
nextKey = primaryKeys[pQuery->pos];
|
nextKey = primaryKeys[pQuery->pos];
|
||||||
if (!doCheckWithPrevQueryRange(pQInfo, nextKey, pOneMeterDataInfo)) {
|
|
||||||
|
if (!doCheckWithPrevQueryRange(pQuery, nextKey)) {
|
||||||
|
qTrace("QInfo:%p vid:%d sid:%d id:%s, no data qualified in data file, lastKey:%" PRId64, pQInfo,
|
||||||
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->numOfBlocks, pQuery->lastKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -447,7 +426,10 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
(pBlock->keyFirst >= pQuery->ekey && pBlock->keyLast <= pQuery->lastKey && !QUERY_IS_ASC_QUERY(pQuery)));
|
(pBlock->keyFirst >= pQuery->ekey && pBlock->keyLast <= pQuery->lastKey && !QUERY_IS_ASC_QUERY(pQuery)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQuery->intervalTime > 0 && pQuery->slidingTime > 0) {
|
if (pQuery->intervalTime == 0) {
|
||||||
|
setExecutionContext(pSupporter, pRuntimeEnv->windowResInfo.pResult, pOneMeterDataInfo->meterOrderIdx,
|
||||||
|
pOneMeterDataInfo->groupIdx, pMeterQueryInfo);
|
||||||
|
} else /* if (pQuery->intervalTime > 0)*/ { // interval query
|
||||||
setIntervalQueryRange(pMeterQueryInfo, pSupporter, nextKey);
|
setIntervalQueryRange(pMeterQueryInfo, pSupporter, nextKey);
|
||||||
|
|
||||||
ret = setIntervalQueryExecutionContext(pSupporter, pOneMeterDataInfo->meterOrderIdx, pMeterQueryInfo);
|
ret = setIntervalQueryExecutionContext(pSupporter, pOneMeterDataInfo->meterOrderIdx, pMeterQueryInfo);
|
||||||
|
@ -458,7 +440,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queryOnBlock(pSupporter, pRuntimeEnv->blockStatus, &binfo, pOneMeterDataInfo, pInfoEx->pBlock.fields, searchFn);
|
applyIntervalQueryOnBlock(pSupporter, pOneMeterDataInfo, &binfo, pInfoEx->pBlock.fields, searchFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pReqMeterDataInfo);
|
tfree(pReqMeterDataInfo);
|
||||||
|
@ -481,7 +463,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
|
||||||
|
|
||||||
static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *dataInCache, int32_t index,
|
static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *dataInCache, int32_t index,
|
||||||
int32_t start) {
|
int32_t start) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
|
|
||||||
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
|
@ -497,8 +479,8 @@ static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *
|
||||||
|
|
||||||
vnodeSetTagValueInParam(pSupporter->pSidSet, pRuntimeEnv, pMeterSidExtInfo[index]);
|
vnodeSetTagValueInParam(pSupporter->pSidSet, pRuntimeEnv, pMeterSidExtInfo[index]);
|
||||||
|
|
||||||
dTrace("QInfo:%p query on (%d): vid:%d sid:%d meterId:%s, qrange:%" PRId64 "-%" PRId64, pQInfo, index - start, pMeterObj->vnode,
|
dTrace("QInfo:%p query on (%d): vid:%d sid:%d meterId:%s, qrange:%" PRId64 "-%" PRId64, pQInfo, index - start,
|
||||||
pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey);
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey);
|
||||||
|
|
||||||
pQInfo->pObj = pMeterObj;
|
pQInfo->pObj = pMeterObj;
|
||||||
pQuery->lastKey = pQuery->skey;
|
pQuery->lastKey = pQuery->skey;
|
||||||
|
@ -511,8 +493,8 @@ static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *
|
||||||
|
|
||||||
// data in file or cache is not qualified for the query. abort
|
// data in file or cache is not qualified for the query. abort
|
||||||
if (!(dataInCache || dataInDisk)) {
|
if (!(dataInCache || dataInDisk)) {
|
||||||
dTrace("QInfo:%p vid:%d sid:%d meterId:%s, qrange:%" PRId64 "-%" PRId64 ", nores, %p", pQInfo, pMeterObj->vnode, pMeterObj->sid,
|
dTrace("QInfo:%p vid:%d sid:%d meterId:%s, qrange:%" PRId64 "-%" PRId64 ", nores, %p", pQInfo, pMeterObj->vnode,
|
||||||
pMeterObj->meterId, pQuery->skey, pQuery->ekey, pQuery);
|
pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey, pQuery);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +518,7 @@ static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *
|
||||||
|
|
||||||
static int64_t doCheckMetersInGroup(SQInfo *pQInfo, int32_t index, int32_t start) {
|
static int64_t doCheckMetersInGroup(SQInfo *pQInfo, int32_t index, int32_t start) {
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
|
|
||||||
bool dataInDisk = true;
|
bool dataInDisk = true;
|
||||||
|
@ -591,7 +573,7 @@ static int64_t doCheckMetersInGroup(SQInfo *pQInfo, int32_t index, int32_t start
|
||||||
* @param pQInfo
|
* @param pQInfo
|
||||||
*/
|
*/
|
||||||
static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
|
|
||||||
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
SMeterSidExtInfo **pMeterSidExtInfo = pSupporter->pMeterSidExtInfo;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
|
@ -611,8 +593,8 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
int32_t end = pSids->starterPos[pSupporter->subgroupIdx + 1] - 1;
|
int32_t end = pSids->starterPos[pSupporter->subgroupIdx + 1] - 1;
|
||||||
|
|
||||||
if (isFirstLastRowQuery(pQuery)) {
|
if (isFirstLastRowQuery(pQuery)) {
|
||||||
dTrace("QInfo:%p last_row query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid,
|
dTrace("QInfo:%p last_row query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid, pSids->numOfSubSet,
|
||||||
pSids->numOfSubSet, pSupporter->subgroupIdx);
|
pSupporter->subgroupIdx);
|
||||||
|
|
||||||
TSKEY key = -1;
|
TSKEY key = -1;
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
|
@ -644,8 +626,8 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
int64_t num = doCheckMetersInGroup(pQInfo, index, start);
|
int64_t num = doCheckMetersInGroup(pQInfo, index, start);
|
||||||
assert(num >= 0);
|
assert(num >= 0);
|
||||||
} else {
|
} else {
|
||||||
dTrace("QInfo:%p interp query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid,
|
dTrace("QInfo:%p interp query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, vid, pSids->numOfSubSet,
|
||||||
pSids->numOfSubSet, pSupporter->subgroupIdx);
|
pSupporter->subgroupIdx);
|
||||||
|
|
||||||
for (int32_t k = start; k <= end; ++k) {
|
for (int32_t k = start; k <= end; ++k) {
|
||||||
if (isQueryKilled(pQuery)) {
|
if (isQueryKilled(pQuery)) {
|
||||||
|
@ -704,8 +686,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSKEY skey = pQInfo->pTableQuerySupporter->pMeterSidExtInfo[k]->key;
|
||||||
TSKEY skey = pQInfo->pMeterQuerySupporter->pMeterSidExtInfo[k]->key;
|
|
||||||
if (skey > 0) {
|
if (skey > 0) {
|
||||||
pQuery->skey = skey;
|
pQuery->skey = skey;
|
||||||
}
|
}
|
||||||
|
@ -773,7 +754,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
pQuery->ekey = pSupporter->rawEKey;
|
pQuery->ekey = pSupporter->rawEKey;
|
||||||
pSupporter->meterIdx++;
|
pSupporter->meterIdx++;
|
||||||
|
|
||||||
pQInfo->pMeterQuerySupporter->pMeterSidExtInfo[k]->key = pQuery->lastKey;
|
pQInfo->pTableQuerySupporter->pMeterSidExtInfo[k]->key = pQuery->lastKey;
|
||||||
|
|
||||||
// if the buffer is full or group by each table, we need to jump out of the loop
|
// if the buffer is full or group by each table, we need to jump out of the loop
|
||||||
if (Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL) ||
|
if (Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL) ||
|
||||||
|
@ -789,7 +770,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
assert(!Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL));
|
assert(!Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL));
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
pQInfo->pMeterQuerySupporter->pMeterSidExtInfo[k]->key = pQuery->lastKey;
|
pQInfo->pTableQuerySupporter->pMeterSidExtInfo[k]->key = pQuery->lastKey;
|
||||||
// buffer is full, wait for the next round to retrieve data from current meter
|
// buffer is full, wait for the next round to retrieve data from current meter
|
||||||
assert(Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL));
|
assert(Q_STATUS_EQUAL(pQuery->over, QUERY_RESBUF_FULL));
|
||||||
break;
|
break;
|
||||||
|
@ -819,10 +800,10 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
||||||
SWindowResInfo* pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pWindowResInfo->size; ++i) {
|
for (int32_t i = 0; i < pWindowResInfo->size; ++i) {
|
||||||
SWindowStatus* pStatus = &pWindowResInfo->pResult[i].status;
|
SWindowStatus *pStatus = &pWindowResInfo->pResult[i].status;
|
||||||
pStatus->closed = true; // enable return all results for group by normal columns
|
pStatus->closed = true; // enable return all results for group by normal columns
|
||||||
|
|
||||||
SWindowResult *pResult = &pWindowResInfo->pResult[i];
|
SWindowResult *pResult = &pWindowResInfo->pResult[i];
|
||||||
|
@ -831,7 +812,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pQInfo->pMeterQuerySupporter->subgroupIdx = 0;
|
pQInfo->pTableQuerySupporter->subgroupIdx = 0;
|
||||||
pQuery->pointsRead = 0;
|
pQuery->pointsRead = 0;
|
||||||
copyFromGroupBuf(pQInfo, pWindowResInfo->pResult);
|
copyFromGroupBuf(pQInfo, pWindowResInfo->pResult);
|
||||||
}
|
}
|
||||||
|
@ -842,12 +823,12 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
|
||||||
dTrace(
|
dTrace(
|
||||||
"QInfo %p vid:%d, numOfMeters:%d, index:%d, numOfGroups:%d, %d points returned, totalRead:%d totalReturn:%d,"
|
"QInfo %p vid:%d, numOfMeters:%d, index:%d, numOfGroups:%d, %d points returned, totalRead:%d totalReturn:%d,"
|
||||||
"next skey:%" PRId64 ", offset:%" PRId64,
|
"next skey:%" PRId64 ", offset:%" PRId64,
|
||||||
pQInfo, vid, pSids->numOfSids, pSupporter->meterIdx, pSids->numOfSubSet, pQuery->pointsRead,
|
pQInfo, vid, pSids->numOfSids, pSupporter->meterIdx, pSids->numOfSubSet, pQuery->pointsRead, pQInfo->pointsRead,
|
||||||
pQInfo->pointsRead, pQInfo->pointsReturned, pQuery->skey, pQuery->limit.offset);
|
pQInfo->pointsReturned, pQuery->skey, pQuery->limit.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doOrderedScan(SQInfo *pQInfo) {
|
static void doOrderedScan(SQInfo *pQInfo) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
|
|
||||||
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
||||||
|
@ -867,17 +848,16 @@ static void doOrderedScan(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupMeterQueryInfoForSupplementQuery(SMeterQuerySupportObj *pSupporter) {
|
static void setupMeterQueryInfoForSupplementQuery(STableQuerySupportObj *pSupporter) {
|
||||||
for (int32_t i = 0; i < pSupporter->numOfMeters; ++i) {
|
for (int32_t i = 0; i < pSupporter->numOfMeters; ++i) {
|
||||||
SMeterQueryInfo *pMeterQueryInfo = pSupporter->pMeterDataInfo[i].pMeterQInfo;
|
SMeterQueryInfo * pMeterQueryInfo = pSupporter->pMeterDataInfo[i].pMeterQInfo;
|
||||||
SQueryDiskbasedResultBuf* pResultBuf = pSupporter->runtimeEnv.pResultBuf;
|
SQueryDiskbasedResultBuf *pResultBuf = pSupporter->runtimeEnv.pResultBuf;
|
||||||
|
|
||||||
changeMeterQueryInfoForSuppleQuery(pResultBuf, pMeterQueryInfo, pSupporter->rawSKey, pSupporter->rawEKey);
|
changeMeterQueryInfoForSuppleQuery(pResultBuf, pMeterQueryInfo, pSupporter->rawSKey, pSupporter->rawEKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doMultiMeterSupplementaryScan(SQInfo *pQInfo) {
|
static void doMultiMeterSupplementaryScan(SQInfo *pQInfo) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
|
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
|
@ -898,7 +878,9 @@ static void doMultiMeterSupplementaryScan(SQInfo *pQInfo) {
|
||||||
setupMeterQueryInfoForSupplementQuery(pSupporter);
|
setupMeterQueryInfoForSupplementQuery(pSupporter);
|
||||||
|
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
|
|
||||||
doOrderedScan(pQInfo);
|
doOrderedScan(pQInfo);
|
||||||
|
|
||||||
int64_t et = taosGetTimestampMs();
|
int64_t et = taosGetTimestampMs();
|
||||||
dTrace("QInfo:%p supplementary scan completed, elapsed time: %lldms", pQInfo, et - st);
|
dTrace("QInfo:%p supplementary scan completed, elapsed time: %lldms", pQInfo, et - st);
|
||||||
|
|
||||||
|
@ -917,8 +899,8 @@ static void doMultiMeterSupplementaryScan(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
|
static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQueryRuntimeEnv* pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
|
|
||||||
if (pSupporter->subgroupIdx > 0) {
|
if (pSupporter->subgroupIdx > 0) {
|
||||||
|
@ -954,8 +936,8 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, group:%d", pQInfo, pSupporter->rawSKey, pSupporter->rawEKey,
|
dTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, group:%d", pQInfo, pSupporter->rawSKey,
|
||||||
pQuery->order.order, pSupporter->pSidSet->numOfSubSet);
|
pSupporter->rawEKey, pQuery->order.order, pSupporter->pSidSet->numOfSubSet);
|
||||||
|
|
||||||
dTrace("QInfo:%p main query scan start", pQInfo);
|
dTrace("QInfo:%p main query scan start", pQInfo);
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
|
@ -965,9 +947,18 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
|
||||||
pQuery->order.order ^ 1);
|
pQuery->order.order ^ 1);
|
||||||
|
|
||||||
// failed to save all intermediate results into disk, abort further query processing
|
// failed to save all intermediate results into disk, abort further query processing
|
||||||
if (doCloseAllOpenedResults(pSupporter) != TSDB_CODE_SUCCESS) {
|
// if (doCloseAllOpenedResults(pSupporter) != TSDB_CODE_SUCCESS) {
|
||||||
dError("QInfo:%p failed to save intermediate results, abort further query processing", pQInfo);
|
// dError("QInfo:%p failed to save intermediate results, abort further query processing", pQInfo);
|
||||||
return;
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (pQuery->intervalTime > 0) {
|
||||||
|
for (int32_t i = 0; i < pSupporter->numOfMeters; ++i) {
|
||||||
|
SMeterQueryInfo *pMeterQueryInfo = pSupporter->pMeterDataInfo[i].pMeterQInfo;
|
||||||
|
closeAllTimeWindow(&pMeterQueryInfo->windowResInfo);
|
||||||
|
}
|
||||||
|
} else { // close results for group result
|
||||||
|
closeAllTimeWindow(&pRuntimeEnv->windowResInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
doMultiMeterSupplementaryScan(pQInfo);
|
doMultiMeterSupplementaryScan(pQInfo);
|
||||||
|
@ -1005,7 +996,7 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
|
||||||
*/
|
*/
|
||||||
static void vnodeSingleTableFixedOutputProcessor(SQInfo *pQInfo) {
|
static void vnodeSingleTableFixedOutputProcessor(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pMeterQuerySupporter->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pTableQuerySupporter->runtimeEnv;
|
||||||
|
|
||||||
assert(pQuery->slot >= 0 && pQuery->pos >= 0);
|
assert(pQuery->slot >= 0 && pQuery->pos >= 0);
|
||||||
|
|
||||||
|
@ -1036,7 +1027,7 @@ static void vnodeSingleTableMultiOutputProcessor(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = &pQInfo->query;
|
SQuery * pQuery = &pQInfo->query;
|
||||||
SMeterObj *pMeterObj = pQInfo->pObj;
|
SMeterObj *pMeterObj = pQInfo->pObj;
|
||||||
|
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pMeterQuerySupporter->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pTableQuerySupporter->runtimeEnv;
|
||||||
|
|
||||||
// for ts_comp query, re-initialized is not allowed
|
// for ts_comp query, re-initialized is not allowed
|
||||||
if (!isTSCompQuery(pQuery)) {
|
if (!isTSCompQuery(pQuery)) {
|
||||||
|
@ -1067,8 +1058,9 @@ static void vnodeSingleTableMultiOutputProcessor(SQInfo *pQInfo) {
|
||||||
TSKEY nextTimestamp = loadRequiredBlockIntoMem(pRuntimeEnv, &pRuntimeEnv->nextPos);
|
TSKEY nextTimestamp = loadRequiredBlockIntoMem(pRuntimeEnv, &pRuntimeEnv->nextPos);
|
||||||
assert(nextTimestamp > 0 || ((nextTimestamp < 0) && Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)));
|
assert(nextTimestamp > 0 || ((nextTimestamp < 0) && Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)));
|
||||||
|
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64, pQInfo,
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64,
|
||||||
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->limit.offset, pQuery->lastKey, pQuery->ekey);
|
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->limit.offset, pQuery->lastKey,
|
||||||
|
pQuery->ekey);
|
||||||
|
|
||||||
resetCtxOutputBuf(pRuntimeEnv);
|
resetCtxOutputBuf(pRuntimeEnv);
|
||||||
}
|
}
|
||||||
|
@ -1080,8 +1072,8 @@ static void vnodeSingleTableMultiOutputProcessor(SQInfo *pQInfo) {
|
||||||
TSKEY nextTimestamp = loadRequiredBlockIntoMem(pRuntimeEnv, &pRuntimeEnv->nextPos);
|
TSKEY nextTimestamp = loadRequiredBlockIntoMem(pRuntimeEnv, &pRuntimeEnv->nextPos);
|
||||||
assert(nextTimestamp > 0 || ((nextTimestamp < 0) && Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)));
|
assert(nextTimestamp > 0 || ((nextTimestamp < 0) && Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)));
|
||||||
|
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, query abort due to buffer limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo,
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, query abort due to buffer limitation, next qrange:%" PRId64 "-%" PRId64,
|
||||||
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->lastKey, pQuery->ekey);
|
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->lastKey, pQuery->ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, %d points returned, totalRead:%d totalReturn:%d", pQInfo, pMeterObj->vnode,
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, %d points returned, totalRead:%d totalReturn:%d", pQInfo, pMeterObj->vnode,
|
||||||
|
@ -1093,7 +1085,7 @@ static void vnodeSingleTableMultiOutputProcessor(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeSingleMeterIntervalMainLooper(SMeterQuerySupportObj *pSupporter, SQueryRuntimeEnv *pRuntimeEnv) {
|
static void vnodeSingleMeterIntervalMainLooper(STableQuerySupportObj *pSupporter, SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1113,18 +1105,19 @@ static void vnodeSingleMeterIntervalMainLooper(SMeterQuerySupportObj *pSupporter
|
||||||
|
|
||||||
// here we can ignore the records in case of no interpolation
|
// here we can ignore the records in case of no interpolation
|
||||||
if ((pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) && pQuery->limit.offset > 0 &&
|
if ((pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) && pQuery->limit.offset > 0 &&
|
||||||
pQuery->interpoType == TSDB_INTERPO_NONE) { // maxOutput <= 0, means current query does not generate any results
|
pQuery->interpoType == TSDB_INTERPO_NONE) {
|
||||||
|
// maxOutput <= 0, means current query does not generate any results
|
||||||
// todo handle offset, in case of top/bottom interval query
|
// todo handle offset, in case of top/bottom interval query
|
||||||
if (maxOutput > 0) {
|
if (maxOutput > 0) {
|
||||||
pQuery->limit.offset--;
|
pQuery->limit.offset--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// assert(0);
|
// assert(0);
|
||||||
// pQuery->pointsRead += maxOutput;
|
// pQuery->pointsRead += maxOutput;
|
||||||
// forwardCtxOutputBuf(pRuntimeEnv, maxOutput);
|
// forwardCtxOutputBuf(pRuntimeEnv, maxOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK|QUERY_COMPLETED)) {
|
if (Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK | QUERY_COMPLETED)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,7 +1144,7 @@ static void vnodeSingleTableIntervalProcessor(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = &(pQInfo->query);
|
SQuery * pQuery = &(pQInfo->query);
|
||||||
SMeterObj *pMeterObj = pQInfo->pObj;
|
SMeterObj *pMeterObj = pQInfo->pObj;
|
||||||
|
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
SQueryRuntimeEnv * pRuntimeEnv = &pSupporter->runtimeEnv;
|
||||||
|
|
||||||
int32_t numOfInterpo = 0;
|
int32_t numOfInterpo = 0;
|
||||||
|
@ -1211,7 +1204,7 @@ static void vnodeSingleTableIntervalProcessor(SQInfo *pQInfo) {
|
||||||
void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
SQInfo *pQInfo = (SQInfo *)pMsg->ahandle;
|
SQInfo *pQInfo = (SQInfo *)pMsg->ahandle;
|
||||||
|
|
||||||
if (pQInfo == NULL || pQInfo->pMeterQuerySupporter == NULL) {
|
if (pQInfo == NULL || pQInfo->pTableQuerySupporter == NULL) {
|
||||||
dTrace("%p freed abort query", pQInfo);
|
dTrace("%p freed abort query", pQInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1231,7 +1224,7 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
dTrace("vid:%d sid:%d id:%s, query thread is created, numOfQueries:%d, QInfo:%p", pMeterObj->vnode, pMeterObj->sid,
|
dTrace("vid:%d sid:%d id:%s, query thread is created, numOfQueries:%d, QInfo:%p", pMeterObj->vnode, pMeterObj->sid,
|
||||||
pMeterObj->meterId, pMeterObj->numOfQueries, pQInfo);
|
pMeterObj->meterId, pMeterObj->numOfQueries, pQInfo);
|
||||||
|
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pMeterQuerySupporter->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->pTableQuerySupporter->runtimeEnv;
|
||||||
assert(pRuntimeEnv->pMeterObj == pMeterObj);
|
assert(pRuntimeEnv->pMeterObj == pMeterObj);
|
||||||
|
|
||||||
if (vnodeHasRemainResults(pQInfo)) {
|
if (vnodeHasRemainResults(pQInfo)) {
|
||||||
|
@ -1267,8 +1260,8 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
// continue to get push data from the group result
|
// continue to get push data from the group result
|
||||||
if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
||||||
pQuery->pointsRead = 0;
|
pQuery->pointsRead = 0;
|
||||||
if (pQInfo->pMeterQuerySupporter->subgroupIdx > 0) {
|
if (pQInfo->pTableQuerySupporter->subgroupIdx > 0) {
|
||||||
copyFromGroupBuf(pQInfo, pQInfo->pMeterQuerySupporter->runtimeEnv.windowResInfo.pResult);
|
copyFromGroupBuf(pQInfo, pQInfo->pTableQuerySupporter->runtimeEnv.windowResInfo.pResult);
|
||||||
pQInfo->pointsRead += pQuery->pointsRead;
|
pQInfo->pointsRead += pQuery->pointsRead;
|
||||||
|
|
||||||
if (pQuery->pointsRead > 0) {
|
if (pQuery->pointsRead > 0) {
|
||||||
|
@ -1285,10 +1278,10 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pQInfo->over = 1;
|
pQInfo->over = 1;
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, query over, %d points are returned", pQInfo,
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, query over, %d points are returned", pQInfo, pMeterObj->vnode, pMeterObj->sid,
|
||||||
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQInfo->pointsRead);
|
pMeterObj->meterId, pQInfo->pointsRead);
|
||||||
|
|
||||||
vnodePrintQueryStatistics(pQInfo->pMeterQuerySupporter);
|
vnodePrintQueryStatistics(pQInfo->pTableQuerySupporter);
|
||||||
sem_post(&pQInfo->dataReady);
|
sem_post(&pQInfo->dataReady);
|
||||||
|
|
||||||
vnodeDecRefCount(pQInfo);
|
vnodeDecRefCount(pQInfo);
|
||||||
|
@ -1323,8 +1316,8 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
dTrace("QInfo:%p query is killed", pQInfo);
|
dTrace("QInfo:%p query is killed", pQInfo);
|
||||||
pQInfo->over = 1;
|
pQInfo->over = 1;
|
||||||
} else {
|
} else {
|
||||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, meter query thread completed, %d points are returned",
|
dTrace("QInfo:%p vid:%d sid:%d id:%s, meter query thread completed, %d points are returned", pQInfo,
|
||||||
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->pointsRead);
|
pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->pointsRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_post(&pQInfo->dataReady);
|
sem_post(&pQInfo->dataReady);
|
||||||
|
@ -1334,7 +1327,7 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
|
||||||
void vnodeMultiMeterQuery(SSchedMsg *pMsg) {
|
void vnodeMultiMeterQuery(SSchedMsg *pMsg) {
|
||||||
SQInfo *pQInfo = (SQInfo *)pMsg->ahandle;
|
SQInfo *pQInfo = (SQInfo *)pMsg->ahandle;
|
||||||
|
|
||||||
if (pQInfo == NULL || pQInfo->pMeterQuerySupporter == NULL) {
|
if (pQInfo == NULL || pQInfo->pTableQuerySupporter == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,10 +1358,10 @@ void vnodeMultiMeterQuery(SSchedMsg *pMsg) {
|
||||||
pQInfo->useconds += (taosGetTimestampUs() - st);
|
pQInfo->useconds += (taosGetTimestampUs() - st);
|
||||||
pQInfo->over = isQueryKilled(pQuery) ? 1 : 0;
|
pQInfo->over = isQueryKilled(pQuery) ? 1 : 0;
|
||||||
|
|
||||||
taosInterpoSetStartInfo(&pQInfo->pMeterQuerySupporter->runtimeEnv.interpoInfo, pQuery->pointsRead,
|
taosInterpoSetStartInfo(&pQInfo->pTableQuerySupporter->runtimeEnv.interpoInfo, pQuery->pointsRead,
|
||||||
pQInfo->query.interpoType);
|
pQInfo->query.interpoType);
|
||||||
|
|
||||||
SMeterQuerySupportObj *pSupporter = pQInfo->pMeterQuerySupporter;
|
STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter;
|
||||||
|
|
||||||
if (pQuery->pointsRead == 0) {
|
if (pQuery->pointsRead == 0) {
|
||||||
pQInfo->over = 1;
|
pQInfo->over = 1;
|
||||||
|
|
|
@ -648,7 +648,7 @@ void *vnodeQueryOnSingleTable(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMeterQuerySupportObj *pSupporter = (SMeterQuerySupportObj *)calloc(1, sizeof(SMeterQuerySupportObj));
|
STableQuerySupportObj *pSupporter = (STableQuerySupportObj *)calloc(1, sizeof(STableQuerySupportObj));
|
||||||
pSupporter->numOfMeters = 1;
|
pSupporter->numOfMeters = 1;
|
||||||
|
|
||||||
pSupporter->pMetersHashTable = taosInitHashTable(pSupporter->numOfMeters, taosIntHash_32, false);
|
pSupporter->pMetersHashTable = taosInitHashTable(pSupporter->numOfMeters, taosIntHash_32, false);
|
||||||
|
@ -659,7 +659,7 @@ void *vnodeQueryOnSingleTable(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
pSupporter->subgroupIdx = -1;
|
pSupporter->subgroupIdx = -1;
|
||||||
pSupporter->pMeterSidExtInfo = NULL;
|
pSupporter->pMeterSidExtInfo = NULL;
|
||||||
|
|
||||||
pQInfo->pMeterQuerySupporter = pSupporter;
|
pQInfo->pTableQuerySupporter = pSupporter;
|
||||||
|
|
||||||
STSBuf *pTSBuf = NULL;
|
STSBuf *pTSBuf = NULL;
|
||||||
if (pQueryMsg->tsLen > 0) {
|
if (pQueryMsg->tsLen > 0) {
|
||||||
|
@ -670,7 +670,7 @@ void *vnodeQueryOnSingleTable(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
tsBufNextPos(pTSBuf);
|
tsBufNextPos(pTSBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((*code) = vnodeQuerySingleTablePrepare(pQInfo, pQInfo->pObj, pSupporter, pTSBuf)) != TSDB_CODE_SUCCESS) {
|
if (((*code) = vnodeQueryTablePrepare(pQInfo, pQInfo->pObj, pSupporter, pTSBuf)) != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ void *vnodeQueryOnMultiMeters(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
|
|
||||||
SSchedMsg schedMsg = {0};
|
SSchedMsg schedMsg = {0};
|
||||||
|
|
||||||
SMeterQuerySupportObj *pSupporter = (SMeterQuerySupportObj *)calloc(1, sizeof(SMeterQuerySupportObj));
|
STableQuerySupportObj *pSupporter = (STableQuerySupportObj *)calloc(1, sizeof(STableQuerySupportObj));
|
||||||
pSupporter->numOfMeters = pQueryMsg->numOfSids;
|
pSupporter->numOfMeters = pQueryMsg->numOfSids;
|
||||||
|
|
||||||
pSupporter->pMetersHashTable = taosInitHashTable(pSupporter->numOfMeters, taosIntHash_32, false);
|
pSupporter->pMetersHashTable = taosInitHashTable(pSupporter->numOfMeters, taosIntHash_32, false);
|
||||||
|
@ -784,7 +784,7 @@ void *vnodeQueryOnMultiMeters(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
(SSchema *)pQueryMsg->pTagSchema, pQueryMsg->numOfTagsCols, NULL, 0);
|
(SSchema *)pQueryMsg->pTagSchema, pQueryMsg->numOfTagsCols, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQInfo->pMeterQuerySupporter = pSupporter;
|
pQInfo->pTableQuerySupporter = pSupporter;
|
||||||
|
|
||||||
STSBuf *pTSBuf = NULL;
|
STSBuf *pTSBuf = NULL;
|
||||||
if (pQueryMsg->tsLen > 0) {
|
if (pQueryMsg->tsLen > 0) {
|
||||||
|
@ -794,7 +794,7 @@ void *vnodeQueryOnMultiMeters(SMeterObj **pMetersObj, SSqlGroupbyExpr *pGroupbyE
|
||||||
tsBufResetPos(pTSBuf);
|
tsBufResetPos(pTSBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((*code) = vnodeMultiMeterQueryPrepare(pQInfo, pQuery, pTSBuf)) != TSDB_CODE_SUCCESS) {
|
if (((*code) = vnodeSTableQueryPrepare(pQInfo, pQuery, pTSBuf)) != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,8 +898,8 @@ int vnodeSaveQueryResult(void *handle, char *data, int32_t *size) {
|
||||||
|
|
||||||
SSchedMsg schedMsg = {0};
|
SSchedMsg schedMsg = {0};
|
||||||
|
|
||||||
if (pQInfo->pMeterQuerySupporter != NULL) {
|
if (pQInfo->pTableQuerySupporter != NULL) {
|
||||||
if (pQInfo->pMeterQuerySupporter->pSidSet == NULL) {
|
if (pQInfo->pTableQuerySupporter->pSidSet == NULL) {
|
||||||
schedMsg.fp = vnodeSingleTableQuery;
|
schedMsg.fp = vnodeSingleTableQuery;
|
||||||
} else { // group by tag
|
} else { // group by tag
|
||||||
schedMsg.fp = vnodeMultiMeterQuery;
|
schedMsg.fp = vnodeMultiMeterQuery;
|
||||||
|
|
|
@ -446,8 +446,8 @@ void vnodeExecuteRetrieveReq(SSchedMsg *pSched) {
|
||||||
// buffer size for progress information, including meter count,
|
// buffer size for progress information, including meter count,
|
||||||
// and for each meter, including 'uid' and 'TSKEY'.
|
// and for each meter, including 'uid' and 'TSKEY'.
|
||||||
int progressSize = 0;
|
int progressSize = 0;
|
||||||
if (pQInfo->pMeterQuerySupporter != NULL)
|
if (pQInfo->pTableQuerySupporter != NULL)
|
||||||
progressSize = pQInfo->pMeterQuerySupporter->numOfMeters * (sizeof(int64_t) + sizeof(TSKEY)) + sizeof(int32_t);
|
progressSize = pQInfo->pTableQuerySupporter->numOfMeters * (sizeof(int64_t) + sizeof(TSKEY)) + sizeof(int32_t);
|
||||||
else if (pQInfo->pObj != NULL)
|
else if (pQInfo->pObj != NULL)
|
||||||
progressSize = sizeof(int64_t) + sizeof(TSKEY) + sizeof(int32_t);
|
progressSize = sizeof(int64_t) + sizeof(TSKEY) + sizeof(int32_t);
|
||||||
|
|
||||||
|
@ -486,13 +486,13 @@ void vnodeExecuteRetrieveReq(SSchedMsg *pSched) {
|
||||||
// write the progress information of each meter to response
|
// write the progress information of each meter to response
|
||||||
// this is required by subscriptions
|
// this is required by subscriptions
|
||||||
if (numOfRows > 0 && code == TSDB_CODE_SUCCESS) {
|
if (numOfRows > 0 && code == TSDB_CODE_SUCCESS) {
|
||||||
if (pQInfo->pMeterQuerySupporter != NULL && pQInfo->pMeterQuerySupporter->pMeterSidExtInfo != NULL) {
|
if (pQInfo->pTableQuerySupporter != NULL && pQInfo->pTableQuerySupporter->pMeterSidExtInfo != NULL) {
|
||||||
*((int32_t *)pMsg) = htonl(pQInfo->pMeterQuerySupporter->numOfMeters);
|
*((int32_t *)pMsg) = htonl(pQInfo->pTableQuerySupporter->numOfMeters);
|
||||||
pMsg += sizeof(int32_t);
|
pMsg += sizeof(int32_t);
|
||||||
for (int32_t i = 0; i < pQInfo->pMeterQuerySupporter->numOfMeters; i++) {
|
for (int32_t i = 0; i < pQInfo->pTableQuerySupporter->numOfMeters; i++) {
|
||||||
*((int64_t *)pMsg) = htobe64(pQInfo->pMeterQuerySupporter->pMeterSidExtInfo[i]->uid);
|
*((int64_t *)pMsg) = htobe64(pQInfo->pTableQuerySupporter->pMeterSidExtInfo[i]->uid);
|
||||||
pMsg += sizeof(int64_t);
|
pMsg += sizeof(int64_t);
|
||||||
*((TSKEY *)pMsg) = htobe64(pQInfo->pMeterQuerySupporter->pMeterSidExtInfo[i]->key);
|
*((TSKEY *)pMsg) = htobe64(pQInfo->pTableQuerySupporter->pMeterSidExtInfo[i]->key);
|
||||||
pMsg += sizeof(TSKEY);
|
pMsg += sizeof(TSKEY);
|
||||||
}
|
}
|
||||||
} else if (pQInfo->pObj != NULL) {
|
} else if (pQInfo->pObj != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue