diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index 2efc33a8ee1350d3c2ee05536eced70b9edc3463..adfbb919206a184664655cc11746c1d25c14147b 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -66,7 +66,6 @@ int32_t metaCacheOpen(SMeta* pMeta); void metaCacheClose(SMeta* pMeta); int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo); int32_t metaCacheDrop(SMeta* pMeta, int64_t uid); -int32_t metaCacheGet(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo); struct SMeta { TdThreadRwlock lock; diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 9c879bf36950842a70879ebfc391731a37324565..9bbff6c6bd2285f752c6b104f5445e3c06927168 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -127,7 +127,7 @@ _err: // return 0; // } -bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) { +bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) { // query uid.idx if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), NULL, NULL) < 0) { return false; @@ -1051,6 +1051,8 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj return TSDB_CODE_SUCCESS; } +int32_t metaCacheGet(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo); + int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo) { int32_t code = 0; void *pData = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 5db02fa285cd675f72aba603d7bd3b6cfed2db9e..00d2ac848f6d599fef54d9957047521e27062c89 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -188,11 +188,16 @@ int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) { n += tPutI32v(p ? p + n : p, pSet->diskId.level); n += tPutI32v(p ? p + n : p, pSet->diskId.id); n += tPutI32v(p ? p + n : p, pSet->fid); + + // data n += tPutHeadFile(p ? p + n : p, pSet->pHeadF); n += tPutDataFile(p ? p + n : p, pSet->pDataF); - n += tPutLastFile(p ? p + n : p, pSet->pLastF); n += tPutSmaFile(p ? p + n : p, pSet->pSmaF); + // last + n += tPutU8(p ? p + n : p, 1); // for future compatibility + n += tPutLastFile(p ? p + n : p, pSet->pLastF); + return n; } @@ -202,11 +207,17 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) { n += tGetI32v(p + n, &pSet->diskId.level); n += tGetI32v(p + n, &pSet->diskId.id); n += tGetI32v(p + n, &pSet->fid); + + // data n += tGetHeadFile(p + n, pSet->pHeadF); n += tGetDataFile(p + n, pSet->pDataF); - n += tGetLastFile(p + n, pSet->pLastF); n += tGetSmaFile(p + n, pSet->pSmaF); + // last + uint8_t nLast; + n += tGetU8(p + n, &nLast); + n += tGetLastFile(p + n, pSet->pLastF); + return n; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index a970b0be74c9468b05525bf71684006fa813fb2e..744f16b113e898659234fe5fc9a522be951bc70d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -30,8 +30,6 @@ struct STsdbSnapReader { SArray* aBlockL; // SArray SBlockIdx* pBlockIdx; SBlockL* pBlockL; - SBlock* pBlock; - SBlock block; int32_t iBlockIdx; int32_t iBlockL; @@ -78,9 +76,6 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { if (code) goto _err; pReader->iBlock = 0; - if (pReader->iBlock < pReader->mBlock.nItem) { - tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, &pReader->block, tGetBlock); - } } else { pReader->pBlockIdx = NULL; } @@ -97,18 +92,16 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { while (true) { if (pReader->pBlockIdx && pReader->pBlockL) { - TABLEID minId = {.suid = pReader->pBlockL->suid, .uid = pReader->pBlockL->minUid}; - TABLEID maxId = {.suid = pReader->pBlockL->suid, .uid = pReader->pBlockL->maxUid}; - - if (tTABLEIDCmprFn(pReader->pBlockIdx, &minId) < 0) { - // TODO - } else if (tTABLEIDCmprFn(pReader->pBlockIdx, &maxId) < 0) { - // TODO - } else { - // TODO - } + TABLEID id = {.suid = pReader->pBlockL->suid, .uid = pReader->pBlockL->minUid}; + + // if (tTABLEIDCmprFn(pReader->pBlockIdx, &minId) < 0) { + // // TODO + // } else if (tTABLEIDCmprFn(pReader->pBlockIdx, &maxId) < 0) { + // // TODO + // } else { + // // TODO + // } } else if (pReader->pBlockIdx) { - // may have problem (todo) while (pReader->iBlock < pReader->mBlock.nItem) { SBlock block; tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, &block, tGetBlock); @@ -119,9 +112,24 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { // next pReader->iBlock++; + if (*ppData) break; + } - if (*ppData) goto _exit; + if (pReader->iBlock >= pReader->mBlock.nItem) { + pReader->iBlockIdx++; + if (pReader->iBlockIdx < taosArrayGetSize(pReader->aBlockIdx)) { + pReader->pBlockIdx = (SBlockIdx*)taosArrayGet(pReader->aBlockIdx, pReader->iBlockIdx); + + code = tsdbReadBlock(pReader->pDataFReader, pReader->pBlockIdx, &pReader->mBlock); + if (code) goto _err; + + pReader->iBlock = 0; + } else { + pReader->pBlockIdx = NULL; + } } + + if (*ppData) goto _exit; } else if (pReader->pBlockL) { while (pReader->pBlockL) { if (pReader->pBlockL->minVer <= pReader->ever && pReader->pBlockL->maxVer >= pReader->sver) {