refact
This commit is contained in:
parent
f184d1d3d4
commit
27f465a884
|
@ -27,13 +27,13 @@ typedef struct STbUidGenerator {
|
|||
tb_uid_t nextUid;
|
||||
} STbUidGenerator;
|
||||
|
||||
// STableUidGenerator
|
||||
int metaOpenUidGnrt(SMeta *pMeta);
|
||||
void metaCloseUidGnrt(SMeta *pMeta);
|
||||
|
||||
// tb_uid_t
|
||||
#define IVLD_TB_UID 0
|
||||
tb_uid_t generateUid(STbUidGenerator *);
|
||||
|
||||
// STableUidGenerator
|
||||
void tableUidGeneratorInit(STbUidGenerator *, tb_uid_t suid);
|
||||
#define tableUidGeneratorClear(ug)
|
||||
tb_uid_t metaGenerateUid(SMeta *pMeta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -44,25 +44,41 @@ SMeta *metaOpen(const char *path, const SMetaOptions *pMetaOptions) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Create META path
|
||||
// Create META path (TODO)
|
||||
taosMkDir(path);
|
||||
|
||||
// Open the DBs needed
|
||||
if (metaOpenDB(pMeta) < 0) {
|
||||
// Open meta cache
|
||||
if (metaOpenCache(pMeta) < 0) {
|
||||
// TODO: handle error
|
||||
metaFree(pMeta);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tableUidGeneratorInit(&(pMeta->uidGnrt), IVLD_TB_UID);
|
||||
// Open meta db
|
||||
if (metaOpenDB(pMeta) < 0) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Open meta index
|
||||
if (metaOpenIdx(pMeta) < 0) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Open meta table uid generator
|
||||
if (metaOpenUidGnrt(pMeta) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pMeta;
|
||||
}
|
||||
|
||||
void metaClose(SMeta *pMeta) {
|
||||
if (pMeta) {
|
||||
tableUidGeneratorClear(&pMeta->uidGnrt);
|
||||
metaCloseUidGnrt(pMeta);
|
||||
metaCloseIdx(pMeta);
|
||||
metaCloseDB(pMeta);
|
||||
metaCloseCache(pMeta);
|
||||
metaFree(pMeta);
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +97,7 @@ static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions) {
|
|||
|
||||
pMeta->path = strdup(path);
|
||||
if (pMeta->path == NULL) {
|
||||
metaFree(pMeta);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "metaTbUid.h"
|
||||
#include "meta.h"
|
||||
#include "metaDef.h"
|
||||
|
||||
tb_uid_t generateUid(STbUidGenerator *pGen) {
|
||||
// Generate a new table UID
|
||||
return ++(pGen->nextUid);
|
||||
int metaOpenUidGnrt(SMeta *pMeta) {
|
||||
// Init a generator
|
||||
pMeta->uidGnrt.nextUid = IVLD_TB_UID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tableUidGeneratorInit(STbUidGenerator *pGen, tb_uid_t suid) {
|
||||
// Init a generator
|
||||
pGen->nextUid = suid;
|
||||
void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */ }
|
||||
|
||||
tb_uid_t metaGenerateUid(SMeta *pMeta) {
|
||||
// Generate a new table UID
|
||||
return ++(pMeta->uidGnrt.nextUid);
|
||||
}
|
Loading…
Reference in New Issue