make compile and run test
This commit is contained in:
parent
b45884c151
commit
87dcc7fd92
|
@ -57,7 +57,7 @@ SMetaQueryOpts *metaQueryOptionsCreate();
|
|||
void metaQueryOptionsDestroy(SMetaQueryOpts *);
|
||||
|
||||
// STableOpts
|
||||
void metaTableOptsInit(int8_t type, const char *name, const STSchema *pSchema);
|
||||
void metaTableOptsInit(STableOpts *, int8_t type, const char *name, const STSchema *pSchema);
|
||||
|
||||
/* -------------------------------- Hided implementations -------------------------------- */
|
||||
struct STableOpts {
|
||||
|
|
|
@ -146,10 +146,19 @@ int metaCreateTable(SMeta *pMeta, STableOpts *pTableOpts) {
|
|||
|
||||
wopt = rocksdb_writeoptions_create();
|
||||
|
||||
// Add to tbname db
|
||||
rocksdb_put(pMeta->tbnameDb, wopt, pTableOpts->name, strlen(pTableOpts->name), &pTableObj->pTable->uid,
|
||||
sizeof(tb_uid_t), &err);
|
||||
rocksdb_put(pMeta->schemaDb, wopt, pTableOpts->name, strlen(pTableOpts->name), &pTableObj->pTable->uid,
|
||||
sizeof(tb_uid_t), &err);
|
||||
|
||||
// Add to schema db
|
||||
char id[12];
|
||||
char buf[256];
|
||||
void *pBuf = buf;
|
||||
*(tb_uid_t *)id = pTableObj->pTable->uid;
|
||||
*(int32_t *)(id + sizeof(tb_uid_t)) = schemaVersion(pTableOpts->pSchema);
|
||||
int size = tdEncodeSchema(&pBuf, pTableOpts->pSchema);
|
||||
|
||||
rocksdb_put(pMeta->schemaDb, wopt, id, 12, buf, size, &err);
|
||||
|
||||
rocksdb_writeoptions_destroy(wopt);
|
||||
|
||||
|
@ -162,6 +171,12 @@ void metaDestroy(const char *path) { taosRemoveDir(path); }
|
|||
|
||||
int metaCommit(SMeta *meta) { return 0; }
|
||||
|
||||
void metaTableOptsInit(STableOpts *pTableOpts, int8_t type, const char *name, const STSchema *pSchema) {
|
||||
pTableOpts->type = type;
|
||||
pTableOpts->name = strdup(name);
|
||||
pTableOpts->pSchema = tdDupSchema(pSchema);
|
||||
}
|
||||
|
||||
/* -------------------- Static Methods -------------------- */
|
||||
|
||||
static STable *metaTableNew(tb_uid_t uid, const char *name, int32_t sver) {
|
||||
|
|
|
@ -1,15 +1,37 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "meta.h"
|
||||
|
||||
TEST(MetaTest, meta_open_test) {
|
||||
// Open Meta
|
||||
SMeta *meta = metaOpen(NULL);
|
||||
std::cout << "Meta is opened!" << std::endl;
|
||||
|
||||
// Create tables
|
||||
STableOpts tbOpts;
|
||||
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);
|
||||
|
||||
metaCreateTable(meta, &tbOpts);
|
||||
}
|
||||
|
||||
// Close Meta
|
||||
metaClose(meta);
|
||||
std::cout << "Meta is closed!" << std::endl;
|
||||
|
||||
metaDestroy("meta");
|
||||
std::cout << "Meta is destroyed!" << std::endl;
|
||||
// // Destroy Meta
|
||||
// metaDestroy("meta");
|
||||
// std::cout << "Meta is destroyed!" << std::endl;
|
||||
}
|
Loading…
Reference in New Issue