This commit is contained in:
Hongze Cheng 2021-12-16 15:28:53 +08:00
parent d0d56645a9
commit 835c3030c5
5 changed files with 13 additions and 10 deletions

View File

@ -16,6 +16,7 @@
#ifndef _TD_META_H_ #ifndef _TD_META_H_
#define _TD_META_H_ #define _TD_META_H_
#include "mallocator.h"
#include "os.h" #include "os.h"
#include "trow.h" #include "trow.h"
@ -71,7 +72,7 @@ typedef struct STbCfg {
} STbCfg; } STbCfg;
// SMeta operations // SMeta operations
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg); SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
void metaClose(SMeta *pMeta); void metaClose(SMeta *pMeta);
void metaRemove(const char *path); void metaRemove(const char *path);
int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg); int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg);

View File

@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open meta // Open meta
sprintf(dir, "%s/meta", pVnode->path); sprintf(dir, "%s/meta", pVnode->path);
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg)); pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg), vBufPoolGetMAF(pVnode));
if (pVnode->pMeta == NULL) { if (pVnode->pMeta == NULL) {
// TODO: handle error // TODO: handle error
return -1; return -1;

View File

@ -34,7 +34,7 @@ extern "C" {
struct SMeta { struct SMeta {
char* path; char* path;
SMetaCfg options; SMetaCfg options;
SMetaDB* pDB; SMetaDB* pDB;
SMetaIdx* pIdx; SMetaIdx* pIdx;
SMetaCache* pCache; SMetaCache* pCache;
STbUidGenerator uidGnrt; STbUidGenerator uidGnrt;

View File

@ -17,12 +17,12 @@
#include "metaDef.h" #include "metaDef.h"
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg); static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
static void metaFree(SMeta *pMeta); static void metaFree(SMeta *pMeta);
static int metaOpenImpl(SMeta *pMeta); static int metaOpenImpl(SMeta *pMeta);
static void metaCloseImpl(SMeta *pMeta); static void metaCloseImpl(SMeta *pMeta);
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg) { SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
SMeta *pMeta = NULL; SMeta *pMeta = NULL;
// Set default options // Set default options
@ -37,7 +37,7 @@ SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg) {
} }
// Allocate handle // Allocate handle
pMeta = metaNew(path, pMetaCfg); pMeta = metaNew(path, pMetaCfg, pMAF);
if (pMeta == NULL) { if (pMeta == NULL) {
// TODO: handle error // TODO: handle error
return NULL; return NULL;
@ -65,7 +65,7 @@ void metaClose(SMeta *pMeta) {
void metaRemove(const char *path) { taosRemoveDir(path); } void metaRemove(const char *path) { taosRemoveDir(path); }
/* ------------------------ STATIC METHODS ------------------------ */ /* ------------------------ STATIC METHODS ------------------------ */
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg) { static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
SMeta *pMeta; SMeta *pMeta;
size_t psize = strlen(path); size_t psize = strlen(path);
@ -81,6 +81,7 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg) {
} }
metaOptionsCopy(&(pMeta->options), pMetaCfg); metaOptionsCopy(&(pMeta->options), pMetaCfg);
pMeta->pmaf = pMAF;
return pMeta; return pMeta;
}; };

View File

@ -15,7 +15,7 @@
#include "tsdbDef.h" #include "tsdbDef.h"
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg); static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF);
static void tsdbFree(STsdb *pTsdb); static void tsdbFree(STsdb *pTsdb);
static int tsdbOpenImpl(STsdb *pTsdb); static int tsdbOpenImpl(STsdb *pTsdb);
static void tsdbCloseImpl(STsdb *pTsdb); static void tsdbCloseImpl(STsdb *pTsdb);
@ -35,7 +35,7 @@ STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory
} }
// Create the handle // Create the handle
pTsdb = tsdbNew(path, pTsdbCfg); pTsdb = tsdbNew(path, pTsdbCfg, pMAF);
if (pTsdb == NULL) { if (pTsdb == NULL) {
// TODO: handle error // TODO: handle error
return NULL; return NULL;
@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) {
void tsdbRemove(const char *path) { taosRemoveDir(path); } void tsdbRemove(const char *path) { taosRemoveDir(path); }
/* ------------------------ STATIC METHODS ------------------------ */ /* ------------------------ STATIC METHODS ------------------------ */
static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg) { static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF) {
STsdb *pTsdb = NULL; STsdb *pTsdb = NULL;
pTsdb = (STsdb *)calloc(1, sizeof(STsdb)); pTsdb = (STsdb *)calloc(1, sizeof(STsdb));
@ -73,6 +73,7 @@ static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbCfg) {
pTsdb->path = strdup(path); pTsdb->path = strdup(path);
tsdbOptionsCopy(&(pTsdb->options), pTsdbCfg); tsdbOptionsCopy(&(pTsdb->options), pTsdbCfg);
pTsdb->pmaf = pMAF;
return pTsdb; return pTsdb;
} }