cache/read: lazy init uidList when laoding from tsdb
This commit is contained in:
parent
b3fae65d90
commit
c0a0e07597
|
@ -1615,10 +1615,37 @@ static STableLoadInfo *getTableLoadInfo(SCacheRowsReader *pReader, uint64_t uid)
|
|||
return pInfo;
|
||||
}
|
||||
|
||||
static int32_t uidComparFunc(const void *p1, const void *p2) {
|
||||
uint64_t pu1 = *(uint64_t *)p1;
|
||||
uint64_t pu2 = *(uint64_t *)p2;
|
||||
if (pu1 == pu2) {
|
||||
return 0;
|
||||
} else {
|
||||
return (pu1 < pu2) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t *getUidList(SCacheRowsReader *pReader) {
|
||||
if (!pReader->uidList) {
|
||||
int32_t numOfTables = pReader->numOfTables;
|
||||
|
||||
pReader->uidList = taosMemoryMalloc(numOfTables * sizeof(uint64_t));
|
||||
|
||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||
uint64_t uid = pReader->pTableList[i].uid;
|
||||
pReader->uidList[i] = uid;
|
||||
}
|
||||
|
||||
taosSort(pReader->uidList, numOfTables, sizeof(uint64_t), uidComparFunc);
|
||||
}
|
||||
|
||||
return pReader->uidList;
|
||||
}
|
||||
|
||||
static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsReader *pReader, void *pFileReader,
|
||||
bool isFile) {
|
||||
int32_t code = 0;
|
||||
uint64_t *uidList = pReader->uidList;
|
||||
uint64_t *uidList = getUidList(pReader);
|
||||
int32_t numOfTables = pReader->numOfTables;
|
||||
int64_t suid = pReader->info.suid;
|
||||
|
||||
|
|
|
@ -133,16 +133,6 @@ int32_t tsdbReuseCacherowsReader(void* reader, void* pTableIdList, int32_t numOf
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t uidComparFunc(const void* p1, const void* p2) {
|
||||
uint64_t pu1 = *(uint64_t*)p1;
|
||||
uint64_t pu2 = *(uint64_t*)p2;
|
||||
if (pu1 == pu2) {
|
||||
return 0;
|
||||
} else {
|
||||
return (pu1 < pu2) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
SArray* pCidList, int32_t* pSlotIds, uint64_t suid, void** pReader, const char* idstr) {
|
||||
*pReader = NULL;
|
||||
|
@ -168,19 +158,6 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
|||
p->pTableList = pTableIdList;
|
||||
p->numOfTables = numOfTables;
|
||||
|
||||
p->uidList = taosMemoryMalloc(numOfTables * sizeof(uint64_t));
|
||||
if (p->uidList == NULL) {
|
||||
tsdbCacherowsReaderClose(p);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||
uint64_t uid = p->pTableList[i].uid;
|
||||
p->uidList[i] = uid;
|
||||
}
|
||||
|
||||
taosSort(p->uidList, numOfTables, sizeof(uint64_t), uidComparFunc);
|
||||
|
||||
int32_t code = setTableSchema(p, suid, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbCacherowsReaderClose(p);
|
||||
|
|
Loading…
Reference in New Issue