opt query performance.
This commit is contained in:
parent
399fa20915
commit
5741c02651
|
@ -526,6 +526,13 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
SCompInfo *compInfo = (SCompInfo *)(data + compHeader->compInfoOffset);
|
SCompInfo *compInfo = (SCompInfo *)(data + compHeader->compInfoOffset);
|
||||||
#else
|
#else
|
||||||
SCompHeader *compHeader = (SCompHeader *)(buf + sizeof(SCompHeader) * pMeterObj->sid);
|
SCompHeader *compHeader = (SCompHeader *)(buf + sizeof(SCompHeader) * pMeterObj->sid);
|
||||||
|
|
||||||
|
// no data in this file for specified meter, abort
|
||||||
|
if (compHeader->compInfoOffset == 0) {
|
||||||
|
free(buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
lseek(pVnodeFileInfo->headerFd, compHeader->compInfoOffset, SEEK_SET);
|
lseek(pVnodeFileInfo->headerFd, compHeader->compInfoOffset, SEEK_SET);
|
||||||
|
|
||||||
SCompInfo CompInfo = {0};
|
SCompInfo CompInfo = {0};
|
||||||
|
@ -547,8 +554,13 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
vnodeFreeFieldsEx(pRuntimeEnv);
|
vnodeFreeFieldsEx(pRuntimeEnv);
|
||||||
pQuery->numOfBlocks = (int32_t)compInfo->numOfBlocks;
|
pQuery->numOfBlocks = (int32_t)compInfo->numOfBlocks;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* +-------------+-----------+----------------+
|
||||||
|
* | comp block | checksum | SField Pointer |
|
||||||
|
* +-------------+-----------+----------------+
|
||||||
|
*/
|
||||||
int32_t compBlockSize = compInfo->numOfBlocks * sizeof(SCompBlock);
|
int32_t compBlockSize = compInfo->numOfBlocks * sizeof(SCompBlock);
|
||||||
size_t bufferSize = compBlockSize + sizeof(TSCKSUM);
|
size_t bufferSize = compBlockSize + sizeof(TSCKSUM) + POINTER_BYTES * pQuery->numOfBlocks;
|
||||||
|
|
||||||
// prepare buffer to hold compblock data
|
// prepare buffer to hold compblock data
|
||||||
if (pQuery->blockBufferSize != bufferSize) {
|
if (pQuery->blockBufferSize != bufferSize) {
|
||||||
|
@ -562,7 +574,8 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
memcpy(pQuery->pBlock, (char *)compInfo + sizeof(SCompInfo), (size_t)compBlockSize);
|
memcpy(pQuery->pBlock, (char *)compInfo + sizeof(SCompInfo), (size_t)compBlockSize);
|
||||||
TSCKSUM checksum = *(TSCKSUM *)((char *)compInfo + sizeof(SCompInfo) + compBlockSize);
|
TSCKSUM checksum = *(TSCKSUM *)((char *)compInfo + sizeof(SCompInfo) + compBlockSize);
|
||||||
#else
|
#else
|
||||||
read(pVnodeFileInfo->headerFd, pQuery->pBlock, bufferSize);
|
// read data: comp block + checksum
|
||||||
|
read(pVnodeFileInfo->headerFd, pQuery->pBlock, compBlockSize + sizeof(TSCKSUM));
|
||||||
TSCKSUM checksum = *(TSCKSUM*)((char*)pQuery->pBlock + compBlockSize);
|
TSCKSUM checksum = *(TSCKSUM*)((char*)pQuery->pBlock + compBlockSize);
|
||||||
// read(pVnodeFileInfo->headerFd, &checksum, sizeof(TSCKSUM));
|
// read(pVnodeFileInfo->headerFd, &checksum, sizeof(TSCKSUM));
|
||||||
#endif
|
#endif
|
||||||
|
@ -573,7 +586,7 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
return -1; //TODO free resource in error process
|
return -1; //TODO free resource in error process
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->pFields = (SField **)((char *)pQuery->pBlock + compBlockSize);
|
pQuery->pFields = (SField **)((char *)pQuery->pBlock + compBlockSize + sizeof(TSCKSUM));
|
||||||
vnodeSetCompBlockInfoLoaded(pRuntimeEnv, fileIndex, pMeterObj->sid);
|
vnodeSetCompBlockInfoLoaded(pRuntimeEnv, fileIndex, pMeterObj->sid);
|
||||||
|
|
||||||
int64_t et = taosGetTimestampUs();
|
int64_t et = taosGetTimestampUs();
|
||||||
|
|
Loading…
Reference in New Issue