diff --git a/src/vnode/common/catalog/inc/type.h b/src/vnode/common/catalog/inc/type.h index ed8d84a22785e4e51f2262a426c08c1240edccb2..69aee2a5de6dc73f476cb465977d2e90f6341102 100644 --- a/src/vnode/common/catalog/inc/type.h +++ b/src/vnode/common/catalog/inc/type.h @@ -1,7 +1,9 @@ #if !defined(_TD_TYPE_H_) #define _TD_TYPE_H_ -typedef enum { +#include + +typedef enum : uint8_t { TD_DATATYPE_INVLD = 0, TD_DATATYPE_BOOL, TD_DATATYPE_TINYINT, diff --git a/src/vnode/common/tstr/inc/tstring.h b/src/vnode/common/tstr/inc/tstring.h index f7cea231f8d48a5d510f8f3b9487a984c1fb8138..742069b9db7aed819e45c5a0f128b7285abbb288 100644 --- a/src/vnode/common/tstr/inc/tstring.h +++ b/src/vnode/common/tstr/inc/tstring.h @@ -4,21 +4,37 @@ #define _TD_TSTRING_H_ #include +#include + +#define TD_TSTRING_INIT_SIZE 16 typedef char* tstring_t; // The string header typedef struct { - int32_t strLen; // Allocated data space - int32_t avail; // Available space + int32_t space; // Allocated data space char data[]; } STStrHdr; // Get the data length of the string -#define TSTRLEN(pstr) ((STStrHdr *)pstr)->strLen -// Get the available space -#define TSTRAVAIL(pstr) ((STStrHdr *)pstr)->avail +#define TSTRLEN(pstr) strlen((char *)pstr) // Get the real allocated string length -#define TSTRRLEN(pstr) ((STStrHdr *)pstr)->strLen + sizeof(STStrHdr) +#define TSTRSPACE(pstr) (*(int32_t *)((char *)pstr - sizeof(STStrHdr))) +// Get the available space +#define TSTAVAIL(pstr) (TSTRSPACE(pstr) - TSTRLEN(pstr)) + +// Create an empty tstring with default size +tstring_t tdNewTString(); +// Create an empty tstring with size +tstring_t tdNewTStringWithSize(uint32_t size); +// Create a tstring with a init value +tstring_t tdNewTStringWithValue(char *value); +// Create a tstring with a init value & size +tstring_t tdNewTStringWithValueSize(char *value, uint32_t size); + +tstring_t tstrcat(tstring_t dest, tstring_t src); +int32_t tstrcmp(tstring_t str1, tstring_t str2); +int32_t tstrncmp(tstring_t str1, tstring_t str2, int32_t n); + #endif // _TD_TSTRING_H_ diff --git a/src/vnode/tsdb/inc/tsdbFile.h b/src/vnode/tsdb/inc/tsdbFile.h new file mode 100644 index 0000000000000000000000000000000000000000..a4cfa595550252e506195875b0e41a245e465541 --- /dev/null +++ b/src/vnode/tsdb/inc/tsdbFile.h @@ -0,0 +1,29 @@ +#if !defined(_TD_TSDB_FILE_H_) +#define _TD_TSDB_FILE_H_ + +#include "tstring.h" + +typedef int32_t file_id_t; + +typedef enum : uint8_t { + TSDB_FILE_TYPE_HEAD, + TSDB_FILE_TYPE_DATA, + TSDB_FILE_TYPE_LAST, + TSDB_FILE_TYPE_META +} TSDB_FILE_TYPE; + +typedef struct { + int64_t fileSize; +} SFileInfo; + +typedef struct { + tstring_t fname; + SFileInfo; +} SFILE; + +tstring_t tdGetHeadFileName(/* TODO */); +tstring_t tdGetDataFileName(/* TODO */); +tstring_t tdGetLastFileName(/* TODO */); +tstring_t tdGetMetaFileName(/* TODO */); + +#endif // _TD_TSDB_FILE_H_ diff --git a/src/vnode/tsdb/inc/tsdbMeta.h b/src/vnode/tsdb/inc/tsdbMeta.h index 9ab39171a6ebce27bed7a60d1d6f9f4a76797149..684e80160f13bbadffb527cfb3eb8490aa1da136 100644 --- a/src/vnode/tsdb/inc/tsdbMeta.h +++ b/src/vnode/tsdb/inc/tsdbMeta.h @@ -51,6 +51,9 @@ typedef struct STable { // Tag values for this table char *pTagVal; + + // Cached data + SSkipList *pData; } STable; #define TSDB_GET_TABLE_ID(pTable) (((STable *)pTable)->tid).tableId