提交 a036d64a 编写于 作者: dengyihao's avatar dengyihao

avoid filter invalid table

上级 4f16771d
...@@ -53,79 +53,79 @@ _err: ...@@ -53,79 +53,79 @@ _err:
return -1; return -1;
} }
//int metaGetTableEntryByUidTest(void* meta, SArray *uidList) { // int metaGetTableEntryByUidTest(void* meta, SArray *uidList) {
// //
// SArray* readerList = taosArrayInit(taosArrayGetSize(uidList), sizeof(SMetaReader)); // SArray* readerList = taosArrayInit(taosArrayGetSize(uidList), sizeof(SMetaReader));
// SArray* uidVersion = taosArrayInit(taosArrayGetSize(uidList), sizeof(STbDbKey)); // SArray* uidVersion = taosArrayInit(taosArrayGetSize(uidList), sizeof(STbDbKey));
// SMeta *pMeta = meta; // SMeta *pMeta = meta;
// int64_t version; // int64_t version;
// SHashObj *uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); // SHashObj *uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
// //
// int64_t stt1 = taosGetTimestampUs(); // int64_t stt1 = taosGetTimestampUs();
// for(int i = 0; i < taosArrayGetSize(uidList); i++) { // for(int i = 0; i < taosArrayGetSize(uidList); i++) {
// void* ppVal = NULL; // void* ppVal = NULL;
// int vlen = 0; // int vlen = 0;
// uint64_t * uid = taosArrayGet(uidList, i); // uint64_t * uid = taosArrayGet(uidList, i);
// // query uid.idx // // query uid.idx
// if (tdbTbGet(pMeta->pUidIdx, uid, sizeof(*uid), &ppVal, &vlen) < 0) { // if (tdbTbGet(pMeta->pUidIdx, uid, sizeof(*uid), &ppVal, &vlen) < 0) {
// continue; // continue;
// } // }
// version = *(int64_t *)ppVal; // version = *(int64_t *)ppVal;
// //
// STbDbKey tbDbKey = {.version = version, .uid = *uid}; // STbDbKey tbDbKey = {.version = version, .uid = *uid};
// taosArrayPush(uidVersion, &tbDbKey); // taosArrayPush(uidVersion, &tbDbKey);
// taosHashPut(uHash, uid, sizeof(int64_t), ppVal, sizeof(int64_t)); // taosHashPut(uHash, uid, sizeof(int64_t), ppVal, sizeof(int64_t));
// } // }
// int64_t stt2 = taosGetTimestampUs(); // int64_t stt2 = taosGetTimestampUs();
// qDebug("metaGetTableEntryByUidTest1 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt2-stt1); // qDebug("metaGetTableEntryByUidTest1 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt2-stt1);
// //
// TBC *pCur = NULL; // TBC *pCur = NULL;
// tdbTbcOpen(pMeta->pTbDb, &pCur, NULL); // tdbTbcOpen(pMeta->pTbDb, &pCur, NULL);
// tdbTbcMoveToFirst(pCur); // tdbTbcMoveToFirst(pCur);
// void *pKey = NULL; // void *pKey = NULL;
// int kLen = 0; // int kLen = 0;
// //
// while(1){ // while(1){
// SMetaReader pReader = {0}; // SMetaReader pReader = {0};
// int32_t ret = tdbTbcNext(pCur, &pKey, &kLen, &pReader.pBuf, &pReader.szBuf); // int32_t ret = tdbTbcNext(pCur, &pKey, &kLen, &pReader.pBuf, &pReader.szBuf);
// if (ret < 0) break; // if (ret < 0) break;
// STbDbKey *tmp = (STbDbKey*)pKey; // STbDbKey *tmp = (STbDbKey*)pKey;
// int64_t *ver = (int64_t*)taosHashGet(uHash, &tmp->uid, sizeof(int64_t)); // int64_t *ver = (int64_t*)taosHashGet(uHash, &tmp->uid, sizeof(int64_t));
// if(ver == NULL || *ver != tmp->version) continue; // if(ver == NULL || *ver != tmp->version) continue;
// taosArrayPush(readerList, &pReader); // taosArrayPush(readerList, &pReader);
// } // }
// tdbTbcClose(pCur); // tdbTbcClose(pCur);
// //
// taosArrayClear(readerList); // taosArrayClear(readerList);
// int64_t stt3 = taosGetTimestampUs(); // int64_t stt3 = taosGetTimestampUs();
// qDebug("metaGetTableEntryByUidTest2 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt3-stt2); // qDebug("metaGetTableEntryByUidTest2 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt3-stt2);
// for(int i = 0; i < taosArrayGetSize(uidVersion); i++) { // for(int i = 0; i < taosArrayGetSize(uidVersion); i++) {
// SMetaReader pReader = {0}; // SMetaReader pReader = {0};
// //
// STbDbKey *tbDbKey = taosArrayGet(uidVersion, i); // STbDbKey *tbDbKey = taosArrayGet(uidVersion, i);
// // query table.db // // query table.db
// if (tdbTbGet(pMeta->pTbDb, tbDbKey, sizeof(STbDbKey), &pReader.pBuf, &pReader.szBuf) < 0) { // if (tdbTbGet(pMeta->pTbDb, tbDbKey, sizeof(STbDbKey), &pReader.pBuf, &pReader.szBuf) < 0) {
// continue; // continue;
// } // }
// taosArrayPush(readerList, &pReader); // taosArrayPush(readerList, &pReader);
// } // }
// int64_t stt4 = taosGetTimestampUs(); // int64_t stt4 = taosGetTimestampUs();
// qDebug("metaGetTableEntryByUidTest3 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt4-stt3); // qDebug("metaGetTableEntryByUidTest3 rows:%d, cost:%ld us", taosArrayGetSize(uidList), stt4-stt3);
// //
// for(int i = 0; i < taosArrayGetSize(readerList); i++){ // for(int i = 0; i < taosArrayGetSize(readerList); i++){
// SMetaReader* pReader = taosArrayGet(readerList, i); // SMetaReader* pReader = taosArrayGet(readerList, i);
// metaReaderInit(pReader, meta, 0); // metaReaderInit(pReader, meta, 0);
// // decode the entry // // decode the entry
// tDecoderInit(&pReader->coder, pReader->pBuf, pReader->szBuf); // tDecoderInit(&pReader->coder, pReader->pBuf, pReader->szBuf);
// //
// if (metaDecodeEntry(&pReader->coder, &pReader->me) < 0) { // if (metaDecodeEntry(&pReader->coder, &pReader->me) < 0) {
// } // }
// metaReaderClear(pReader); // metaReaderClear(pReader);
// } // }
// int64_t stt5 = taosGetTimestampUs(); // int64_t stt5 = taosGetTimestampUs();
// qDebug("metaGetTableEntryByUidTest4 rows:%d, cost:%ld us", taosArrayGetSize(readerList), stt5-stt4); // qDebug("metaGetTableEntryByUidTest4 rows:%d, cost:%ld us", taosArrayGetSize(readerList), stt5-stt4);
// return 0; // return 0;
//} // }
int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) { int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
SMeta *pMeta = pReader->pMeta; SMeta *pMeta = pReader->pMeta;
...@@ -824,7 +824,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) { ...@@ -824,7 +824,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
#endif #endif
const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) { const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) {
STag *tag = (STag*) pTag; STag *tag = (STag *)pTag;
if (type == TSDB_DATA_TYPE_JSON) { if (type == TSDB_DATA_TYPE_JSON) {
return tag; return tag;
} }
...@@ -926,6 +926,9 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { ...@@ -926,6 +926,9 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
break; break;
} }
} }
if (p->suid != pKey->suid) {
break;
}
first = false; first = false;
if (p != NULL) { if (p != NULL) {
int32_t cmp = (*param->filterFunc)(p->data, pKey->data, pKey->type); int32_t cmp = (*param->filterFunc)(p->data, pKey->data, pKey->type);
...@@ -966,10 +969,10 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj ...@@ -966,10 +969,10 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj
SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid); SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid);
SHashObj *uHash = NULL; SHashObj *uHash = NULL;
size_t len = taosArrayGetSize(uidList); // len > 0 means there already have uids size_t len = taosArrayGetSize(uidList); // len > 0 means there already have uids
if(len > 0){ if (len > 0) {
uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
for(int i = 0; i < len; i++){ 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));
} }
...@@ -982,7 +985,7 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj ...@@ -982,7 +985,7 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj
if (len > 0 && taosHashGet(uHash, &id, sizeof(int64_t)) == NULL) { if (len > 0 && taosHashGet(uHash, &id, sizeof(int64_t)) == NULL) {
continue; continue;
}else if (len == 0) { } else if (len == 0) {
taosArrayPush(uidList, &id); taosArrayPush(uidList, &id);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册