add the support of issue #1131. [tbase-901]
This commit is contained in:
parent
33367d7033
commit
ca136d47de
|
@ -1307,7 +1307,6 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
|
|||
tscTrace("continue parse sql: %s", pSql->asyncTblPos);
|
||||
}
|
||||
|
||||
|
||||
if (tscIsInsertOrImportData(pSql->sqlstr)) {
|
||||
/*
|
||||
* only for async multi-vnode insertion
|
||||
|
|
|
@ -829,7 +829,7 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd* pCmd) {
|
|||
|
||||
char* z = NULL;
|
||||
if (len > 0) {
|
||||
z = strstr (pCmd->payload, "invalid sql");
|
||||
z = strstr (pCmd->payload, "invalid SQL");
|
||||
}
|
||||
|
||||
return z != NULL;
|
||||
|
|
|
@ -129,6 +129,7 @@ bool isPointInterpoQuery(SQuery* pQuery);
|
|||
bool isTopBottomQuery(SQuery* pQuery);
|
||||
bool isFirstLastRowQuery(SQuery* pQuery);
|
||||
bool isTSCompQuery(SQuery* pQuery);
|
||||
bool notHasQueryTimeRange(SQuery *pQuery);
|
||||
|
||||
bool needSupplementaryScan(SQuery* pQuery);
|
||||
bool onDemandLoadDatablock(SQuery* pQuery, int16_t queryRangeSet);
|
||||
|
@ -172,10 +173,10 @@ void enableFunctForMasterScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order);
|
|||
int32_t mergeMetersResultToOneGroups(SMeterQuerySupportObj* pSupporter);
|
||||
void copyFromGroupBuf(SQInfo* pQInfo, SOutputRes* result);
|
||||
|
||||
SBlockInfo getBlockBasicInfo(void* pBlock, int32_t blockType);
|
||||
SCacheBlock* getCacheDataBlock(SMeterObj* pMeterObj, SQuery* pQuery, int32_t slot);
|
||||
SBlockInfo getBlockBasicInfo(SQueryRuntimeEnv* pRuntimeEnv, void* pBlock, int32_t blockType);
|
||||
SCacheBlock* getCacheDataBlock(SMeterObj* pMeterObj, SQueryRuntimeEnv* pRuntimeEnv, int32_t slot);
|
||||
|
||||
void queryOnBlock(SMeterQuerySupportObj* pSupporter, int64_t* primaryKeys, int32_t blockStatus, char* data,
|
||||
void queryOnBlock(SMeterQuerySupportObj* pSupporter, int64_t* primaryKeys, int32_t blockStatus,
|
||||
SBlockInfo* pBlockBasicInfo, SMeterDataInfo* pDataHeadInfoEx, SField* pFields,
|
||||
__block_search_fn_t searchFn);
|
||||
|
||||
|
|
|
@ -35,19 +35,19 @@ typedef struct {
|
|||
int32_t fileId;
|
||||
} SPositionInfo;
|
||||
|
||||
typedef struct SQueryLoadBlockInfo {
|
||||
typedef struct SLoadDataBlockInfo {
|
||||
int32_t fileListIndex; /* index of this file in files list of this vnode */
|
||||
int32_t fileId;
|
||||
int32_t slotIdx;
|
||||
int32_t sid;
|
||||
bool tsLoaded; // if timestamp column of current block is loaded or not
|
||||
} SQueryLoadBlockInfo;
|
||||
} SLoadDataBlockInfo;
|
||||
|
||||
typedef struct SQueryLoadCompBlockInfo {
|
||||
typedef struct SLoadCompBlockInfo {
|
||||
int32_t sid; /* meter sid */
|
||||
int32_t fileId;
|
||||
int32_t fileListIndex;
|
||||
} SQueryLoadCompBlockInfo;
|
||||
} SLoadCompBlockInfo;
|
||||
|
||||
/*
|
||||
* the header file info for one vnode
|
||||
|
@ -126,20 +126,28 @@ typedef struct RuntimeEnvironment {
|
|||
SQuery* pQuery;
|
||||
SMeterObj* pMeterObj;
|
||||
SQLFunctionCtx* pCtx;
|
||||
SQueryLoadBlockInfo loadBlockInfo; /* record current block load information */
|
||||
SQueryLoadCompBlockInfo loadCompBlockInfo; /* record current compblock information in SQuery */
|
||||
SQueryFilesInfo vnodeFileInfo;
|
||||
int16_t numOfRowsPerPage;
|
||||
int16_t offset[TSDB_MAX_COLUMNS];
|
||||
int16_t scanFlag; // denotes reversed scan of data or not
|
||||
SInterpolationInfo interpoInfo;
|
||||
SData** pInterpoBuf;
|
||||
SOutputRes* pResult; // reference to SQuerySupporter->pResult
|
||||
void* hashList;
|
||||
int32_t usedIndex; // assigned SOutputRes in list
|
||||
STSBuf* pTSBuf;
|
||||
STSCursor cur;
|
||||
SQueryCostSummary summary;
|
||||
SLoadDataBlockInfo loadBlockInfo; /* record current block load information */
|
||||
SLoadCompBlockInfo loadCompBlockInfo; /* record current compblock information in SQuery */
|
||||
SQueryFilesInfo vnodeFileInfo;
|
||||
int16_t numOfRowsPerPage;
|
||||
int16_t offset[TSDB_MAX_COLUMNS];
|
||||
int16_t scanFlag; // denotes reversed scan of data or not
|
||||
SInterpolationInfo interpoInfo;
|
||||
SData** pInterpoBuf;
|
||||
SOutputRes* pResult; // reference to SQuerySupporter->pResult
|
||||
void* hashList;
|
||||
int32_t usedIndex; // assigned SOutputRes in list
|
||||
STSBuf* pTSBuf;
|
||||
STSCursor cur;
|
||||
SQueryCostSummary summary;
|
||||
|
||||
/*
|
||||
* Temporarily hold the in-memory cache block info during scan cache blocks
|
||||
* Here we do not use the cacheblock info from pMeterObj, simple because it may change anytime
|
||||
* during the query by the subumit/insert handling threads.
|
||||
* So we keep a copy of the support structure as well as the cache block data itself.
|
||||
*/
|
||||
SCacheBlock cacheBlock;
|
||||
} SQueryRuntimeEnv;
|
||||
|
||||
/* intermediate result during multimeter query involves interval */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -146,9 +146,7 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
if (pQuery->nAggTimeInterval == 0) {
|
||||
if ((pQuery->lastKey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||
(pQuery->lastKey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||
dTrace(
|
||||
"QInfo:%p vid:%d sid:%d id:%s, query completed, no need to scan data in cache. qrange:%lld-%lld, "
|
||||
"lastKey:%lld",
|
||||
dTrace("QInfo:%p vid:%d sid:%d id:%s, query completed, ignore data in cache. qrange:%lld-%lld, lastKey:%lld",
|
||||
pQInfo, pMeterObj->vnode, pMeterObj->sid, pMeterObj->meterId, pQuery->skey, pQuery->ekey,
|
||||
pQuery->lastKey);
|
||||
|
||||
|
@ -183,7 +181,7 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
|
||||
// data in this block may be flushed to disk and this block is allocated to other meter
|
||||
// todo try with remain cache blocks
|
||||
SCacheBlock *pBlock = getCacheDataBlock(pMeterObj, pQuery, pQuery->slot);
|
||||
SCacheBlock *pBlock = getCacheDataBlock(pMeterObj, pRuntimeEnv, pQuery->slot);
|
||||
if (pBlock == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -196,7 +194,7 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
SCacheInfo *pCacheInfo = (SCacheInfo *)pMeterObj->pCache;
|
||||
|
||||
for (int32_t i = 0; i < pCacheInfo->maxBlocks; ++i) {
|
||||
pBlock = getCacheDataBlock(pMeterObj, pQuery, pQuery->slot);
|
||||
pBlock = getCacheDataBlock(pMeterObj, pRuntimeEnv, pQuery->slot);
|
||||
|
||||
/*
|
||||
* 1. pBlock == NULL. The cache block may be flushed to disk, so it is not available, skip and try next
|
||||
|
@ -216,8 +214,8 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
|
||||
setStartPositionForCacheBlock(pQuery, pBlock, &firstCheckSlot);
|
||||
|
||||
TSKEY *primaryKeys = (TSKEY *)pBlock->offset[0];
|
||||
|
||||
TSKEY* primaryKeys = (TSKEY*) pRuntimeEnv->primaryColBuffer->data;
|
||||
|
||||
// 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)) ||
|
||||
(primaryKeys[pQuery->pos] < pSupporter->rawEKey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||
|
@ -226,15 +224,14 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
|
||||
// only record the key on last block
|
||||
SET_CACHE_BLOCK_FLAG(pRuntimeEnv->blockStatus);
|
||||
SBlockInfo binfo = getBlockBasicInfo(pBlock, BLK_CACHE_BLOCK);
|
||||
SBlockInfo binfo = getBlockBasicInfo(pRuntimeEnv, pBlock, BLK_CACHE_BLOCK);
|
||||
|
||||
dTrace("QInfo:%p check data block, brange:%lld-%lld, fileId:%d, slot:%d, pos:%d, bstatus:%d",
|
||||
GET_QINFO_ADDR(pQuery), binfo.keyFirst, binfo.keyLast, pQuery->fileId, pQuery->slot, pQuery->pos,
|
||||
pRuntimeEnv->blockStatus);
|
||||
|
||||
totalBlocks++;
|
||||
queryOnBlock(pSupporter, primaryKeys, pRuntimeEnv->blockStatus, (char *)pBlock, &binfo, &pMeterInfo[k], NULL,
|
||||
searchFn);
|
||||
queryOnBlock(pSupporter, primaryKeys, pRuntimeEnv->blockStatus, &binfo, &pMeterInfo[k], NULL, searchFn);
|
||||
|
||||
if (ALL_CACHE_BLOCKS_CHECKED(pQuery)) {
|
||||
break;
|
||||
|
@ -425,7 +422,7 @@ static SMeterDataInfo *queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
continue;
|
||||
}
|
||||
|
||||
SBlockInfo binfo = getBlockBasicInfo(pBlock, BLK_FILE_BLOCK);
|
||||
SBlockInfo binfo = getBlockBasicInfo(pRuntimeEnv, pBlock, BLK_FILE_BLOCK);
|
||||
|
||||
assert(pQuery->pos >= 0 && pQuery->pos < pBlock->numOfPoints);
|
||||
TSKEY *primaryKeys = (TSKEY *)pRuntimeEnv->primaryColBuffer->data;
|
||||
|
@ -441,8 +438,8 @@ static SMeterDataInfo *queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMe
|
|||
(pBlock->keyFirst >= pQuery->ekey && pBlock->keyLast <= pQuery->lastKey && !QUERY_IS_ASC_QUERY(pQuery)));
|
||||
}
|
||||
|
||||
queryOnBlock(pSupporter, primaryKeys, pRuntimeEnv->blockStatus, (char *)pRuntimeEnv->colDataBuffer, &binfo,
|
||||
pOneMeterDataInfo, pInfoEx->pBlock.fields, searchFn);
|
||||
queryOnBlock(pSupporter, primaryKeys, pRuntimeEnv->blockStatus, &binfo, pOneMeterDataInfo, pInfoEx->pBlock.fields,
|
||||
searchFn);
|
||||
}
|
||||
|
||||
tfree(pReqMeterDataInfo);
|
||||
|
@ -489,6 +486,9 @@ static bool multimeterMultioutputHelper(SQInfo *pQInfo, bool *dataInDisk, bool *
|
|||
pQInfo->pObj = pMeterObj;
|
||||
pQuery->lastKey = pQuery->skey;
|
||||
pRuntimeEnv->pMeterObj = pMeterObj;
|
||||
|
||||
vnodeUpdateQueryColumnIndex(pQuery, pRuntimeEnv->pMeterObj);
|
||||
vnodeUpdateFilterColumnIndex(pQuery);
|
||||
|
||||
vnodeCheckIfDataExists(pRuntimeEnv, pMeterObj, dataInDisk, dataInCache);
|
||||
|
||||
|
@ -619,6 +619,9 @@ static void vnodeMultiMeterMultiOutputProcessor(SQInfo *pQInfo) {
|
|||
pSupporter->rawEKey = key;
|
||||
|
||||
int64_t num = doCheckMetersInGroup(pQInfo, index, start);
|
||||
if (num == 0) {
|
||||
int32_t k = 1;
|
||||
}
|
||||
assert(num >= 0);
|
||||
} else {
|
||||
dTrace("QInfo:%p interp query on vid:%d, numOfGroups:%d, current group:%d", pQInfo, pOneMeter->vnode,
|
||||
|
@ -686,7 +689,7 @@ static void vnodeMultiMeterMultiOutputProcessor(SQInfo *pQInfo) {
|
|||
setQueryStatus(pQuery, QUERY_NO_DATA_TO_CHECK);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool dataInDisk = true;
|
||||
bool dataInCache = true;
|
||||
if (!multimeterMultioutputHelper(pQInfo, &dataInDisk, &dataInCache, k, 0)) {
|
||||
|
@ -725,9 +728,6 @@ static void vnodeMultiMeterMultiOutputProcessor(SQInfo *pQInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
vnodeUpdateQueryColumnIndex(pQuery, pRuntimeEnv->pMeterObj);
|
||||
vnodeUpdateFilterColumnIndex(pQuery);
|
||||
|
||||
vnodeScanAllData(pRuntimeEnv);
|
||||
|
||||
pQuery->pointsRead = getNumOfResult(pRuntimeEnv);
|
||||
|
|
Loading…
Reference in New Issue