enh(query): improve the performance and add some todo

This commit is contained in:
Haojun Liao 2022-12-03 12:11:20 +08:00
parent de0022b473
commit 658cb393a7
3 changed files with 10 additions and 8 deletions

View File

@ -129,6 +129,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
void* pData = NULL;
pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES);
// todo avoid repeated malloc memory
size_t keyLen = 0;
int32_t iter = 0;
while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {

View File

@ -165,10 +165,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
colDataDestroy(out.columnData);
taosMemoryFreeClear(out.columnData);
out.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
colInfoDataCleanup(out.columnData, out.numOfRows);
cell = cell->pNext;
}

View File

@ -30,6 +30,7 @@ struct SDiskbasedBuf {
TdFilePtr pFile;
int32_t allocateId; // allocated page id
char* path; // file path
char* prefix; // file name prefix
int32_t pageSize; // current used page size
int32_t inMemPages; // numOfPages that are allocated in memory
SList* freePgList; // free page list
@ -48,6 +49,12 @@ struct SDiskbasedBuf {
};
static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
if (pBuf->path[0] == '\0') { // prepare the file name when needed it
char path[PATH_MAX] = {0};
taosGetTmpfilePath(pBuf->prefix, "paged-buf", path);
pBuf->path = taosMemoryStrDup(path);
}
pBuf->pFile =
taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
if (pBuf->pFile == NULL) {
@ -356,10 +363,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
pPBuf->assistBuf = taosMemoryMalloc(pPBuf->pageSize + 2); // EXTRA BYTES
pPBuf->all = taosHashInit(10, fn, true, false);
char path[PATH_MAX] = {0};
taosGetTmpfilePath(dir, "paged-buf", path);
pPBuf->path = strdup(path);
pPBuf->prefix = (char*) dir;
pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));