more
This commit is contained in:
parent
7d7c380c39
commit
d1b6f2b257
|
@ -58,10 +58,12 @@ SMetaQueryOpts *metaQueryOptionsCreate();
|
||||||
void metaQueryOptionsDestroy(SMetaQueryOpts *);
|
void metaQueryOptionsDestroy(SMetaQueryOpts *);
|
||||||
|
|
||||||
// STableOpts
|
// STableOpts
|
||||||
void metaTableOptsInit(STableOpts *, int8_t type, const char *name, const STSchema *pSchema);
|
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0};
|
||||||
|
void metaNormalTableOptsInit(STableOpts *, const char *name, const STSchema *pSchema);
|
||||||
|
void metaTableOptsDestroy(STableOpts *);
|
||||||
|
|
||||||
/* ------------------------ Impl should hidden ------------------------ */
|
/* ------------------------ Impl should hidden ------------------------ */
|
||||||
typedef enum { META_SUPER_TABLE = 0, META_CHILD_TABLE = 1, META_NORMAL_TABLE = 2 } EMetaTableT;
|
typedef enum { META_INIT_TABLE = 0, META_SUPER_TABLE = 1, META_CHILD_TABLE = 2, META_NORMAL_TABLE = 3 } EMetaTableT;
|
||||||
typedef struct SSuperTableOpts {
|
typedef struct SSuperTableOpts {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
STSchema *pSchema; // (ts timestamp, a int)
|
STSchema *pSchema; // (ts timestamp, a int)
|
||||||
|
@ -78,8 +80,8 @@ typedef struct SNormalTableOpts {
|
||||||
} SNormalTableOpts;
|
} SNormalTableOpts;
|
||||||
|
|
||||||
struct STableOpts {
|
struct STableOpts {
|
||||||
EMetaTableT type;
|
int8_t type;
|
||||||
char * name;
|
char * name;
|
||||||
union {
|
union {
|
||||||
SSuperTableOpts superOpts;
|
SSuperTableOpts superOpts;
|
||||||
SChildTableOpts childOpts;
|
SChildTableOpts childOpts;
|
||||||
|
|
|
@ -212,6 +212,26 @@ static int metaCreateNormalTable(SMeta *pMeta, const char *tbname, const SNormal
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void metaNormalTableOptsInit(STableOpts *pTableOpts, const char *name, const STSchema *pSchema) {
|
||||||
|
pTableOpts->type = META_NORMAL_TABLE;
|
||||||
|
pTableOpts->name = strdup(name);
|
||||||
|
pTableOpts->normalOpts.pSchema = tdDupSchema(pSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
void metaTableOptsDestroy(STableOpts *pTableOpts) {
|
||||||
|
switch (pTableOpts->type) {
|
||||||
|
case META_NORMAL_TABLE:
|
||||||
|
tfree(pTableOpts->name);
|
||||||
|
tdFreeSchema(pTableOpts->normalOpts.pSchema);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
pTableOpts->type = META_INIT_TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* -------------------- Structures -------------------- */
|
/* -------------------- Structures -------------------- */
|
||||||
static STable * metaTableNew(tb_uid_t uid, const char *name, int32_t sver);
|
static STable * metaTableNew(tb_uid_t uid, const char *name, int32_t sver);
|
||||||
|
|
|
@ -4,30 +4,36 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
static STSchema *metaGetSimpleSchema() {
|
||||||
|
STSchema * pSchema = NULL;
|
||||||
|
STSchemaBuilder sb;
|
||||||
|
|
||||||
|
tdInitTSchemaBuilder(&sb, 0);
|
||||||
|
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, 0, 8);
|
||||||
|
tdAddColToSchema(&sb, TSDB_DATA_TYPE_INT, 1, 4);
|
||||||
|
|
||||||
|
pSchema = tdGetSchemaFromBuilder(&sb);
|
||||||
|
tdDestroyTSchemaBuilder(&sb);
|
||||||
|
|
||||||
|
return pSchema;
|
||||||
|
}
|
||||||
|
|
||||||
TEST(MetaTest, meta_open_test) {
|
TEST(MetaTest, meta_open_test) {
|
||||||
// Open Meta
|
// Open Meta
|
||||||
SMeta *meta = metaOpen(NULL);
|
SMeta *meta = metaOpen(NULL);
|
||||||
std::cout << "Meta is opened!" << std::endl;
|
std::cout << "Meta is opened!" << std::endl;
|
||||||
|
|
||||||
#if 0
|
// Create 1000000 normal tables
|
||||||
// Create tables
|
META_TABLE_OPTS_DECLARE(tbOpts)
|
||||||
STableOpts tbOpts;
|
STSchema *pSchema = metaGetSimpleSchema();
|
||||||
char tbname[128];
|
char tbname[128];
|
||||||
STSchema * pSchema;
|
|
||||||
STSchemaBuilder sb;
|
|
||||||
tdInitTSchemaBuilder(&sb, 0);
|
|
||||||
for (size_t i = 0; i < 10; i++) {
|
|
||||||
tdAddColToSchema(&sb, TSDB_DATA_TYPE_TIMESTAMP, i, 8);
|
|
||||||
}
|
|
||||||
pSchema = tdGetSchemaFromBuilder(&sb);
|
|
||||||
tdDestroyTSchemaBuilder(&sb);
|
|
||||||
for (size_t i = 0; i < 1000000; i++) {
|
|
||||||
sprintf(tbname, "tb%ld", i);
|
|
||||||
metaTableOptsInit(&tbOpts, 0, tbname, pSchema);
|
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 1000000; i++) {
|
||||||
|
sprintf(tbname, "ntb%ld", i);
|
||||||
|
metaNormalTableOptsInit(&tbOpts, tbname, pSchema);
|
||||||
metaCreateTable(meta, &tbOpts);
|
metaCreateTable(meta, &tbOpts);
|
||||||
|
metaTableOptsDestroy(&tbOpts);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Close Meta
|
// Close Meta
|
||||||
metaClose(meta);
|
metaClose(meta);
|
||||||
|
|
Loading…
Reference in New Issue