提交 2bf2d5e6 编写于 作者: wmmhello's avatar wmmhello

fix:error in get table list by tag filter

上级 d5a8b397
...@@ -965,10 +965,11 @@ END: ...@@ -965,10 +965,11 @@ END:
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *tags) { int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *tags) {
SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid); SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid);
SHashObj *uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); SHashObj *uHash = NULL;
size_t len = taosArrayGetSize(uidList); size_t len = taosArrayGetSize(uidList); // len > 0 means there already have uids
if (len > 0) { if(len > 0){
for (int i = 0; i < len; i++) { uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
for(int i = 0; i < len; i++){
int64_t *uid = taosArrayGet(uidList, i); int64_t *uid = taosArrayGet(uidList, i);
taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i)); taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i));
} }
...@@ -985,13 +986,22 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *t ...@@ -985,13 +986,22 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SArray *t
void *tag = taosMemoryMalloc(pCur->vLen); void *tag = taosMemoryMalloc(pCur->vLen);
memcpy(tag, pCur->pVal, pCur->vLen); memcpy(tag, pCur->pVal, pCur->vLen);
taosArrayPush(tags, &tag);
if (len == 0) { if (len == 0) {
taosArrayPush(uidList, &id); 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);
}
taosHashCleanup(uHash); taosHashCleanup(uHash);
metaCloseCtbCursor(pCur); metaCloseCtbCursor(pCur);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
...@@ -321,6 +321,8 @@ static EDealRes getColumn(SNode** pNode, void* pContext) { ...@@ -321,6 +321,8 @@ static EDealRes getColumn(SNode** pNode, void* pContext) {
pSColumnNode->node.resType.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE; pSColumnNode->node.resType.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
*pNode = (SNode*)pSColumnNode; *pNode = (SNode*)pSColumnNode;
}else{
return DEAL_RES_CONTINUE;
} }
}else{ }else{
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
...@@ -423,11 +425,16 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray ...@@ -423,11 +425,16 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
int64_t* uid = taosArrayGet(uidList, i); int64_t* uid = taosArrayGet(uidList, i);
for(int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++){ for(int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++){
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j); SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j);
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
metaGetTableNameByUid(metaHandle, *uid, str);
colDataAppend(pColInfo, i, str, false);
if(pColInfo->info.colId == -1){ // tbname if(pColInfo->info.colId == -1){ // tbname
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; // char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
metaGetTableNameByUid(metaHandle, *uid, str); // metaGetTableNameByUid(metaHandle, *uid, str);
colDataAppend(pColInfo, i, str, false); // colDataAppend(pColInfo, i, str, false);
qDebug("tbnameget uid:%ld, tbname:%s", *uid, str+2); // qDebug("tagfilter uid:%ld, tbname:%s", *uid, str+2);
}else{ }else{
STagVal tagVal = {0}; STagVal tagVal = {0};
tagVal.cid = pColInfo->info.colId; tagVal.cid = pColInfo->info.colId;
...@@ -445,6 +452,16 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray ...@@ -445,6 +452,16 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
taosMemoryFree(tmp); taosMemoryFree(tmp);
} else { } else {
colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false); colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false);
if(pColInfo->info.type == TSDB_DATA_TYPE_TINYINT){
int8_t tint = *(int8_t*)(&tagVal.i64);
qDebug("tagfilter uid:%ld, tbname:%s, tint:%d", *uid, str+2, tint);
}else if(pColInfo->info.type == TSDB_DATA_TYPE_INT){
int nint = *(int*)(&tagVal.i64);
qDebug("tagfilter uid:%ld, tbname:%s nint:+%d", *uid, str+2, nint);
}
} }
} }
} }
...@@ -529,7 +546,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, ...@@ -529,7 +546,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
int64_t* uid = taosArrayGet(res, i); int64_t* uid = taosArrayGet(res, i);
qDebug("tbnameget get uid:%ld, res:%d", *uid, *(bool*)var); qDebug("tagfilter get uid:%ld, res:%d", *uid, *(bool*)var);
if (*(bool*)var == false) { if (*(bool*)var == false) {
taosArrayRemove(res, i); taosArrayRemove(res, i);
j++; j++;
...@@ -545,7 +562,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, ...@@ -545,7 +562,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
for (int i = 0; i < taosArrayGetSize(res); i++) { for (int i = 0; i < taosArrayGetSize(res); i++) {
STableKeyInfo info = {.uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0}; STableKeyInfo info = {.uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0};
taosArrayPush(pListInfo->pTableList, &info); taosArrayPush(pListInfo->pTableList, &info);
qDebug("tbnameget get uid:%ld", info.uid); qDebug("tagfilter get uid:%ld", info.uid);
} }
taosArrayDestroy(res); taosArrayDestroy(res);
......
...@@ -1672,8 +1672,9 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, ...@@ -1672,8 +1672,9 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);\ colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);\
}else{\ }else{\
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);\ bool res = filterDoCompare(fp, optr, pLeftData, pRightData);\
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);\ colDataAppendInt8(pOut->columnData, i, (int8_t*)&res); \
}\ if(GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT){qDebug("tagfilter left:%d, right:%d, res:%d", *(int64_t*)(pLeftData), *(int64_t*)(pRightData), res);} \
} \
if(freeLeft) taosMemoryFreeClear(pLeftData);\ if(freeLeft) taosMemoryFreeClear(pLeftData);\
if(freeRight) taosMemoryFreeClear(pRightData);\ if(freeRight) taosMemoryFreeClear(pRightData);\
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册