From 89e8f14a791d4e6b1852bc0d3bf7c4e8a3ef3049 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 11 May 2022 02:37:52 +0000 Subject: [PATCH] refact: data format --- include/common/tdataformat.h | 16 ++++++++-------- source/common/src/tdataformat.c | 13 +++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 5a977b22e7..ee61098580 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -41,8 +41,8 @@ int32_t tEncodeTSRow(SEncoder *pEncoder, const STSRow2 *pRow); int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow); // STSchema -int32_t tTSchemaCreate(STSchema **ppTSchema); -int32_t tTSchemaDestroy(STSchema *pTSchema); +int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema **ppTSchema); +void tTSchemaDestroy(STSchema *pTSchema); // STRUCT ================= struct STColumn { @@ -54,12 +54,12 @@ struct STColumn { }; struct STSchema { - int32_t numOfCols; - schema_ver_t version; - uint16_t flen; - int32_t vlen; - int32_t tlen; - STColumn columns[]; + int32_t numOfCols; + int32_t version; + int32_t flen; + int32_t vlen; + int32_t tlen; + STColumn columns[]; }; struct STSRow2 { diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 558190a8ab..3f90fa36e6 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -43,6 +43,19 @@ int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow) { return 0; } +int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema **ppTSchema) { + *ppTSchema = (STSchema *)taosMemoryMalloc(sizeof(STSchema) + sizeof(STColumn) * ncols); + if (*ppTSchema == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + // (*ppTSchema) + return 0; +} + +void tTSchemaDestroy(STSchema *pTSchema) { taosMemoryFree(pTSchema); } + #if 1 // ==================== static void dataColSetNEleNull(SDataCol *pCol, int nEle); int tdAllocMemForCol(SDataCol *pCol, int maxPoints) { -- GitLab