提交 4f16771d 编写于 作者: wmmhello's avatar wmmhello

fix:error in get table list by tag filter

上级 171ce325
......@@ -91,7 +91,7 @@ typedef struct SMetaEntry SMetaEntry;
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags);
void metaReaderClear(SMetaReader *pReader);
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *tags);
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags);
int32_t metaReadNext(SMetaReader *pReader);
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
......
......@@ -962,13 +962,13 @@ END:
return ret;
}
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *tags) {
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) {
SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid);
SHashObj *uHash = NULL;
size_t len = taosArrayGetSize(uidList); // len > 0 means there already have uids
if(len > 0){
uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
for(int i = 0; i < len; i++){
int64_t *uid = taosArrayGet(uidList, i);
taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i));
......@@ -982,26 +982,13 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *t
if (len > 0 && taosHashGet(uHash, &id, sizeof(int64_t)) == NULL) {
continue;
}
void *tag = taosMemoryMalloc(pCur->vLen);
memcpy(tag, pCur->pVal, pCur->vLen);
if (len == 0) {
}else if (len == 0) {
taosArrayPush(uidList, &id);
taosArrayPush(tags, &tag);
}else{
taosHashPut(uHash, &id, sizeof(int64_t), &tag, POINTER_BYTES);
}
}
for(int i = 0; i < len; i++){
int64_t *uid = taosArrayGet(uidList, i);
void **tag = taosHashGet(uHash, uid, POINTER_BYTES);
taosArrayPush(tags, tag);
taosHashPut(tags, &id, sizeof(int64_t), pCur->pVal, pCur->vLen);
}
taosHashCleanup(uHash);
metaCloseCtbCursor(pCur);
return TSDB_CODE_SUCCESS;
......
......@@ -368,7 +368,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
int32_t code = TSDB_CODE_SUCCESS;
SArray* pBlockList = NULL;
SSDataBlock* pResBlock = NULL;
SArray* tags = NULL;
SHashObj * tags = NULL;
SScalarParam output = {0};
tagFilterAssist ctx = {0};
......@@ -399,7 +399,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
}
// int64_t stt = taosGetTimestampUs();
tags = taosArrayInit(8, POINTER_BYTES);
tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
code = metaGetTableTags(metaHandle, suid, uidList, tags);
if (code != TSDB_CODE_SUCCESS) {
terrno = code;
......@@ -421,8 +421,9 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
// int64_t st = taosGetTimestampUs();
for (int32_t i = 0; i < rows; i++) {
void* tag = taosArrayGetP(tags, i);
int64_t* uid = taosArrayGet(uidList, i);
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
ASSERT(tag);
for(int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++){
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j);
......@@ -474,7 +475,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
end:
taosArrayDestroyP(tags, taosMemoryFree);
taosHashCleanup(tags);
taosHashCleanup(ctx.colHash);
taosArrayDestroy(ctx.cInfoList);
blockDataDestroy(pResBlock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册