提交 cfa6e546 编写于 作者: H hzcheng

TD-34

上级 dca2abd6
......@@ -58,6 +58,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo);
tsdb_repo_t * tsdbOpenRepo(char *tsdbDir);
int32_t tsdbCloseRepo(tsdb_repo_t *repo);
int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg);
int32_t tsdbTriggerCommit(tsdb_repo_t *repo);
// --------- TSDB TABLE DEFINITION
typedef struct {
......
......@@ -35,20 +35,21 @@ extern "C" {
// ---------- TSDB TABLE DEFINITION
typedef struct STable {
int8_t type;
STableId tableId;
int32_t superUid; // Super table UID
int32_t sversion;
STSchema * schema;
STSchema * tagSchema;
SDataRow tagVal;
int8_t type;
STableId tableId;
int32_t superUid; // Super table UID
int32_t sversion;
STSchema *schema;
STSchema *tagSchema;
SDataRow tagVal;
union {
void *pData; // For TSDB_NORMAL_TABLE and TSDB_CHILD_TABLE, it is the skiplist for cache data
void *pIndex; // For TSDB_SUPER_TABLE, it is the skiplist index
} content;
void * iData; // Skiplist to commit
void * eventHandler; // TODO
void * streamHandler; // TODO
struct STable *next; // TODO: remove the next
struct STable *next; // TODO: remove the next
} STable;
void * tsdbEncodeTable(STable *pTable, int *contLen);
......
......@@ -64,7 +64,10 @@ typedef struct _tsdb_repo {
// Disk tier handle for multi-tier storage
void *diskTier;
pthread_mutex_t tsdbMutex;
pthread_mutex_t mutex;
int commit;
pthread_t commitThread;
// A limiter to monitor the resources used by tsdb
void *limiter;
......@@ -80,6 +83,7 @@ static int tsdbOpenMetaFile(char *tsdbDir);
static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock);
static int32_t tsdbRestoreCfg(STsdbRepo *pRepo, STsdbCfg *pCfg);
static int32_t tsdbGetDataDirName(STsdbRepo *pRepo, char *fname);
static void * tsdbCommitToFile(void *arg);
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
......@@ -298,6 +302,18 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
return 0;
}
int32_t tsdbTriggerCommit(tsdb_repo_t *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
if (pthread_mutex_lock(&(pRepo->mutex)) < 0) return -1;
if (pRepo->commit) return 0;
pRepo->commit = 1;
pthread_create(&(pRepo->commitThread), NULL, tsdbCommitToFile, (void *)repo);
pthread_mutex_unlock(&(pRepo->mutex));
return 0;
}
/**
* Get the TSDB repository information, including some statistics
* @param pRepo the TSDB repository handle
......@@ -673,4 +689,10 @@ static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock) {
}
return 0;
}
static void *tsdbCommitToFile(void *arg) {
STsdbRepo *pRepo = (STsdbRepo *)arg;
// TODO
return NULL;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册