add more code
This commit is contained in:
parent
c80686b961
commit
e871eb8cf6
|
@ -39,6 +39,7 @@ typedef enum {
|
||||||
|
|
||||||
#define IS_CREATE_STABLE(pCfg) ((pCfg)->tagValues != NULL)
|
#define IS_CREATE_STABLE(pCfg) ((pCfg)->tagValues != NULL)
|
||||||
|
|
||||||
|
// ---------- TSDB TABLE DEFINITION
|
||||||
typedef struct STable {
|
typedef struct STable {
|
||||||
STableId tableId;
|
STableId tableId;
|
||||||
TSDB_TABLE_TYPE type;
|
TSDB_TABLE_TYPE type;
|
||||||
|
@ -79,6 +80,10 @@ typedef struct STable {
|
||||||
|
|
||||||
} STable;
|
} STable;
|
||||||
|
|
||||||
|
void * tsdbEncodeTable(STable *pTable, int *contLen);
|
||||||
|
STable *tsdbDecodeTable(void *cont, int contLen);
|
||||||
|
void * tsdbFreeEncode(void *cont);
|
||||||
|
|
||||||
// ---------- TSDB META HANDLE DEFINITION
|
// ---------- TSDB META HANDLE DEFINITION
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t maxTables; // Max number of tables
|
int32_t maxTables; // Max number of tables
|
||||||
|
@ -108,8 +113,6 @@ int32_t tsdbFreeMeta(STsdbMeta *pMeta);
|
||||||
#define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData)
|
#define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData)
|
||||||
#define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex)
|
#define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex)
|
||||||
|
|
||||||
STSchema *tsdbGetTableSchema(STable *pTable);
|
|
||||||
|
|
||||||
// ---- Operation on SMetaHandle
|
// ---- Operation on SMetaHandle
|
||||||
#define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables)
|
#define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables)
|
||||||
#define TSDB_NUM_OF_SUPER_TABLES(pHandle) ((pHandle)->numOfSuperTables)
|
#define TSDB_NUM_OF_SUPER_TABLES(pHandle) ((pHandle)->numOfSuperTables)
|
||||||
|
|
|
@ -17,6 +17,57 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable);
|
||||||
static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable);
|
static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable);
|
||||||
|
static int tsdbEstimateTableEncodeSize(STable *pTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a TSDB table object as a binary content
|
||||||
|
* ASSUMPTIONS: VALID PARAMETERS
|
||||||
|
*
|
||||||
|
* @param pTable table object to encode
|
||||||
|
* @param contLen the encoded binary content length
|
||||||
|
*
|
||||||
|
* @return binary content for success
|
||||||
|
* NULL fro failure
|
||||||
|
*/
|
||||||
|
void *tsdbEncodeTable(STable *pTable, int *contLen) {
|
||||||
|
if (pTable == NULL) return NULL;
|
||||||
|
|
||||||
|
*contLen = tsdbEstimateTableEncodeSize(pTable);
|
||||||
|
if (*contLen < 0) return NULL;
|
||||||
|
|
||||||
|
void *ret = malloc(*contLen);
|
||||||
|
if (ret == NULL) return NULL;
|
||||||
|
|
||||||
|
// TODO: encode the object to the memory
|
||||||
|
{}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode from an encoded binary
|
||||||
|
* ASSUMPTIONS: valid parameters
|
||||||
|
*
|
||||||
|
* @param cont binary object
|
||||||
|
* @param contLen binary length
|
||||||
|
*
|
||||||
|
* @return TSDB table object for success
|
||||||
|
* NULL for failure
|
||||||
|
*/
|
||||||
|
STable *tsdbDecodeTable(void *cont, int contLen) {
|
||||||
|
STable *pTable = (STable *)calloc(1, sizeof(STable));
|
||||||
|
if (pTable == NULL) return NULL;
|
||||||
|
|
||||||
|
{
|
||||||
|
// TODO recover from the binary content
|
||||||
|
}
|
||||||
|
|
||||||
|
return pTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tsdbFreeEncode(void *cont) {
|
||||||
|
if (cont != NULL) free(cont);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the meta handle
|
* Initialize the meta handle
|
||||||
|
@ -261,4 +312,9 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
|
||||||
assert(pTable->type == TSDB_STABLE);
|
assert(pTable->type == TSDB_STABLE);
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tsdbEstimateTableEncodeSize(STable *pTable) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue