提交 4d6bf767 编写于 作者: H Hongze Cheng

more

上级 472d52a2
......@@ -24,7 +24,7 @@ typedef struct {
typedef struct STSDBCache {
// Number of blocks the cache is allocated
int32_t numOfBlocks;
SDList *cacheList;
STSDBCacheBlock *cacheList;
void * current;
} SCacheHandle;
......@@ -36,6 +36,6 @@ typedef struct STSDBCache {
#define TSDB_NEXT_CACHE_BLOCK(pBlock) ((pBlock)->next)
#define TSDB_PREV_CACHE_BLOCK(pBlock) ((pBlock)->prev)
STSDBCache *tsdbCreateCache();
SCacheHandle *tsdbCreateCache(int32_t numOfBlocks);
#endif // _TD_TSDBCACHE_H_
......@@ -81,4 +81,10 @@ SVSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables)
#define TSDB_NUM_OF_SUPER_TABLES(pHandle) ((pHandle)->numOfSuperTables)
#define TSDB_TABLE_OF_ID(pHandle, id) ((pHandle)->pTables)[id]
#define TSDB_GET_TABLE_OF_NAME(pHandle, name) /* TODO */
\ No newline at end of file
#define TSDB_GET_TABLE_OF_NAME(pHandle, name) /* TODO */
// Create a new meta handle with configuration
SMetaHandle * tsdbCreateMetaHandle (int32_t numOfTables);
// Recover the meta handle from the file
SMetaHandle * tsdbOpenMetaHandle(int fd);
#include <stdint.h>
#include <pthread.h>
#include <stdlib.h>
#include "tsdb.h"
#include "disk.h"
// #include "disk.h"
#include "tsdbMeta.h"
#include "tsdbCache.h"
......@@ -17,34 +18,10 @@ typedef struct STSDBRepo
// The cache Handle
SCacheHandle *pCacheHandle;
/* Disk tier handle for multi-tier storage
*
* The handle is responsible for dealing with object-oriented
* storage.
*/
// Disk tier handle for multi-tier storage
SDiskTier *pDiskTier;
/* Cache block list
*/
SCacheBlock *pCacheBloclList;
/* Map from tableId-->STable
*/
STable *pTableList;
/* Map from tableName->tableId
* TODO: may use dict
*/
void *pTableDict;
/* Map from super tableName->table
* TODO: may use dict
*/
void *pSTableDict;
/* File Store
*/
// File Store
void *pFileStore;
pthread_mutext_t tsdbMutex;
......@@ -53,3 +30,39 @@ typedef struct STSDBRepo
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
// Check the correctness of the TSDB configuration
static int32_t tsdbCheckCfg(STSDBCfg *pCfg) {
// TODO
return 0;
}
tsdb_repo_t *tsdbCreateRepo(STSDBCfg *pCfg, int32_t *error) {
int32_t err = 0;
err = tsdbCheckCfg(pCfg);
if (err != 0) {
// TODO: deal with the error here
}
STSDBRepo *pRepo = (STSDBRepo *) malloc(sizeof(STSDBRepo));
if (pRepo == NULL) {
// TODO: deal with error
}
// TODO: Initailize pMetahandle
pRepo->pMetaHandle = tsdbCreateMetaHandle(pCfg->maxTables);
if (pRepo->pMetaHandle == NULL) {
// TODO: deal with error
free(pRepo);
return NULL;
}
// TODO: Initialize cache handle
pRepo->pCacheHandle = tsdbCreateCache(5);
if (pRepo->pCacheHandle == NULL) {
// TODO: free the object and return error
return NULL;
}
return (tsdb_repo_t *)pRepo;
}
\ No newline at end of file
#include <stdlib.h>
#include "tsdbCache.h"
SCacheHandle *tsdbCreateCache(int32_t numOfBlocks) {
SCacheHandle *pCacheHandle = (SCacheHandle *)malloc(sizeof(SCacheHandle));
if (pCacheHandle == NULL) {
// TODO : deal with the error
return NULL;
}
return pCacheHandle;
}
\ No newline at end of file
#include <stdlib.h>
#include "tsdb.h"
#include "tsdbMeta.h"
SVSchema *tsdbGetTableSchema(STable *pTable) {
SMetaHandle * tsdbCreateMetaHandle (int32_t numOfTables) {
SMetaHandle * pMetahandle = (SMetaHandle *)malloc(sizeof(SMetaHandle));
if (pMetahandle == NULL) {
return NULL;
}
pMetahandle->numOfTables = 0;
pMetahandle->numOfSuperTables = 0;
pMetahandle->pTables = calloc(sizeof(STable *) * numOfTables);
if (pMetahandle->pTables == NULL) {
free(pMetahandle);
return NULL;
}
}
// TODO : initialize the map
// pMetahandle->pNameTableMap = ;
if (pMetahandle->pNameTableMap == NULL) {
free(pMetahandle->pTables);
free(pMetahandle);
return NULL;
}
return pMetahandle;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册