diff --git a/include/server/vnode/meta/impl/metaImpl.h b/include/server/vnode/meta/impl/metaImpl.h
index 7987ddf203..d6f3bbbcfe 100644
--- a/include/server/vnode/meta/impl/metaImpl.h
+++ b/include/server/vnode/meta/impl/metaImpl.h
@@ -25,37 +25,44 @@ extern "C" {
#endif
typedef uint64_t tb_uid_t;
+/* ------------------------ SMetaOptions ------------------------ */
struct SMetaOptions {
- size_t lruCacheSize; // LRU cache size
+ size_t lruCacheSize; // LRU cache size
};
-#if 0
-typedef enum { META_INIT_TABLE = 0, META_SUPER_TABLE = 1, META_CHILD_TABLE = 2, META_NORMAL_TABLE = 3 } EMetaTableT;
-typedef struct SSuperTableOpts {
+/* ------------------------ STbOptions ------------------------ */
+typedef struct {
+} SSMAOptions;
+
+// super table options
+typedef struct {
tb_uid_t uid;
- STSchema *pSchema; // (ts timestamp, a int)
- STSchema *pTagSchema; // (tag1 binary(10), tag2 int)
-} SSuperTableOpts;
+ STSchema* pSchema;
+ STSchema* pTagSchema;
+} SSTbOptions;
-typedef struct SChildTableOpts {
- tb_uid_t suid; // super table uid
- SKVRow tags; // tag value of the child table
-} SChildTableOpts;
+// child table options
+typedef struct {
+ tb_uid_t suid;
+ SKVRow tags;
+} SCTbOptions;
-typedef struct SNormalTableOpts {
- STSchema *pSchema;
-} SNormalTableOpts;
+// normal table options
+typedef struct {
+ SSchema* pSchame;
+} SNTbOptions;
-struct STableOptions {
- int8_t type;
- char * name;
+struct STbOptions {
+ uint8_t type;
+ char* name;
+ uint64_t ttl; // time to live
+ SSMAOptions bsma; // Block-wise sma
union {
- SSuperTableOpts superOpts;
- SChildTableOpts childOpts;
- SNormalTableOpts normalOpts;
+ SSTbOptions stbOptions;
+ SNTbOptions ntbOptions;
+ SCTbOptions ctbOptions;
};
};
-#endif
#ifdef __cplusplus
}
diff --git a/source/dnode/vnode/meta/inc/metaDB.h b/source/dnode/vnode/meta/inc/metaDB.h
index 3381b05f22..8d7482acbb 100644
--- a/source/dnode/vnode/meta/inc/metaDB.h
+++ b/source/dnode/vnode/meta/inc/metaDB.h
@@ -28,6 +28,8 @@ typedef rocksdb_t meta_db_t;
int metaOpenDB(SMeta *pMeta);
void metaCloseDB(SMeta *pMeta);
+int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions);
+int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid);
#ifdef __cplusplus
}
diff --git a/source/dnode/vnode/meta/inc/metaDef.h b/source/dnode/vnode/meta/inc/metaDef.h
index a81bd931e4..5c4ae3428c 100644
--- a/source/dnode/vnode/meta/inc/metaDef.h
+++ b/source/dnode/vnode/meta/inc/metaDef.h
@@ -16,9 +16,11 @@
#ifndef _TD_META_DEF_H_
#define _TD_META_DEF_H_
+#include "meta.h"
#include "metaCache.h"
#include "metaDB.h"
#include "metaIdx.h"
+#include "metaOptions.h"
#include "metaTbUid.h"
#ifdef __cplusplus
diff --git a/source/dnode/vnode/meta/inc/metaIdx.h b/source/dnode/vnode/meta/inc/metaIdx.h
index 4a897228a9..d43df9afc3 100644
--- a/source/dnode/vnode/meta/inc/metaIdx.h
+++ b/source/dnode/vnode/meta/inc/metaIdx.h
@@ -28,6 +28,8 @@ typedef rocksdb_t meta_index_t;
int metaOpenIdx(SMeta *pMeta);
void metaCloseIdx(SMeta *pMeta);
+int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions);
+int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid);
#ifdef __cplusplus
}
diff --git a/source/dnode/vnode/meta/inc/metaTbOptions.h b/source/dnode/vnode/meta/inc/metaTbOptions.h
index cd2b2ee0e8..1da68ffd52 100644
--- a/source/dnode/vnode/meta/inc/metaTbOptions.h
+++ b/source/dnode/vnode/meta/inc/metaTbOptions.h
@@ -16,10 +16,14 @@
#ifndef _TD_META_TABLE_OPTIONS_H_
#define _TD_META_TABLE_OPTIONS_H_
+#include "meta.h"
+
#ifdef __cplusplus
extern "C" {
#endif
+int metaValidateTbOptions(SMeta *pMeta, const STbOptions *);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/dnode/vnode/meta/src/metaDB.c b/source/dnode/vnode/meta/src/metaDB.c
index 1dbb88587a..a8e63b6156 100644
--- a/source/dnode/vnode/meta/src/metaDB.c
+++ b/source/dnode/vnode/meta/src/metaDB.c
@@ -46,4 +46,14 @@ void metaCloseDB(SMeta *pMeta) {
rocksdb_close(pMeta->pDB);
pMeta->pDB = NULL;
}
+}
+
+int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
+ // TODO
+ return 0;
+}
+
+int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
+ /* TODO */
+ return 0;
}
\ No newline at end of file
diff --git a/source/dnode/vnode/meta/src/metaIdx.c b/source/dnode/vnode/meta/src/metaIdx.c
index 29353cd511..54cc8bd461 100644
--- a/source/dnode/vnode/meta/src/metaIdx.c
+++ b/source/dnode/vnode/meta/src/metaIdx.c
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-#include "meta.h"
#include "metaDef.h"
int metaOpenIdx(SMeta *pMeta) {
@@ -46,4 +45,9 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
rocksdb_close(pMeta->pIdx);
pMeta->pIdx = NULL;
}
+}
+
+int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions) {
+ // TODO
+ return 0;
}
\ No newline at end of file
diff --git a/source/dnode/vnode/meta/src/metaTable.c b/source/dnode/vnode/meta/src/metaTable.c
index de1f8bba90..b41d9313d5 100644
--- a/source/dnode/vnode/meta/src/metaTable.c
+++ b/source/dnode/vnode/meta/src/metaTable.c
@@ -13,14 +13,40 @@
* along with this program. If not, see .
*/
-#include "meta.h"
+#include "metaDef.h"
int metaCreateTable(SMeta *pMeta, const STbOptions *pTbOptions) {
- // TODO
+ // Validate the tbOptions
+ if (metaValidateTbOptions(pTbOptions) < 0) {
+ // TODO: handle error
+ return -1;
+ }
+
+ // TODO: add atomicity
+
+ if (metaSaveTableToDB(pMeta, pTbOptions) < 0) {
+ // TODO: handle error
+ return -1;
+ }
+
+ if (metaSaveTableToIdx(pMeta, pTbOptions) < 0) {
+ // TODO: handle error
+ return -1;
+ }
+
return 0;
}
int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
- // TODO
+ if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
+ // TODO: handle error
+ return -1;
+ }
+
+ if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
+ // TODO
+ return -1;
+ }
+
return 0;
}
diff --git a/source/dnode/vnode/meta/src/metaTbOptions.c b/source/dnode/vnode/meta/src/metaTbOptions.c
index 6dea4a4e57..1f855aef23 100644
--- a/source/dnode/vnode/meta/src/metaTbOptions.c
+++ b/source/dnode/vnode/meta/src/metaTbOptions.c
@@ -11,4 +11,11 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
\ No newline at end of file
+ */
+
+#include "metaDef.h"
+
+int metaValidateTbOptions(SMeta *pMeta, const STbOptions *pTbOptions) {
+ // TODO
+ return 0;
+}
\ No newline at end of file