TD-34
This commit is contained in:
parent
dca2abd6fb
commit
cfa6e5469b
|
@ -58,6 +58,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo);
|
||||||
tsdb_repo_t * tsdbOpenRepo(char *tsdbDir);
|
tsdb_repo_t * tsdbOpenRepo(char *tsdbDir);
|
||||||
int32_t tsdbCloseRepo(tsdb_repo_t *repo);
|
int32_t tsdbCloseRepo(tsdb_repo_t *repo);
|
||||||
int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg);
|
int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg);
|
||||||
|
int32_t tsdbTriggerCommit(tsdb_repo_t *repo);
|
||||||
|
|
||||||
// --------- TSDB TABLE DEFINITION
|
// --------- TSDB TABLE DEFINITION
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -35,20 +35,21 @@ extern "C" {
|
||||||
|
|
||||||
// ---------- TSDB TABLE DEFINITION
|
// ---------- TSDB TABLE DEFINITION
|
||||||
typedef struct STable {
|
typedef struct STable {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
STableId tableId;
|
STableId tableId;
|
||||||
int32_t superUid; // Super table UID
|
int32_t superUid; // Super table UID
|
||||||
int32_t sversion;
|
int32_t sversion;
|
||||||
STSchema * schema;
|
STSchema *schema;
|
||||||
STSchema * tagSchema;
|
STSchema *tagSchema;
|
||||||
SDataRow tagVal;
|
SDataRow tagVal;
|
||||||
union {
|
union {
|
||||||
void *pData; // For TSDB_NORMAL_TABLE and TSDB_CHILD_TABLE, it is the skiplist for cache data
|
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
|
void *pIndex; // For TSDB_SUPER_TABLE, it is the skiplist index
|
||||||
} content;
|
} content;
|
||||||
|
void * iData; // Skiplist to commit
|
||||||
void * eventHandler; // TODO
|
void * eventHandler; // TODO
|
||||||
void * streamHandler; // TODO
|
void * streamHandler; // TODO
|
||||||
struct STable *next; // TODO: remove the next
|
struct STable *next; // TODO: remove the next
|
||||||
} STable;
|
} STable;
|
||||||
|
|
||||||
void * tsdbEncodeTable(STable *pTable, int *contLen);
|
void * tsdbEncodeTable(STable *pTable, int *contLen);
|
||||||
|
|
|
@ -64,7 +64,10 @@ typedef struct _tsdb_repo {
|
||||||
// Disk tier handle for multi-tier storage
|
// Disk tier handle for multi-tier storage
|
||||||
void *diskTier;
|
void *diskTier;
|
||||||
|
|
||||||
pthread_mutex_t tsdbMutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
|
int commit;
|
||||||
|
pthread_t commitThread;
|
||||||
|
|
||||||
// A limiter to monitor the resources used by tsdb
|
// A limiter to monitor the resources used by tsdb
|
||||||
void *limiter;
|
void *limiter;
|
||||||
|
@ -80,6 +83,7 @@ static int tsdbOpenMetaFile(char *tsdbDir);
|
||||||
static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock);
|
static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock);
|
||||||
static int32_t tsdbRestoreCfg(STsdbRepo *pRepo, STsdbCfg *pCfg);
|
static int32_t tsdbRestoreCfg(STsdbRepo *pRepo, STsdbCfg *pCfg);
|
||||||
static int32_t tsdbGetDataDirName(STsdbRepo *pRepo, char *fname);
|
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_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
|
||||||
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
|
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
|
||||||
|
@ -298,6 +302,18 @@ int32_t tsdbConfigRepo(tsdb_repo_t *repo, STsdbCfg *pCfg) {
|
||||||
return 0;
|
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
|
* Get the TSDB repository information, including some statistics
|
||||||
* @param pRepo the TSDB repository handle
|
* @param pRepo the TSDB repository handle
|
||||||
|
@ -674,3 +690,9 @@ static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *tsdbCommitToFile(void *arg) {
|
||||||
|
STsdbRepo *pRepo = (STsdbRepo *)arg;
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
Loading…
Reference in New Issue