refact
This commit is contained in:
parent
e9bf4fceb0
commit
1984f40316
|
@ -25,9 +25,9 @@ extern "C" {
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
char* path; // path of current meta
|
char* path; // path of current meta
|
||||||
STbUidGenerator uidGenerator; // meta table UID generator
|
|
||||||
SMetaDB* pMetaDB; // meta DB for real storage engine
|
|
||||||
SMetaOptions options; // meta option
|
SMetaOptions options; // meta option
|
||||||
|
SMetaDB* pMetaDB; // meta DB for real storage engine
|
||||||
|
STbUidGenerator uidGenerator; // meta table UID generator
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -12,3 +12,10 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "meta.h"
|
||||||
|
|
||||||
|
int metaCommit(SMeta *pMeta) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -16,9 +16,9 @@
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
#include "metaDB.h"
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
#include "metaOptions.h"
|
#include "metaOptions.h"
|
||||||
#include "metaDB.h"
|
|
||||||
|
|
||||||
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions);
|
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions);
|
||||||
static void metaFree(SMeta *pMeta);
|
static void metaFree(SMeta *pMeta);
|
||||||
|
@ -57,6 +57,8 @@ SMeta *metaOpen(const char *path, const SMetaOptions *pMetaOptions) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tableUidGeneratorInit(&(pMeta->uidGenerator), IVLD_TB_UID);
|
||||||
|
|
||||||
return pMeta;
|
return pMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,33 +70,7 @@ void metaClose(SMeta *pMeta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
void metaRemove(const char *path) { taosRemoveDir(path); }
|
||||||
int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
|
|
||||||
size_t vallen;
|
|
||||||
char * pUid;
|
|
||||||
|
|
||||||
// Check if table already exists
|
|
||||||
pUid = tkvGet(pMeta->tbnameDb, NULL, pTableOpts->name, strlen(pTableOpts->name), &vallen);
|
|
||||||
if (pUid) {
|
|
||||||
free(pUid);
|
|
||||||
// Table already exists, return error code
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (pTableOpts->type) {
|
|
||||||
case META_SUPER_TABLE:
|
|
||||||
return metaCreateSuperTable(pMeta, pTableOpts->name, &(pTableOpts->superOpts));
|
|
||||||
case META_CHILD_TABLE:
|
|
||||||
return metaCreateChildTable(pMeta, pTableOpts->name, &(pTableOpts->childOpts));
|
|
||||||
case META_NORMAL_TABLE:
|
|
||||||
return metaCreateNormalTable(pMeta, pTableOpts->name, &(pTableOpts->normalOpts));
|
|
||||||
default:
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
||||||
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions) {
|
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions) {
|
||||||
|
@ -125,6 +101,32 @@ static void metaFree(SMeta *pMeta) {
|
||||||
|
|
||||||
// OLD -------------------------------------------------------------------
|
// OLD -------------------------------------------------------------------
|
||||||
#if 0
|
#if 0
|
||||||
|
int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
|
||||||
|
size_t vallen;
|
||||||
|
char * pUid;
|
||||||
|
|
||||||
|
// Check if table already exists
|
||||||
|
pUid = tkvGet(pMeta->tbnameDb, NULL, pTableOpts->name, strlen(pTableOpts->name), &vallen);
|
||||||
|
if (pUid) {
|
||||||
|
free(pUid);
|
||||||
|
// Table already exists, return error code
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pTableOpts->type) {
|
||||||
|
case META_SUPER_TABLE:
|
||||||
|
return metaCreateSuperTable(pMeta, pTableOpts->name, &(pTableOpts->superOpts));
|
||||||
|
case META_CHILD_TABLE:
|
||||||
|
return metaCreateChildTable(pMeta, pTableOpts->name, &(pTableOpts->childOpts));
|
||||||
|
case META_NORMAL_TABLE:
|
||||||
|
return metaCreateNormalTable(pMeta, pTableOpts->name, &(pTableOpts->normalOpts));
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int metaCreateSuperTable(SMeta *pMeta, const char *tbname, const SSuperTableOpts *pSuperTableOpts) {
|
static int metaCreateSuperTable(SMeta *pMeta, const char *tbname, const SSuperTableOpts *pSuperTableOpts) {
|
||||||
size_t vallen;
|
size_t vallen;
|
||||||
size_t keylen;
|
size_t keylen;
|
||||||
|
|
|
@ -12,3 +12,15 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "meta.h"
|
||||||
|
|
||||||
|
int metaCreateTable(SMeta *pMeta, const STableOptions *pTbOptions) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue