more
This commit is contained in:
parent
552051da5a
commit
770b1bb1c0
|
@ -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;
|
||||||
|
|
||||||
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 @@
|
||||||
#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;
|
||||||
|
|
||||||
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 @@
|
||||||
#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
|
||||||
|
|
|
@ -46,4 +46,14 @@ void metaCloseDB(SMeta *pMeta) {
|
||||||
rocksdb_close(pMeta->pDB);
|
rocksdb_close(pMeta->pDB);
|
||||||
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;
|
||||||
}
|
}
|
|
@ -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) {
|
||||||
|
@ -46,4 +45,9 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
|
||||||
rocksdb_close(pMeta->pIdx);
|
rocksdb_close(pMeta->pIdx);
|
||||||
pMeta->pIdx = NULL;
|
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/>.
|
* 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) {
|
||||||
// TODO
|
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
||||||
|
// TODO: handle error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
||||||
|
// TODO
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,11 @@
|
||||||
*
|
*
|
||||||
* 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;
|
||||||
|
}
|
Loading…
Reference in New Issue