This commit is contained in:
Hongze Cheng 2022-03-29 07:15:07 +00:00
parent 5d1d22552a
commit e9585e74f7
1 changed files with 44 additions and 8 deletions

View File

@ -458,23 +458,59 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
struct SMCtbCursor { struct SMCtbCursor {
TDBC *pCur; TDBC *pCur;
tb_uid_t suid; tb_uid_t suid;
void *pKey;
void *pVal;
int kLen;
int vLen;
}; };
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) { SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
// TODO SMCtbCursor *pCtbCur = NULL;
ASSERT(0); SMetaDB *pDB = pMeta->pDB;
return NULL; int ret;
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
if (pCtbCur == NULL) {
return NULL;
}
pCtbCur->suid = uid;
ret = tdbDbcOpen(pDB->pCtbIdx, &pCtbCur->pCur);
if (ret < 0) {
taosMemoryFree(pCtbCur);
return NULL;
}
// TODO: move the cursor to the suid there
return pCtbCur;
} }
void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) { void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) {
// TODO if (pCtbCur) {
ASSERT(0); if (pCtbCur->pCur) {
tdbDbcClose(pCtbCur->pCur);
TDB_FREE(pCtbCur->pKey);
TDB_FREE(pCtbCur->pVal);
}
taosMemoryFree(pCtbCur);
}
} }
tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) { tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
// TODO int ret;
ASSERT(0); SCtbIdxKey *pCtbIdxKey;
return 0;
ret = tdbDbNext(pCtbCur->pCur, &pCtbCur->pKey, &pCtbCur->kLen, &pCtbCur->pVal, &pCtbCur->vLen);
if (ret < 0) {
return 0;
}
pCtbIdxKey = pCtbCur->pVal;
return pCtbIdxKey->uid;
} }
int metaGetTbNum(SMeta *pMeta) { int metaGetTbNum(SMeta *pMeta) {