commit
02fe080ea3
|
@ -195,7 +195,6 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
// uint32_t padding;
|
|
||||||
uint32_t hasLast : 2;
|
uint32_t hasLast : 2;
|
||||||
uint32_t numOfBlocks : 30;
|
uint32_t numOfBlocks : 30;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
|
@ -224,7 +223,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
int16_t len;
|
int32_t len;
|
||||||
int32_t type : 8;
|
int32_t type : 8;
|
||||||
int32_t offset : 24;
|
int32_t offset : 24;
|
||||||
int64_t sum;
|
int64_t sum;
|
||||||
|
@ -438,8 +437,9 @@ int tsdbLoadCompIdx(SRWHelper* pHelper, void* target);
|
||||||
int tsdbLoadCompInfo(SRWHelper* pHelper, void* target);
|
int tsdbLoadCompInfo(SRWHelper* pHelper, void* target);
|
||||||
int tsdbLoadCompData(SRWHelper* phelper, SCompBlock* pcompblock, void* target);
|
int tsdbLoadCompData(SRWHelper* phelper, SCompBlock* pcompblock, void* target);
|
||||||
void tsdbGetDataStatis(SRWHelper* pHelper, SDataStatis* pStatis, int numOfCols);
|
void tsdbGetDataStatis(SRWHelper* pHelper, SDataStatis* pStatis, int numOfCols);
|
||||||
int tsdbLoadBlockDataCols(SRWHelper* pHelper, SCompBlock* pCompBlock, int16_t* colIds, int numOfColIds);
|
int tsdbLoadBlockDataCols(SRWHelper* pHelper, SCompBlock* pCompBlock, SCompInfo* pCompInfo, int16_t* colIds,
|
||||||
int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock);
|
int numOfColIds);
|
||||||
|
int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock, SCompInfo* pCompInfo);
|
||||||
|
|
||||||
// ------------------ tsdbMain.c
|
// ------------------ tsdbMain.c
|
||||||
#define REPO_ID(r) (r)->config.tsdbId
|
#define REPO_ID(r) (r)->config.tsdbId
|
||||||
|
|
|
@ -318,7 +318,7 @@ int tsdbMoveLastBlockIfNeccessary(SRWHelper *pHelper) {
|
||||||
ASSERT(pCompBlock->last);
|
ASSERT(pCompBlock->last);
|
||||||
|
|
||||||
if (pCompBlock->numOfSubBlocks > 1) {
|
if (pCompBlock->numOfSubBlocks > 1) {
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1)) < 0) return -1;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1), NULL) < 0) return -1;
|
||||||
ASSERT(pHelper->pDataCols[0]->numOfRows > 0 && pHelper->pDataCols[0]->numOfRows < pCfg->minRowsPerFileBlock);
|
ASSERT(pHelper->pDataCols[0]->numOfRows > 0 && pHelper->pDataCols[0]->numOfRows < pCfg->minRowsPerFileBlock);
|
||||||
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0],
|
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0],
|
||||||
pHelper->pDataCols[0]->numOfRows, &compBlock, true, true) < 0)
|
pHelper->pDataCols[0]->numOfRows, &compBlock, true, true) < 0)
|
||||||
|
@ -577,11 +577,12 @@ void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbLoadBlockDataCols(SRWHelper *pHelper, SCompBlock *pCompBlock, int16_t *colIds, int numOfColIds) {
|
int tsdbLoadBlockDataCols(SRWHelper *pHelper, SCompBlock *pCompBlock, SCompInfo *pCompInfo, int16_t *colIds, int numOfColIds) {
|
||||||
ASSERT(pCompBlock->numOfSubBlocks >= 1); // Must be super block
|
ASSERT(pCompBlock->numOfSubBlocks >= 1); // Must be super block
|
||||||
|
|
||||||
int numOfSubBlocks = pCompBlock->numOfSubBlocks;
|
int numOfSubBlocks = pCompBlock->numOfSubBlocks;
|
||||||
if (numOfSubBlocks > 1) pCompBlock = (SCompBlock *)POINTER_SHIFT(pHelper->pCompInfo, pCompBlock->offset);
|
if (numOfSubBlocks > 1)
|
||||||
|
pCompBlock = (SCompBlock *)POINTER_SHIFT((pCompInfo == NULL) ? pHelper->pCompInfo : pCompInfo, pCompBlock->offset);
|
||||||
|
|
||||||
tdResetDataCols(pHelper->pDataCols[0]);
|
tdResetDataCols(pHelper->pDataCols[0]);
|
||||||
if (tsdbLoadBlockDataColsImpl(pHelper, pCompBlock, pHelper->pDataCols[0], colIds, numOfColIds) < 0) goto _err;
|
if (tsdbLoadBlockDataColsImpl(pHelper, pCompBlock, pHelper->pDataCols[0], colIds, numOfColIds) < 0) goto _err;
|
||||||
|
@ -598,10 +599,10 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock) {
|
int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SCompInfo *pCompInfo) {
|
||||||
|
|
||||||
int numOfSubBlock = pCompBlock->numOfSubBlocks;
|
int numOfSubBlock = pCompBlock->numOfSubBlocks;
|
||||||
if (numOfSubBlock > 1) pCompBlock = (SCompBlock *)POINTER_SHIFT(pHelper->pCompInfo, pCompBlock->offset);
|
if (numOfSubBlock > 1)
|
||||||
|
pCompBlock = (SCompBlock *)POINTER_SHIFT((pCompInfo == NULL) ? pHelper->pCompInfo : pCompInfo, pCompBlock->offset);
|
||||||
|
|
||||||
tdResetDataCols(pHelper->pDataCols[0]);
|
tdResetDataCols(pHelper->pDataCols[0]);
|
||||||
if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[0]) < 0) goto _err;
|
if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[0]) < 0) goto _err;
|
||||||
|
@ -703,6 +704,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add checksum
|
// Add checksum
|
||||||
|
ASSERT(pCompCol->len > 0);
|
||||||
pCompCol->len += sizeof(TSCKSUM);
|
pCompCol->len += sizeof(TSCKSUM);
|
||||||
taosCalcChecksumAppend(0, (uint8_t *)tptr, pCompCol->len);
|
taosCalcChecksumAppend(0, (uint8_t *)tptr, pCompCol->len);
|
||||||
|
|
||||||
|
@ -792,7 +794,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
|
||||||
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
||||||
} else {
|
} else {
|
||||||
// Load
|
// Load
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx)) < 0) goto _err;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err;
|
||||||
ASSERT(pHelper->pDataCols[0]->numOfRows <= blockAtIdx(pHelper, blkIdx)->numOfRows);
|
ASSERT(pHelper->pDataCols[0]->numOfRows <= blockAtIdx(pHelper, blkIdx)->numOfRows);
|
||||||
// Merge
|
// Merge
|
||||||
if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err;
|
if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err;
|
||||||
|
@ -848,7 +850,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
|
||||||
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
||||||
} else { // Load-Merge-Write
|
} else { // Load-Merge-Write
|
||||||
// Load
|
// Load
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx)) < 0) goto _err;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err;
|
||||||
if (blockAtIdx(pHelper, blkIdx)->last) pHelper->hasOldLastBlock = false;
|
if (blockAtIdx(pHelper, blkIdx)->last) pHelper->hasOldLastBlock = false;
|
||||||
|
|
||||||
rowsWritten = rows3;
|
rowsWritten = rows3;
|
||||||
|
|
|
@ -592,9 +592,12 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
|
||||||
pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
|
pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
tdInitDataCols(pCheckInfo->pDataCols, tsdbGetTableSchema(pCheckInfo->pTableObj));
|
STSchema* pSchema = tsdbGetTableSchema(pCheckInfo->pTableObj);
|
||||||
|
tdInitDataCols(pCheckInfo->pDataCols, pSchema);
|
||||||
|
tdInitDataCols(pQueryHandle->rhelper.pDataCols[0], pSchema);
|
||||||
|
tdInitDataCols(pQueryHandle->rhelper.pDataCols[1], pSchema);
|
||||||
|
|
||||||
if (tsdbLoadBlockData(&(pQueryHandle->rhelper), pBlock) == 0) {
|
if (tsdbLoadBlockData(&(pQueryHandle->rhelper), pBlock, pCheckInfo->pCompInfo) == 0) {
|
||||||
SDataBlockLoadInfo* pBlockLoadInfo = &pQueryHandle->dataBlockLoadInfo;
|
SDataBlockLoadInfo* pBlockLoadInfo = &pQueryHandle->dataBlockLoadInfo;
|
||||||
|
|
||||||
pBlockLoadInfo->fileGroup = pQueryHandle->pFileGroup;
|
pBlockLoadInfo->fileGroup = pQueryHandle->pFileGroup;
|
||||||
|
|
Loading…
Reference in New Issue