diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index 5a7b605cb81c20bb8f530e30a0dc6a34688a92ec..92270a886f4cae4363e8c774bfa2622c3989b23b 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -1,4 +1,7 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -PROJECT(TDengine) +cmake_minimum_required(VERSION 2.8) -ADD_SUBDIRECTORY(detail) \ No newline at end of file +project(tsdb) + +add_subdirectory(common) + +add_subdirectory(tsdb) \ No newline at end of file diff --git a/src/vnode/common/CMakeLists.txt b/src/vnode/common/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..38803c2421ffc97bbecf018d02b962228af9eb62 --- /dev/null +++ b/src/vnode/common/CMakeLists.txt @@ -0,0 +1,8 @@ +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) + +list(REMOVE_ITEM SOURCE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/src/vnodePeer.c) + +message(STATUS "Common source file ${SOURCE_LIST}") + +add_library(common ${SOURCE_LIST}) +target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc") diff --git a/src/vnode/common/src/schema.c b/src/vnode/common/src/schema.c index cf0664c7cc0dee5542cc958921e01c60acb568ff..79b41533d23a0ef5ae8ace9da67e9416d5f604b0 100644 --- a/src/vnode/common/src/schema.c +++ b/src/vnode/common/src/schema.c @@ -51,7 +51,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema) { char *pName = TD_ISCHEMA_COL_NAMES(pISchema); for (int32_t i = 0; i < totalCols; i++) { SColumn *pCol = TD_SCHEMA_COLUMN_AT(TD_ISCHEMA_SCHEMA(pISchema), i); - char * colName = TD_COLUMN_NAME(TD_SCHEMA_COLUMN_AT(pSchema, i), i); + char * colName = TD_COLUMN_NAME(TD_SCHEMA_COLUMN_AT(pSchema, i)); TD_COLUMN_NAME(pCol) = pName; diff --git a/src/vnode/tsdb/CMakeLists.txt b/src/vnode/tsdb/CMakeLists.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4a88fbd7d65dfe6a327d7b5ad0348fb12dc079e4 100644 --- a/src/vnode/tsdb/CMakeLists.txt +++ b/src/vnode/tsdb/CMakeLists.txt @@ -0,0 +1,9 @@ +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) + +message(STATUS "tsdb source files: ${SOURCE_LIST}") + +add_library(tsdb STATIC ${SOURCE_LIST}) + +target_link_libraries(tsdb common) + +target_include_directories(tsdb PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc") \ No newline at end of file diff --git a/src/vnode/tsdb/inc/tsdb.h b/src/vnode/tsdb/inc/tsdb.h index 3842872910cddb2db4978139da010a42895c0176..b04f0148f06b27d8dd3b2e6d3e35519828eb2e08 100644 --- a/src/vnode/tsdb/inc/tsdb.h +++ b/src/vnode/tsdb/inc/tsdb.h @@ -8,7 +8,7 @@ #include #include -#include "cache.h" +// #include "cache.h" #include "schema.h" #define TSDB_VERSION_MAJOR 1 @@ -69,7 +69,7 @@ typedef struct { SDataShardPolicy dataShardPolicy; SBlockRowsPolicy blockRowsPolicy; SRetentionPolicy retentionPlicy; // retention configuration - SCachePool * cachePool; // the cache pool the repository to use + void * cachePool; // the cache pool the repository to use } STSDBCfg; // the TSDB repository info @@ -220,6 +220,9 @@ typedef struct STimeWindow { int64_t ekey; } STimeWindow; +typedef struct { +} SColumnFilterInfo; + // query condition to build vnode iterator typedef struct STSDBQueryCond { STimeWindow twindow; @@ -252,6 +255,10 @@ typedef struct STableIDList { int32_t num; } STableIDList; +typedef struct { + +} SFields; + /** * Get the data block iterator, starting from position according to the query condition * @param pRepo the TSDB repository to query on diff --git a/src/vnode/tsdb/inc/tsdbCache.h b/src/vnode/tsdb/inc/tsdbCache.h index b0993c1e093be67e1267c3bc897f25cf40d50c01..049cdc0847d8da27f46fbf77d30d9d24fc3bc67a 100644 --- a/src/vnode/tsdb/inc/tsdbCache.h +++ b/src/vnode/tsdb/inc/tsdbCache.h @@ -3,7 +3,7 @@ #include -#include "cache.h" +// #include "cache.h" #define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16*1024*1024 /* 16M */ @@ -13,22 +13,21 @@ typedef struct { int32_t numOfRows // numOfRows } STableCacheInfo; -typedef struct { - char *pData; - STableCacheInfo *pTableInfo; - SCacheBlock *prev; - SCacheBlock *next; +typedef struct _tsdb_cache_block { + char * pData; + STableCacheInfo * pTableInfo; + struct _tsdb_cache_block *prev; + struct _tsdb_cache_block *next; } STSDBCacheBlock; // Use a doublely linked list to implement this typedef struct STSDBCache { // Number of blocks the cache is allocated - int32_t numOfBlocks; + int32_t numOfBlocks; STSDBCacheBlock *cacheList; - void * current; + void * current; } SCacheHandle; - // ---- Operation on STSDBCacheBlock #define TSDB_CACHE_BLOCK_DATA(pBlock) ((pBlock)->pData) #define TSDB_CACHE_AVAIL_SPACE(pBlock) ((char *)((pBlock)->pTableInfo) - ((pBlock)->pData)) diff --git a/src/vnode/tsdb/inc/tsdbFile.h b/src/vnode/tsdb/inc/tsdbFile.h index 91abea076f4551257ec83620833c00045a084fb2..02eb0c78813a7e89c326bfc6b99b3351b805ab67 100644 --- a/src/vnode/tsdb/inc/tsdbFile.h +++ b/src/vnode/tsdb/inc/tsdbFile.h @@ -1,7 +1,8 @@ #if !defined(_TD_TSDB_FILE_H_) #define _TD_TSDB_FILE_H_ -#include "tstring.h" +#include +// #include "tstring.h" typedef int32_t file_id_t; @@ -24,7 +25,7 @@ typedef struct { } SFileInfo; typedef struct { - tstring_t fname; + char * fname; SFileInfo fInfo; } SFILE; diff --git a/src/vnode/tsdb/inc/tsdbMeta.h b/src/vnode/tsdb/inc/tsdbMeta.h index 28bafa1dc8a8b426edca2e4a0397d23676d1b1ec..588394459e151f4fc03c0c5923dcf05082daeba5 100644 --- a/src/vnode/tsdb/inc/tsdbMeta.h +++ b/src/vnode/tsdb/inc/tsdbMeta.h @@ -4,7 +4,7 @@ #include -#include "taosdef.h" +// #include "taosdef.h" // Initially, there are 4 tables #define TSDB_INIT_NUMBER_OF_SUPER_TABLE 4 @@ -30,7 +30,7 @@ typedef struct STable { // For TSDB_SUPER_TABLE, it is the schema including tags // For TSDB_NTABLE, it is only the schema, not including tags // For TSDB_STABLE, it is NULL - SVSchema *pSchema; + SSchema *pSchema; // Tag value for this table // For TSDB_SUPER_TABLE and TSDB_NTABLE, it is NULL @@ -75,7 +75,7 @@ typedef struct { #define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData) #define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex) -SVSchema *tsdbGetTableSchema(STable *pTable); +SSchema *tsdbGetTableSchema(STable *pTable); // ---- Operation on SMetaHandle #define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables) diff --git a/src/vnode/tsdb/src/tsdb.c b/src/vnode/tsdb/src/tsdb.c index d0087945240e8ac83befb1a5fb45a7a4c3aa41ed..7e13e3183ad8ab33e9f975356359fd7d247f069c 100644 --- a/src/vnode/tsdb/src/tsdb.c +++ b/src/vnode/tsdb/src/tsdb.c @@ -2,14 +2,15 @@ #include #include -#include "taosdef.h" +// #include "taosdef.h" // #include "disk.h" +#include "tsdb.h" #include "tsdbCache.h" #include "tsdbMeta.h" typedef struct STSDBRepo { // TSDB configuration - STSDBcfg *pCfg; + STSDBCfg *pCfg; // The meter meta handle of this TSDB repository SMetaHandle *pMetaHandle; @@ -18,12 +19,12 @@ typedef struct STSDBRepo { SCacheHandle *pCacheHandle; // Disk tier handle for multi-tier storage - SDiskTier *pDiskTier; + void *pDiskTier; // File Store void *pFileStore; - pthread_mutext_t tsdbMutex; + pthread_mutex_t tsdbMutex; } STSDBRepo; diff --git a/src/vnode/tsdb/src/tsdbFileStore.c b/src/vnode/tsdb/src/tsdbFileStore.c index f6cc959f8f6dd24fb9ef4d65c23e5d8debf97929..a47f2eb1e48c85b47ab4e5adce262074d03942d6 100644 --- a/src/vnode/tsdb/src/tsdbFileStore.c +++ b/src/vnode/tsdb/src/tsdbFileStore.c @@ -1,6 +1,6 @@ #include "tsdbFile.h" char *tsdbGetFileName(char *dirName, char *fname, TSDB_FILE_TYPE type){ - char *suffix = tsdbFileSuffix[type]; + // char *suffix = tsdbFileSuffix[type]; // TODO } \ No newline at end of file diff --git a/src/vnode/tsdb/src/tsdbMeta.c b/src/vnode/tsdb/src/tsdbMeta.c index 5bc82dfa103056e58abe3746460503d85b8e824c..9fad7b126931f40ccae7a3c3bf001e933c4d9115 100644 --- a/src/vnode/tsdb/src/tsdbMeta.c +++ b/src/vnode/tsdb/src/tsdbMeta.c @@ -1,6 +1,7 @@ #include -#include "taosdef.h" +// #include "taosdef.h" +#include "tsdb.h" #include "tsdbMeta.h" SMetaHandle *tsdbCreateMetaHandle(int32_t numOfTables) { @@ -11,7 +12,7 @@ SMetaHandle *tsdbCreateMetaHandle(int32_t numOfTables) { pMetahandle->numOfTables = 0; pMetahandle->numOfSuperTables = 0; - pMetahandle->pTables = calloc(sizeof(STable *) * numOfTables); + pMetahandle->pTables = calloc(sizeof(STable *), numOfTables); if (pMetahandle->pTables == NULL) { free(pMetahandle); return NULL;