diff --git a/include/server/vnode/meta/impl/metaImpl.h b/include/server/vnode/meta/impl/metaImpl.h
index 7987ddf203e56c60acb1844cc6db7374784136e9..d6f3bbbcfec3d06ef8bcfe56a8bd1c14a1082d76 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 3381b05f22c5bedcafeb161b1e858edfdfab5b82..8d7482acbbf4f00f014766dc0cbed03d83b86233 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 a81bd931e489bd30585986b6464b204eb4937c9b..5c4ae3428c345d3ef93b086045059d56eb791d58 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 4a897228a9ecd52bfbd3dad2e90e2e69c8969ee2..d43df9afc3cd43e12f6f0a4a397f351f802d0a96 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 cd2b2ee0e86c59abd62d5cd3e539b281633cfde9..1da68ffd52bc8da2c659134e65fc2d4768473f61 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 1dbb88587a7ddc7df54fcf5894106306a1367dee..a8e63b6156dff56ebfd8b9bbf7d0044ae95d3c97 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 29353cd51112b3813a9a0b8c6a1029f7b0a4a48f..54cc8bd461edc69a37126737e7020d5df9827ea3 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 de1f8bba90114d3de147e6a827d230ad4850b7df..b41d9313d5df6edf11c240ca6cc2fc01f4210a76 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 6dea4a4e57392be988126c579648f39a8270b9bf..1f855aef23823b0e15e2be6785d8b80989e07d37 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