提交 770b1bb1 编写于 作者: H Hongze Cheng

more

上级 552051da
...@@ -25,37 +25,44 @@ extern "C" { ...@@ -25,37 +25,44 @@ extern "C" {
#endif #endif
typedef uint64_t tb_uid_t; typedef uint64_t tb_uid_t;
/* ------------------------ SMetaOptions ------------------------ */
struct SMetaOptions { struct SMetaOptions {
size_t lruCacheSize; // LRU cache size size_t lruCacheSize; // LRU cache size
}; };
#if 0 /* ------------------------ STbOptions ------------------------ */
typedef enum { META_INIT_TABLE = 0, META_SUPER_TABLE = 1, META_CHILD_TABLE = 2, META_NORMAL_TABLE = 3 } EMetaTableT; typedef struct {
typedef struct SSuperTableOpts { } SSMAOptions;
// super table options
typedef struct {
tb_uid_t uid; tb_uid_t uid;
STSchema *pSchema; // (ts timestamp, a int) STSchema* pSchema;
STSchema *pTagSchema; // (tag1 binary(10), tag2 int) STSchema* pTagSchema;
} SSuperTableOpts; } SSTbOptions;
typedef struct SChildTableOpts { // child table options
tb_uid_t suid; // super table uid typedef struct {
SKVRow tags; // tag value of the child table tb_uid_t suid;
} SChildTableOpts; SKVRow tags;
} SCTbOptions;
typedef struct SNormalTableOpts { // normal table options
STSchema *pSchema; typedef struct {
} SNormalTableOpts; SSchema* pSchame;
} SNTbOptions;
struct STableOptions { struct STbOptions {
int8_t type; uint8_t type;
char * name; char* name;
uint64_t ttl; // time to live
SSMAOptions bsma; // Block-wise sma
union { union {
SSuperTableOpts superOpts; SSTbOptions stbOptions;
SChildTableOpts childOpts; SNTbOptions ntbOptions;
SNormalTableOpts normalOpts; SCTbOptions ctbOptions;
}; };
}; };
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -28,6 +28,8 @@ typedef rocksdb_t meta_db_t; ...@@ -28,6 +28,8 @@ typedef rocksdb_t meta_db_t;
int metaOpenDB(SMeta *pMeta); int metaOpenDB(SMeta *pMeta);
void metaCloseDB(SMeta *pMeta); void metaCloseDB(SMeta *pMeta);
int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions);
int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
#ifndef _TD_META_DEF_H_ #ifndef _TD_META_DEF_H_
#define _TD_META_DEF_H_ #define _TD_META_DEF_H_
#include "meta.h"
#include "metaCache.h" #include "metaCache.h"
#include "metaDB.h" #include "metaDB.h"
#include "metaIdx.h" #include "metaIdx.h"
#include "metaOptions.h"
#include "metaTbUid.h" #include "metaTbUid.h"
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -28,6 +28,8 @@ typedef rocksdb_t meta_index_t; ...@@ -28,6 +28,8 @@ typedef rocksdb_t meta_index_t;
int metaOpenIdx(SMeta *pMeta); int metaOpenIdx(SMeta *pMeta);
void metaCloseIdx(SMeta *pMeta); void metaCloseIdx(SMeta *pMeta);
int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions);
int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -16,10 +16,14 @@ ...@@ -16,10 +16,14 @@
#ifndef _TD_META_TABLE_OPTIONS_H_ #ifndef _TD_META_TABLE_OPTIONS_H_
#define _TD_META_TABLE_OPTIONS_H_ #define _TD_META_TABLE_OPTIONS_H_
#include "meta.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int metaValidateTbOptions(SMeta *pMeta, const STbOptions *);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -47,3 +47,13 @@ void metaCloseDB(SMeta *pMeta) { ...@@ -47,3 +47,13 @@ void metaCloseDB(SMeta *pMeta) {
pMeta->pDB = NULL; 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
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "meta.h"
#include "metaDef.h" #include "metaDef.h"
int metaOpenIdx(SMeta *pMeta) { int metaOpenIdx(SMeta *pMeta) {
...@@ -47,3 +46,8 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */ ...@@ -47,3 +46,8 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
pMeta->pIdx = NULL; pMeta->pIdx = NULL;
} }
} }
int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions) {
// TODO
return 0;
}
\ No newline at end of file
...@@ -13,14 +13,40 @@ ...@@ -13,14 +13,40 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "meta.h" #include "metaDef.h"
int metaCreateTable(SMeta *pMeta, const STbOptions *pTbOptions) { 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; return 0;
} }
int metaDropTable(SMeta *pMeta, tb_uid_t uid) { int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
// TODO: handle error
return -1;
}
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
// TODO // TODO
return -1;
}
return 0; return 0;
} }
...@@ -12,3 +12,10 @@ ...@@ -12,3 +12,10 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "metaDef.h"
int metaValidateTbOptions(SMeta *pMeta, const STbOptions *pTbOptions) {
// TODO
return 0;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册