more
This commit is contained in:
parent
7d7c380c39
commit
d1b6f2b257
|
@ -58,10 +58,12 @@ SMetaQueryOpts *metaQueryOptionsCreate();
|
|||
void metaQueryOptionsDestroy(SMetaQueryOpts *);
|
||||
|
||||
// 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 ------------------------ */
|
||||
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 {
|
||||
tb_uid_t uid;
|
||||
STSchema *pSchema; // (ts timestamp, a int)
|
||||
|
@ -78,7 +80,7 @@ typedef struct SNormalTableOpts {
|
|||
} SNormalTableOpts;
|
||||
|
||||
struct STableOpts {
|
||||
EMetaTableT type;
|
||||
int8_t type;
|
||||
char * name;
|
||||
union {
|
||||
SSuperTableOpts superOpts;
|
||||
|
|
|
@ -212,6 +212,26 @@ static int metaCreateNormalTable(SMeta *pMeta, const char *tbname, const SNormal
|
|||
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
|
||||
/* -------------------- Structures -------------------- */
|
||||
static STable * metaTableNew(tb_uid_t uid, const char *name, int32_t sver);
|
||||
|
|
|
@ -4,30 +4,36 @@
|
|||
|
||||
#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) {
|
||||
// Open Meta
|
||||
SMeta *meta = metaOpen(NULL);
|
||||
std::cout << "Meta is opened!" << std::endl;
|
||||
|
||||
#if 0
|
||||
// Create tables
|
||||
STableOpts tbOpts;
|
||||
// Create 1000000 normal tables
|
||||
META_TABLE_OPTS_DECLARE(tbOpts)
|
||||
STSchema *pSchema = metaGetSimpleSchema();
|
||||
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);
|
||||
metaTableOptsDestroy(&tbOpts);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Close Meta
|
||||
metaClose(meta);
|
||||
|
|
Loading…
Reference in New Issue