This commit is contained in:
hzcheng 2020-02-13 05:37:25 +00:00
parent de06d0048f
commit d1f7112e3e
3 changed files with 148 additions and 60 deletions

View File

@ -88,3 +88,5 @@ SMetaHandle * tsdbCreateMetaHandle (int32_t numOfTables);
// Recover the meta handle from the file
SMetaHandle * tsdbOpenMetaHandle(int fd);
int32_t tsdbCreateMeterImpl(SMetaHandle *pHandle, STableCfg *pCfg);

View File

@ -1,14 +1,13 @@
#include <stdint.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include "tsdb.h"
// #include "disk.h"
#include "tsdbMeta.h"
#include "tsdbCache.h"
#include "tsdbMeta.h"
typedef struct STSDBRepo
{
typedef struct STSDBRepo {
// TSDB configuration
STSDBcfg *pCfg;
@ -44,9 +43,10 @@ tsdb_repo_t *tsdbCreateRepo(STSDBCfg *pCfg, int32_t *error) {
// TODO: deal with the error here
}
STSDBRepo *pRepo = (STSDBRepo *) malloc(sizeof(STSDBRepo));
STSDBRepo *pRepo = (STSDBRepo *)malloc(sizeof(STSDBRepo));
if (pRepo == NULL) {
// TODO: deal with error
return NULL;
}
// TODO: Initailize pMetahandle
@ -66,3 +66,70 @@ tsdb_repo_t *tsdbCreateRepo(STSDBCfg *pCfg, int32_t *error) {
return (tsdb_repo_t *)pRepo;
}
int32_t tsdbDropRepo(tsdb_repo_t *pRepo, int32_t *error) {
STSDBRepo *pTRepo = (STSDBRepo *)pRepo;
// TODO: Close the metaHandle
// TODO: Close the cache
return 0;
}
tsdb_repo_t *tsdbOpenRepo(char *tsdbDir, int32_t *error) {
STSDBRepo *pRepo = (STSDBRepo *)malloc(sizeof(STSDBRepo));
if (pRepo == NULL) {
return NULL;
}
// TODO: Initialize configuration from the file
{
// TODO: Initialize the pMetaHandle
}
if (pRepo->pMetaHandle == NULL) {
free(pRepo);
return NULL;
}
{
// TODO: initialize the pCacheHandle
}
if (pRepo->pCacheHandle == NULL) {
// TODO: deal with error
return NULL;
}
return (tsdb_repo_t *)pRepo;
}
int32_t tsdbCloseRepo(tsdb_repo_t *pRepo, int32_t *error) {
STSDBRepo *pTRepo = (STSDBRepo *)pRepo;
return 0;
}
int32_t tsdbConfigRepo(STSDBCfg *pCfg, int32_t *error) {
// TODO
}
STSDBRepoInfo *tsdbGetStatus(tsdb_repo_t *pRepo, int32_t *error) {
// TODO
}
int32_t tsdbCreateTable(tsdb_repo_t *pRepo, STableCfg *pCfg, int32_t *error) {
// TODO
}
int32_t tsdbAlterTable(tsdb_repo_t *pRepo, STableCfg *pCfg, int32_t *error) {
// TODO
}
STableInfo *tsdbGetTableInfo(tsdb_repo_t *pRepo, STableId tid, int32_t *error) {
// TODO
}
int32_t tsdbInsertData(tsdb_repo_t *pRepo, STableId tid, char *pData, int32_t *error) {
// TODO
}

View File

@ -3,8 +3,8 @@
#include "tsdb.h"
#include "tsdbMeta.h"
SMetaHandle * tsdbCreateMetaHandle (int32_t numOfTables) {
SMetaHandle * pMetahandle = (SMetaHandle *)malloc(sizeof(SMetaHandle));
SMetaHandle *tsdbCreateMetaHandle(int32_t numOfTables) {
SMetaHandle *pMetahandle = (SMetaHandle *)malloc(sizeof(SMetaHandle));
if (pMetahandle == NULL) {
return NULL;
}
@ -27,3 +27,22 @@ SMetaHandle * tsdbCreateMetaHandle (int32_t numOfTables) {
return pMetahandle;
}
static int32_t tsdbCheckTableCfg(STableCfg *pCfg) { return 0; }
int32_t tsdbCreateMeterImpl(SMetaHandle *pHandle, STableCfg *pCfg) {
if (tsdbCheckTableCfg(pCfg) < 0) {
return -1;
}
// TODO:
STable *pTable = (STable *)malloc(sizeof(STable));
if (pTable == NULL) {
return -1;
}
pHandle->pTables[pCfg->tableId] = pTable;
// TODO: add name to it
return 0;
}