From 2da826f955d1263a4604cb022fcda6e4e50bd97f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 9 Feb 2020 14:58:06 +0800 Subject: [PATCH] more --- src/vnode/common/catalog/inc/type.h | 4 +++- src/vnode/common/tstr/inc/tstring.h | 28 ++++++++++++++++++++++------ src/vnode/tsdb/inc/tsdbFile.h | 29 +++++++++++++++++++++++++++++ src/vnode/tsdb/inc/tsdbMeta.h | 3 +++ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 src/vnode/tsdb/inc/tsdbFile.h diff --git a/src/vnode/common/catalog/inc/type.h b/src/vnode/common/catalog/inc/type.h index ed8d84a227..69aee2a5de 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 f7cea231f8..742069b9db 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 0000000000..a4cfa59555 --- /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 9ab39171a6..684e80160f 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 -- GitLab