From 194ffc9438c433d8cbefaaf1b139640d3ed0d45b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sat, 8 Feb 2020 18:58:46 +0800 Subject: [PATCH] more --- src/vnode/common/catalog/inc/schema.h | 22 ++++++++++++++++++++++ src/vnode/common/data/inc/data.h | 2 ++ src/vnode/common/tstr/inc/tstring.h | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/vnode/common/tstr/inc/tstring.h diff --git a/src/vnode/common/catalog/inc/schema.h b/src/vnode/common/catalog/inc/schema.h index 89a048574c..add0fdd9a1 100644 --- a/src/vnode/common/catalog/inc/schema.h +++ b/src/vnode/common/catalog/inc/schema.h @@ -3,6 +3,7 @@ #include +#include "tstring.h" #include "type.h" typedef struct _scolumn { @@ -15,4 +16,25 @@ typedef struct SSchema { SColumn *columns; } SSchema; +// Column with version +typedef struct { + td_datatype_t type; + int32_t colId; + int32_t bytes; +} SVColumn; + +// Schema with version +typedef struct { + int32_t version; // Schema with version + int32_t numOfCols; + int32_t columnId; + SVColumn *columns; +} SVSchema; + +int32_t tdAddColumnToSchema(tstring_t pSchema, SColumn col); + +td_datatype_t tdGetTypeOfCol(SSchema *pSchema, int32_t col); +int32_t tdGetLengthOfCol(SSchema *pSchema, int32_t col); + + #endif // _TD_SCHEMA_H_ diff --git a/src/vnode/common/data/inc/data.h b/src/vnode/common/data/inc/data.h index 5ccecd4718..3768375025 100644 --- a/src/vnode/common/data/inc/data.h +++ b/src/vnode/common/data/inc/data.h @@ -3,6 +3,8 @@ #include +#include "schema.h" + /* The row data should in the form of */ diff --git a/src/vnode/common/tstr/inc/tstring.h b/src/vnode/common/tstr/inc/tstring.h new file mode 100644 index 0000000000..f7cea231f8 --- /dev/null +++ b/src/vnode/common/tstr/inc/tstring.h @@ -0,0 +1,24 @@ +/* A dynamic string library + */ +#if !defined(_TD_TSTRING_H_) +#define _TD_TSTRING_H_ + +#include + +typedef char* tstring_t; + +// The string header +typedef struct { + int32_t strLen; // Allocated data space + int32_t avail; // Available 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 +// Get the real allocated string length +#define TSTRRLEN(pstr) ((STStrHdr *)pstr)->strLen + sizeof(STStrHdr) + +#endif // _TD_TSTRING_H_ -- GitLab