diff --git a/src/tsdb/inc/tsdbReadImpl.h b/src/tsdb/inc/tsdbReadImpl.h index 1775873ca934c36a168e32727b913f4ebafe891a..12727adb89cdf3eebeb014a3b867b412c3a5d9ac 100644 --- a/src/tsdb/inc/tsdbReadImpl.h +++ b/src/tsdb/inc/tsdbReadImpl.h @@ -71,12 +71,12 @@ typedef struct { * blkVer; // 0 - original block, 1 - block since importing .smad/.smal * aggrOffset; // only valid when blkVer > 0 and aggrStat > 0 */ -#define SBlockFieldsP1 \ - uint64_t aggrStat : 1; \ - uint64_t blkVer : 7; \ - uint64_t aggrOffset : 56; \ - uint32_t aggrLen; \ - uint32_t padding +#define SBlockFieldsP1 \ + uint64_t aggrStat : 1; \ + uint64_t blkVer : 7; \ + uint64_t aggrOffset : 56; \ + uint64_t aggrNumOfCols : 16; \ + uint64_t padding : 48 typedef struct { SBlockFieldsP0; @@ -213,7 +213,6 @@ static FORCE_INLINE size_t tsdbBlockStatisSize(int nCols, uint32_t blkVer) { } } -#define TSDB_BLOCK_AGGR_COLS(blkLen, blkVer) ((blkLen - sizeof(TSCKSUM)) / sizeof(SAggrBlkColV##blkVer)) #define TSDB_BLOCK_AGGR_SIZE(ncols, blkVer) (sizeof(SAggrBlkColV##blkVer) * (ncols) + sizeof(TSCKSUM)) static FORCE_INLINE size_t tsdbBlockAggrSize(int nCols, uint32_t blkVer) { @@ -227,17 +226,6 @@ static FORCE_INLINE size_t tsdbBlockAggrSize(int nCols, uint32_t blkVer) { } } -static FORCE_INLINE int32_t tsdbBlockAggrCols(uint32_t blkLen, uint32_t blkVer) { - switch (blkVer) { - case TSDB_SBLK_VER_0: - ASSERT(false); - return 0; - case TSDB_SBLK_VER_1: - default: - return TSDB_BLOCK_AGGR_COLS(blkLen, 1); - } -} - int tsdbInitReadH(SReadH *pReadh, STsdbRepo *pRepo); void tsdbDestroyReadH(SReadH *pReadh); int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet); diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index 3a9793ac95451123a8dad02b797dc86b2196d837..9b79e11f5a324fbff26635c27ae7e7ecd2ae39ab 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -1216,7 +1216,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile pBlock->aggrStat = aggrStatus; pBlock->blkVer = SBlockVerLatest; pBlock->aggrOffset = (uint64_t)offsetAggr; - pBlock->aggrLen = tsizeAggr; + pBlock->aggrNumOfCols = nAggrCols; pBlock->padding = 0; // padding filled with 0 tsdbDebug("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64 diff --git a/src/tsdb/src/tsdbReadImpl.c b/src/tsdb/src/tsdbReadImpl.c index afe901d1dc634c2e69474db0457c6885ca587279..0f238c9a16fb17b69ff0313763433f6322f3022b 100644 --- a/src/tsdb/src/tsdbReadImpl.c +++ b/src/tsdb/src/tsdbReadImpl.c @@ -469,8 +469,7 @@ static int tsdbLoadBlockStatisFromAggr(SReadH *pReadh, SBlock *pBlock) { return -1; } - size_t sizeAggr = pBlock->aggrLen; - // tsdbBlockAggrSize(pBlock->numOfCols, (uint32_t)pBlock->blkVer); + size_t sizeAggr = tsdbBlockAggrSize(pBlock->aggrNumOfCols, (uint32_t)pBlock->blkVer); if (tsdbMakeRoom((void **)(&(pReadh->pAggrBlkData)), sizeAggr) < 0) return -1; int64_t nreadAggr = tsdbReadDFile(pDFileAggr, (void *)(pReadh->pAggrBlkData), sizeAggr); @@ -579,10 +578,9 @@ void tsdbGetBlockStatis(SReadH *pReadh, SDataStatis *pStatis, int numOfCols, SBl } } else if (pBlock->aggrStat) { SAggrBlkData *pAggrBlkData = pReadh->pAggrBlkData; - int32_t nAggrBlkCols = tsdbBlockAggrCols(pBlock->aggrLen, pBlock->blkVer); for (int i = 0, j = 0; i < numOfCols;) { - if (j >= nAggrBlkCols) { + if (j >= pBlock->aggrNumOfCols) { pStatis[i].numOfNull = -1; i++; continue;