提交 0d4b9df6 编写于 作者: C Cary Xu

code optimization

上级 729eb668
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册