more
This commit is contained in:
parent
552051da5a
commit
770b1bb1c0
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -13,7 +13,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -13,14 +13,40 @@
|
|||
* 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) {
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -11,4 +11,11 @@
|
|||
*
|
||||
* 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/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "metaDef.h"
|
||||
|
||||
int metaValidateTbOptions(SMeta *pMeta, const STbOptions *pTbOptions) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue