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

more

上级 2da826f9
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
#include "type.h" #include "type.h"
typedef struct _scolumn { typedef struct _scolumn {
td_datatype_t type; tstring_t colName; // column name
int32_t bytes; td_datatype_t type; // data type
int32_t bytes; // number of bytes
} SColumn; } SColumn;
typedef struct SSchema { typedef struct SSchema {
...@@ -18,6 +19,7 @@ typedef struct SSchema { ...@@ -18,6 +19,7 @@ typedef struct SSchema {
// Column with version // Column with version
typedef struct { typedef struct {
tstring_t colName;
td_datatype_t type; td_datatype_t type;
int32_t colId; int32_t colId;
int32_t bytes; int32_t bytes;
...@@ -27,7 +29,7 @@ typedef struct { ...@@ -27,7 +29,7 @@ typedef struct {
typedef struct { typedef struct {
int32_t version; // Schema with version int32_t version; // Schema with version
int32_t numOfCols; int32_t numOfCols;
int32_t columnId; int32_t numOfTags;
SVColumn *columns; SVColumn *columns;
} SVSchema; } SVSchema;
......
...@@ -18,9 +18,16 @@ typedef struct { ...@@ -18,9 +18,16 @@ typedef struct {
typedef struct { typedef struct {
tstring_t fname; tstring_t fname;
SFileInfo; SFileInfo fInfo;
} SFILE; } SFILE;
typedef struct {
int64_t offset;
int64_t skey;
int64_t ekey;
int16_t numOfBlocks;
} SDataBlock;
tstring_t tdGetHeadFileName(/* TODO */); tstring_t tdGetHeadFileName(/* TODO */);
tstring_t tdGetDataFileName(/* TODO */); tstring_t tdGetDataFileName(/* TODO */);
tstring_t tdGetLastFileName(/* TODO */); tstring_t tdGetLastFileName(/* TODO */);
......
...@@ -2,61 +2,83 @@ ...@@ -2,61 +2,83 @@
* For internal usage * For internal usage
************************************/ ************************************/
#include "tsdb.h" #include <pthread.h>
typedef enum { #include "tsdb.h"
TSDB_TABLE_NORMAL,
TSDB_TABLE_STABLE,
TSDB_TABLE_SUPER
} TSDB_TABLE_TYPE;
// Below is the struct definition of super table // Initially, there are 4 tables
// TODO: May merge all table definitions #define TSDB_INIT_NUMBER_OF_SUPER_TABLE 4
typedef struct _super_table {
int64_t uid;
char *tableName;
int64_t createdTime; typedef enum : uint8_t {
TSDB_SUPER_TABLE, // super table
// TODO: try to merge the two schema into one TSDB_NTABLE, // table not created from super table
SSchema *pSchema; TSDB_STABLE // table created from super table
SSchema *pTagSchema; } TSDB_TABLE_TYPE;
// 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;
// Table created from super table
typedef struct STable { typedef struct STable {
tsdb_id_t tableId; tsdb_id_t tableId;
int64_t uid; int64_t uid;
char *tableName; char * tableName;
TSDB_TABLE_TYPE type;
int64_t createdTime; int64_t createdTime;
// super table UID // 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; char *pTagVal;
// Cached data // Object content;
SSkipList *pData; // 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; } STable;
#define TSDB_GET_TABLE_ID(pTable) (((STable *)pTable)->tid).tableId typedef struct {
#define TSDB_GET_TABLE_UID(pTable) (((STable *)pTable)->tid).uid 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 "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.
先完成此消息的编辑!
想要评论请 注册