提交 d89aae08 编写于 作者: H Hongze Cheng

more

上级 4e306a79
......@@ -20,52 +20,25 @@
extern "C" {
#endif
typedef struct tkv_db_s tkv_db_t;
typedef struct {
/* data */
} tkv_key_t;
typedef struct {
bool pinned;
int64_t ref; // TODO: use util library
// TODO: add a RW latch here
uint64_t offset;
void * pObj;
} tkv_obj_t;
typedef int (*tkv_key_comp_fn_t)(const tkv_key_t *, const tkv_key_t *);
typedef void (*tkv_get_key_fn_t)(const tkv_obj_t *, tkv_key_t *);
typedef int (*tkv_obj_encode_fn_t)(void **buf, void *pObj);
typedef void *(*tkv_obj_decode_fn_t)(void *buf, void **pObj);
typedef int (*tkv_obj_comp_fn_t)(const tkv_obj_t *, const tkv_obj_t *);
typedef void (*tkv_obj_destroy_fn_t)(void *);
typedef struct {
uint64_t memLimit;
tkv_get_key_fn_t getKey;
tkv_obj_encode_fn_t encode;
tkv_obj_decode_fn_t decode;
tkv_obj_comp_fn_t compare;
tkv_obj_destroy_fn_t destroy;
} tkv_db_option_t;
tkv_db_t * tkvOpenDB(char *dir, tkv_db_option_t *);
int tkvCloseDB(tkv_db_t *);
int tkvPut(tkv_db_t *, tkv_obj_t *);
int tkvPutBatch(tkv_db_t *, tkv_obj_t **, int); // TODO: use array here
const tkv_obj_t *tkvGet(tkv_key_t *);
int tkvGetBatch(tkv_db_t *, tkv_key_t **, int, tkv_obj_t **); // TODO: use array here
int tkvDrop(tkv_db_t *, tkv_key_t *);
int tkvDropBatch(tkv_db_t *, tkv_key_t **, int); // TODO: use array here
int tkvCommit(tkv_db_t *, void * /*TODO*/);
typedef struct {
} tkv_db_iter_t;
tkv_db_iter_t * tkvIterNew(tkv_db_t *);
void tkvIterFree(tkv_db_iter_t *);
const tkv_obj_t *tkvIterNext(tkv_db_iter_t *);
// Types exported
typedef struct STkvDb STkvDb;
typedef struct STkvOptions STkvOptions;
typedef struct STkvCache STkvCache;
// DB operations
STkvDb *tkvOpen(const STkvOptions *options, const char *path);
void tkvClose(STkvDb *db);
void tkvPut(STkvDb *db, void * /*TODO*/);
// DB options
STkvOptions *tkvOptionsCreate();
void tkvOptionsDestroy(STkvOptions *);
void tkvOptionsSetCache(STkvOptions *, STkvCache *);
// DB cache
typedef enum { TKV_LRU_CACHE = 0, TKV_LFU_CACHE = 1 } ETkvCacheType;
STkvCache *tkvCacheCreate(size_t capacity, ETkvCacheType type);
void tkvCacheDestroy(STkvCache *);
#ifdef __cplusplus
}
......
......@@ -18,16 +18,42 @@
#include "taosMsg.h"
#include "os.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SMeta SMeta;
typedef uint64_t tuid_t;
// Types exported
typedef struct SMeta SMeta;
typedef struct SMetaOptions SMetaOptions;
typedef struct SMetaQueryHandle SMetaQueryHandle;
typedef struct SMetaQueryOptions SMetaQueryOptions;
// SMeta operations
int metaCreate(const char *path);
int metaDestroy(const char *path);
SMeta *metaOpen(SMetaOptions *);
void metaClose(SMeta *);
int metaCreateTable(SMeta *, void *);
int metaDropTable(SMeta *, uint64_t tuid_t);
int metaAlterTable(SMeta *, void *);
int metaCommit(SMeta *);
// Options
SMetaOptions *metaOptionsCreate();
void metaOptionsDestroy(SMetaOptions *);
void metaOptionsSetCache(SMetaOptions *, size_t capacity);
// SMetaQueryHandle
SMetaQueryHandle *metaQueryHandleCreate(SMetaQueryOptions *);
void metaQueryHandleDestroy(SMetaQueryHandle *);
int metaCreateTable(SMeta *pMeta, SCreateTableReq *pReq);
int metaDropTable(SMeta *pMeta, SDropTableReq *pReq);
int metaAlterTable(SMeta *pMeta, SAlterTableReq *pReq);
int metaCommit(SMeta *pMeta);
// SMetaQueryOptions
SMetaQueryOptions *metaQueryOptionsCreate();
void metaQueryOptionsDestroy(SMetaQueryOptions *);
#ifdef __cplusplus
}
......
......@@ -23,33 +23,60 @@
extern "C" {
#endif
typedef struct STsdb STsdb;
typedef struct {
int32_t id; // TODO: use a global definition
int32_t days;
int32_t keep;
int32_t keep1;
int32_t keep2;
int32_t minRows;
int32_t maxRows;
int8_t precision;
int8_t update;
} STsdbCfg;
// Module init and clear
int tsdbInit();
int tsdbClear();
// Repository operations
int tsdbCreateRepo(int id);
int tsdbDropRepo(int id);
STsdb *tsdbOpenRepo(STsdbCfg *pCfg);
int tsdbCloseRepo(STsdb *pTsdb);
int tsdbForceCloseRepo(STsdb *pTsdb);
// Data commit
int tsdbInsert(STsdb *pTsdb, SSubmitReq *pMsg);
int tsdbCommit(STsdb *pTsdb);
// Types exported
typedef struct STsdb STsdb;
typedef struct STsdbOptions STsdbOptions;
typedef struct STsdbSMAOptions STsdbSMAOptions; // SMA stands for Small Materialized Aggregation
typedef struct STsdbReadOptions STsdbReadOptions;
typedef struct STsdbSnapshot STsdbSnapshot;
typedef struct STsdbQueryHandle STsdbQueryHandle;
// DB operations
int tsdbCreate(const char *path);
int tsdbDestroy(const char *path);
STsdb *tsdbOpen(const STsdbOptions *options);
void tsdbClose(STsdb *);
int tsdbReset(STsdb *, const STsdbOptions *);
int tsdbInsert(STsdb *, SSubmitReq *, SSubmitRsp *);
int tsdbCommit(STsdb *);
int tsdbCompact(STsdb *);
// Options
STsdbOptions *tsdbOptionsCreate();
void tsdbOptionsDestroy(STsdbOptions *);
void tsdbOptionsSetId(STsdbOptions *, int id);
void tsdbOptionsSetHoursPerFile(STsdbOptions *, int hours);
void tsdbOptionsSetRetention(STsdbOptions *, int keep, int keep1, int keep2);
void tsdbOptionsSetMinAndMaxRows(STsdbOptions *, int minRows, int maxRows);
void tsdbOptionsSetPrecision(STsdbOptions *, int);
void tsdbOptionsSetCache(STsdbOptions *, int);
typedef enum { TSDB_NO_UPDATE = 0, TSDB_WHOLE_ROW_UPDATE = 1, TSDB_PARTIAL_ROW_UPDATE = 2 } ETsdbUpdateType;
void tsdbOptionsSetUpdate(STsdbOptions *, ETsdbUpdateType);
void tsdbOptionsSetSMA(STsdbOptions *, STsdbSMAOptions *);
// STsdbSMAOptions
STsdbSMAOptions *tsdbSMAOptionsCreate();
void tsdbSMAOptionsDestroy(STsdbSMAOptions *);
void tsdbSMAOptionsSetFuncs(STsdbSMAOptions *, SArray * /*Array of function to perform on each block*/);
void tsdbSMAOptionsSetIntervals(STsdbSMAOptions *, SArray *);
void tsdbSMAOptionsSetColTypes(STsdbSMAOptions *, SArray *);
// STsdbQueryHandle
STsdbQueryHandle *tsdbQueryHandleCreate(STsdb *, STsdbReadOptions *);
void tsdbQueryHandleDestroy(STsdbQueryHandle *);
void tsdbResetQueryHandle(STsdbQueryHandle *, STsdbReadOptions *);
bool tsdbNextDataBlock(STsdbQueryHandle *);
void tsdbGetDataBlockInfo(STsdbQueryHandle *, SDataBlockInfo *);
void tsdbGetDataBlockStatisInfo(STsdbQueryHandle *, SDataStatis **);
// STsdbReadOptions
STsdbReadOptions *tsdbReadOptionsCreate();
void tsdbReadOptionsDestroy(STsdbReadOptions *);
void tsdbReadOptionsSetSnapshot(STsdbReadOptions *, STsdbSnapshot *);
// STsdbSnapshot
STsdbSnapshot *tsdbSnapshotCreate(STsdb *);
void tsdbSnapshotDestroy(STsdbSnapshot *);
#ifdef __cplusplus
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册