From a87f915ebfbe411bba450973104bb36a2f5b97f4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 25 Oct 2022 15:30:41 +0800 Subject: [PATCH 1/2] fix(query):set correct column match info size. --- source/dnode/vnode/src/tsdb/tsdbRead.c | 11 ++++++++++- source/libs/executor/src/cachescanoperator.c | 2 +- source/libs/executor/src/executil.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index ca877f599f..f94dbc51d1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1631,7 +1631,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS || merge.pTSchema == NULL) { return code; } } @@ -3768,6 +3768,15 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return false; } +bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) { + void* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid)); + if (pBlockScanInfo == NULL) { // no data block for the table of given uid + return false; + } + + +} + static void setBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) { ASSERT(pDataBlockInfo != NULL && pReader != NULL); pDataBlockInfo->rows = pReader->pResBlock->info.rows; diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 22a685230a..914da422ad 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -279,7 +279,7 @@ int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pC } size_t size = taosArrayGetSize(pColMatchInfo->pList); - SArray* pMatchInfo = taosArrayInit(size, sizeof(SColMatchInfo)); + SArray* pMatchInfo = taosArrayInit(size, sizeof(SColMatchItem)); for (int32_t i = 0; i < size; ++i) { SColMatchItem* pColInfo = taosArrayGet(pColMatchInfo->pList, i); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index f58c2a0e34..971b28eb09 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1073,7 +1073,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod pMatchInfo->matchType = type; - SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo)); + SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchItem)); if (pList == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; return code; From 6acdfdd9abdf2d112d7906b45d95bd3be151a5b0 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 25 Oct 2022 16:20:51 +0800 Subject: [PATCH 2/2] refactor: do some internal refactor. --- source/dnode/vnode/src/tsdb/tsdbRead.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index f94dbc51d1..71828882c3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -111,7 +111,7 @@ typedef struct SDataBlockIter { int32_t index; SArray* blockList; // SArray int32_t order; - SDataBlk block; // current SDataBlk data + SDataBlk block; // current SDataBlk data SHashObj* pTableMap; } SDataBlockIter; @@ -1209,19 +1209,19 @@ static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* p (pVerRange->maxVer < pBlock->maxVer && pVerRange->maxVer >= pBlock->minVer); } -static SDataBlk* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, +static SDataBlk* getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, int32_t* nextIndex, int32_t order) { bool asc = ASCENDING_TRAVERSE(order); - if (asc && pFBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockList) - 1) { + if (asc && pBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockList) - 1) { return NULL; } - if (!asc && pFBlockInfo->tbBlockIdx == 0) { + if (!asc && pBlockInfo->tbBlockIdx == 0) { return NULL; } int32_t step = asc ? 1 : -1; - *nextIndex = pFBlockInfo->tbBlockIdx + step; + *nextIndex = pBlockInfo->tbBlockIdx + step; SDataBlk* pBlock = taosMemoryCalloc(1, sizeof(SDataBlk)); int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); @@ -3769,12 +3769,12 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { } bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) { - void* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid)); + STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid)); if (pBlockScanInfo == NULL) { // no data block for the table of given uid return false; } - + return true; } static void setBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockInfo) {