提交 aefd622e 编写于 作者: H Hongze Cheng

more

上级 2da826f9
......@@ -7,8 +7,9 @@
#include "type.h"
typedef struct _scolumn {
td_datatype_t type;
int32_t bytes;
tstring_t colName; // column name
td_datatype_t type; // data type
int32_t bytes; // number of bytes
} SColumn;
typedef struct SSchema {
......@@ -18,6 +19,7 @@ typedef struct SSchema {
// Column with version
typedef struct {
tstring_t colName;
td_datatype_t type;
int32_t colId;
int32_t bytes;
......@@ -27,7 +29,7 @@ typedef struct {
typedef struct {
int32_t version; // Schema with version
int32_t numOfCols;
int32_t columnId;
int32_t numOfTags;
SVColumn *columns;
} SVSchema;
......
......@@ -18,9 +18,16 @@ typedef struct {
typedef struct {
tstring_t fname;
SFileInfo;
SFileInfo fInfo;
} SFILE;
typedef struct {
int64_t offset;
int64_t skey;
int64_t ekey;
int16_t numOfBlocks;
} SDataBlock;
tstring_t tdGetHeadFileName(/* TODO */);
tstring_t tdGetDataFileName(/* TODO */);
tstring_t tdGetLastFileName(/* TODO */);
......
......@@ -2,61 +2,83 @@
* For internal usage
************************************/
#include "tsdb.h"
#include <pthread.h>
typedef enum {
TSDB_TABLE_NORMAL,
TSDB_TABLE_STABLE,
TSDB_TABLE_SUPER
} TSDB_TABLE_TYPE;
#include "tsdb.h"
// Below is the struct definition of super table
// TODO: May merge all table definitions
typedef struct _super_table {
int64_t uid;
char *tableName;
// Initially, there are 4 tables
#define TSDB_INIT_NUMBER_OF_SUPER_TABLE 4
int64_t createdTime;
// TODO: try to merge the two schema into one
SSchema *pSchema;
SSchema *pTagSchema;
// A index created for all tables created using this super table
SSkipList * pIndex;
} SSTable;
// Normal table struct definition, table not
// created from super table
typedef struct SNTable
{
tsdb_id_t tableId;
int64_t uid;
char *tableName;
int64_t createdTime;
SSchema *pSchema
} SNTable;
typedef enum : uint8_t {
TSDB_SUPER_TABLE, // super table
TSDB_NTABLE, // table not created from super table
TSDB_STABLE // table created from super table
} TSDB_TABLE_TYPE;
// Table created from super table
typedef struct STable {
tsdb_id_t tableId;
int64_t uid;
char *tableName;
tsdb_id_t tableId;
int64_t uid;
char * tableName;
TSDB_TABLE_TYPE type;
int64_t createdTime;
// super table UID
int64_t stableUid;
tsdb_id_t superTableId;
// Tag values for this table
// Schema for this table
// For TSDB_SUPER_TABLE, it is the schema including tags
// For TSDB_NTABLE, it is only the schema, not including tags
// For TSDB_STABLE, it is NULL
SVSchema *pSchema;
// Tag value for this table
// For TSDB_SUPER_TABLE and TSDB_NTABLE, it is NULL
// For TSDB_STABLE, it is the tag value string
char *pTagVal;
// Cached data
SSkipList *pData;
// Object content;
// For TSDB_SUPER_TABLE, it is the index of tables created from it
// For TSDB_STABLE and TSDB_NTABLE, it is the cache data
union {
void *pData;
void *pIndex;
} content;
// A handle to deal with event
void *eventHandle;
// A handle to deal with stream
void *streamHandle;
} STable;
#define TSDB_GET_TABLE_ID(pTable) (((STable *)pTable)->tid).tableId
#define TSDB_GET_TABLE_UID(pTable) (((STable *)pTable)->tid).uid
typedef struct {
int32_t numOfTables; // Number of tables not including TSDB_SUPER_TABLE (#TSDB_NTABLE + #TSDB_STABLE)
int32_t numOfSuperTables; // Number of super tables (#TSDB_SUPER_TABLE)
// An array of tables (TSDB_NTABLE and TSDB_STABLE) in this TSDB repository
STable **pTables;
// A map of tableName->tableId
// TODO: May use hash table
void *pNameTableMap;
} SMetaHandle;
// ---- Operation on STable
#define TSDB_TABLE_ID(pTable) ((pTable)->tableId)
#define TSDB_TABLE_UID(pTable) ((pTable)->uid)
#define TSDB_TABLE_NAME(pTable) ((pTable)->tableName)
#define TSDB_TABLE_TYPE(pTable) ((pTable)->type)
#define TSDB_TABLE_SUPER_TABLE_UID(pTable) ((pTable)->stableUid)
#define TSDB_TABLE_IS_SUPER_TABLE(pTable) (TSDB_TABLE_TYPE(pTable) == TSDB_SUPER_TABLE)
#define TSDB_TABLE_TAG_VALUE(pTable) ((pTable)->pTagVal)
#define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData)
#define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex)
SVSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_IS_SUPER_TABLE(pTable)
// ---- Operation on SMetaHandle
#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
#include "tsdb.h"
#include "tsdbMeta.h"
SVSchema *tsdbGetTableSchema(STable *pTable) {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册