From 44d5644c358f4db2d1433c757478506f6746dabc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 15 Jun 2020 11:16:32 +0000 Subject: [PATCH] TD-353 --- src/common/src/tdataformat.c | 3 +- src/inc/taosdef.h | 2 +- src/tsdb/inc/tsdbMain.h | 71 ++++++++++++++++++------------------ src/tsdb/src/tsdbBuffer.c | 7 ++-- 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index d8b67e1105..77af404eda 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -42,7 +42,7 @@ void *tdEncodeSchema(void *buf, STSchema *pSchema) { STColumn *pCol = schemaColAt(pSchema, i); buf = taosEncodeFixedI8(buf, colType(pCol)); buf = taosEncodeFixedI16(buf, colColId(pCol)); - buf = taosEncodeFixedI32(buf, colBytes(pCol)) : + buf = taosEncodeFixedI32(buf, colBytes(pCol)); } return buf; @@ -54,6 +54,7 @@ void *tdEncodeSchema(void *buf, STSchema *pSchema) { void *tdDecodeSchema(void *buf, STSchema **pRSchema) { int version = 0; int numOfCols = 0; + STSchemaBuilder schemaBuilder; buf = taosDecodeFixedI32(buf, &version); buf = taosDecodeFixedI32(buf, &numOfCols); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f84a7581e4..7490de90d0 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -362,7 +362,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TAOS_QTYPE_WAL 2 #define TAOS_QTYPE_CQ 3 -typedef enum : uint8_t{ +typedef enum { TSDB_SUPER_TABLE = 0, // super table TSDB_CHILD_TABLE = 1, // table created from super table TSDB_NORMAL_TABLE = 2, // ordinary table diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index 34b8b99b5b..c000ac7e79 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -40,26 +40,25 @@ extern int tsdbDebugFlag; #define TSDB_MAX_TABLE_SCHEMAS 16 #define TSDB_FILE_HEAD_SIZE 512 #define TSDB_FILE_DELIMITER 0xF00AFA0F -#define // Definitions // ------------------ tsdbMeta.c typedef struct STable { - ETableType type; - tstr* name; // NOTE: there a flexible string here - STableId tableId; - uint64_t suid; - STable* pSuper; // super table pointer - uint8_t numOfSchemas; - STSchema schema[TSDB_MAX_TABLE_SCHEMAS]; - STSchema* tagSchema; - SKVRow tagVal; - void* pIndex; // For TSDB_SUPER_TABLE, it is the skiplist index - void* eventHandler; // TODO - void* streamHandler; // TODO - TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure - char* sql; - void* cqhandle; + ETableType type; + tstr* name; // NOTE: there a flexible string here + STableId tableId; + uint64_t suid; + struct STable* pSuper; // super table pointer + uint8_t numOfSchemas; + STSchema schema[TSDB_MAX_TABLE_SCHEMAS]; + STSchema* tagSchema; + SKVRow tagVal; + void* pIndex; // For TSDB_SUPER_TABLE, it is the skiplist index + void* eventHandler; // TODO + void* streamHandler; // TODO + TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure + char* sql; + void* cqhandle; T_REF_DECLARE(); } STable; @@ -149,6 +148,25 @@ typedef struct { int direction; } SFileGroupIter; +// ------------------ tsdbMain.c +typedef struct { + int8_t state; + + char* rootDir; + STsdbCfg config; + STsdbAppH appH; + STsdbStat stat; + STsdbMeta* tsdbMeta; + STsdbBufPool* pPool; + SMemTable* mem; + SMemTable* imem; + STsdbFileH* tsdbFileH; + int commit; + pthread_t commitThread; + pthread_mutex_t mutex; + bool repoLocked; +} STsdbRepo; + // ------------------ tsdbRWHelper.c typedef struct { uint32_t len; @@ -241,24 +259,6 @@ typedef struct { void* compBuffer; // Buffer for temperary compress/decompress purpose } SRWHelper; -// ------------------ tsdbMain.c -typedef struct { - int8_t state; - - char* rootDir; - STsdbCfg config; - STsdbAppH appH; - STsdbStat stat; - STsdbMeta* tsdbMeta; - STsdbBufPool* pPool; - SMemTable* mem; - SMemTable* imem; - STsdbFileH* tsdbFileH; - int commit; - pthread_t commitThread; - pthread_mutex_t mutex; - bool repoLocked; -} STsdbRepo; // Operations // ------------------ tsdbMeta.c @@ -289,7 +289,7 @@ void tsdbUnRefTable(STable* pTable); STsdbBufPool* tsdbNewBufPool(); void tsdbFreeBufPool(STsdbBufPool* pBufPool); int tsdbOpenBufPool(STsdbRepo* pRepo); -int tsdbOpenBufPool(STsdbRepo* pRepo); +void tsdbCloseBufPool(STsdbRepo* pRepo); SListNode* tsdbAllocBufBlockFromPool(STsdbRepo* pRepo); // ------------------ tsdbMemTable.c @@ -333,7 +333,6 @@ void tsdbFreeFileH(STsdbFileH* pFileH); char* tsdbGetMetaFileName(char* rootDir); int tsdbLockRepo(STsdbRepo* pRepo); int tsdbUnlockRepo(STsdbRepo* pRepo); -void* tsdbCommitData(void* arg); #if 0 diff --git a/src/tsdb/src/tsdbBuffer.c b/src/tsdb/src/tsdbBuffer.c index 70f8e054f8..95136454a0 100644 --- a/src/tsdb/src/tsdbBuffer.c +++ b/src/tsdb/src/tsdbBuffer.c @@ -86,7 +86,7 @@ int tsdbOpenBufPool(STsdbRepo *pRepo) { } tsdbTrace("vgId:%d buffer pool is opened! bufBlockSize:%d tBufBlocks:%d nBufBlocks:%d", REPO_ID(pRepo), - pBufPool->bufBlockSize, pBufPool->tBufBlocks, pBufPool->nBufBlocks); + pPool->bufBlockSize, pPool->tBufBlocks, pPool->nBufBlocks); return 0; @@ -113,11 +113,10 @@ void tsdbCloseBufPool(STsdbRepo *pRepo) { } SListNode *tsdbAllocBufBlockFromPool(STsdbRepo *pRepo) { - ASSERT(pRepo != NULL && pRepo->pool != NULL); + ASSERT(pRepo != NULL && pRepo->pPool != NULL); ASSERT(IS_REPO_LOCKED(pRepo)); - STsdbCfg * pCfg = &pRepo->config; - STsdbBufPool *pBufPool = pRepo->pool; + STsdbBufPool *pBufPool = pRepo->pPool; while (POOL_IS_EMPTY(pBufPool)) { pthread_cond_wait(&(pBufPool->poolNotEmpty), &(pRepo->mutex));