From 532d4a26b798210598e615b3722aad33564ea948 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Wed, 4 Mar 2020 02:54:56 +0000 Subject: [PATCH] more --- src/vnode/CMakeLists.txt | 2 -- src/vnode/common/inc/type.h | 13 +------------ src/vnode/common/src/dataformat.c | 4 ++++ src/vnode/common/src/schema.c | 16 ++++++++++++++++ src/vnode/tests/tsdb/tsdbTests.cpp | 16 +++++++++++++--- src/vnode/tsdb/CMakeLists.txt | 2 +- src/vnode/tsdb/inc/tsdbFile.h | 13 +++++++------ 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index 5acf0483ec..22770e3799 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 2.8) -project(tsdb) - add_subdirectory(common) add_subdirectory(tsdb) diff --git a/src/vnode/common/inc/type.h b/src/vnode/common/inc/type.h index 685fc2e240..1aaa95cb90 100644 --- a/src/vnode/common/inc/type.h +++ b/src/vnode/common/inc/type.h @@ -16,18 +16,7 @@ typedef enum { TD_DATATYPE_BINARY } td_datatype_t; -const int32_t rowDataLen[] = { - sizeof(int8_t), // TD_DATATYPE_BOOL, - sizeof(int8_t), // TD_DATATYPE_TINYINT, - sizeof(int16_t), // TD_DATATYPE_SMALLINT, - sizeof(int32_t), // TD_DATATYPE_INT, - sizeof(int64_t), // TD_DATATYPE_BIGINT, - sizeof(float), // TD_DATATYPE_FLOAT, - sizeof(double), // TD_DATATYPE_DOUBLE, - sizeof(int32_t), // TD_DATATYPE_VARCHAR, - sizeof(int32_t), // TD_DATATYPE_NCHAR, - sizeof(int32_t) // TD_DATATYPE_BINARY -}; +extern const int32_t rowDataLen[]; // TODO: finish below #define TD_DATATYPE_BOOL_NULL diff --git a/src/vnode/common/src/dataformat.c b/src/vnode/common/src/dataformat.c index f09ea1445b..18b78a4129 100644 --- a/src/vnode/common/src/dataformat.c +++ b/src/vnode/common/src/dataformat.c @@ -29,4 +29,8 @@ int32_t tdGetMaxDataRowSize(SSchema *pSchema) { nbytes += TD_DATA_ROW_HEADER_SIZE; return nbytes; +} + +SDataRow tdSDataRowDup(SDataRow rdata) { + return NULL; } \ No newline at end of file diff --git a/src/vnode/common/src/schema.c b/src/vnode/common/src/schema.c index 79b41533d2..eb1b4eb84b 100644 --- a/src/vnode/common/src/schema.c +++ b/src/vnode/common/src/schema.c @@ -1,6 +1,18 @@ #include #include "schema.h" +const int32_t rowDataLen[] = { + sizeof(int8_t), // TD_DATATYPE_BOOL, + sizeof(int8_t), // TD_DATATYPE_TINYINT, + sizeof(int16_t), // TD_DATATYPE_SMALLINT, + sizeof(int32_t), // TD_DATATYPE_INT, + sizeof(int64_t), // TD_DATATYPE_BIGINT, + sizeof(float), // TD_DATATYPE_FLOAT, + sizeof(double), // TD_DATATYPE_DOUBLE, + sizeof(int32_t), // TD_DATATYPE_VARCHAR, + sizeof(int32_t), // TD_DATATYPE_NCHAR, + sizeof(int32_t) // TD_DATATYPE_BINARY +}; static size_t tdGetEstimatedISchemaLen(SSchema *pSchema) { size_t colNameLen = 0; @@ -82,4 +94,8 @@ int32_t tdGetColumnIdxById(SSchema *pSchema, int32_t colId) { } } return -1; +} + +SSchema *tdDupSchema(SSchema *pSchema) { + return NULL; } \ No newline at end of file diff --git a/src/vnode/tests/tsdb/tsdbTests.cpp b/src/vnode/tests/tsdb/tsdbTests.cpp index 3d7f41df24..8e1b37b191 100644 --- a/src/vnode/tests/tsdb/tsdbTests.cpp +++ b/src/vnode/tests/tsdb/tsdbTests.cpp @@ -4,9 +4,19 @@ #include "tsdb.h" TEST(TsdbTest, createTsdbRepo) { - STsdbCfg *pCfg = (STsdbCfg *)malloc(sizeof(STsdbCfg)); + STsdbCfg config; - free(pCfg); + config.precision = TSDB_PRECISION_MILLI; + config.tsdbId = 0; + config.maxTables = 100; + config.daysPerFile = 10; + config.minRowsPerFileBlock = 100; + config.maxRowsPerFileBlock = 4096; + config.maxCacheSize = 4 * 1024 * 1024; - ASSERT_EQ(1, 2/2); + tsdb_repo_t *pRepo = tsdbCreateRepo("/root/mnt/test/vnode0", &config, NULL); + + ASSERT_NE(pRepo, nullptr); + + tsdbCloseRepo(pRepo); } \ No newline at end of file diff --git a/src/vnode/tsdb/CMakeLists.txt b/src/vnode/tsdb/CMakeLists.txt index ed924109a7..4e66b98528 100644 --- a/src/vnode/tsdb/CMakeLists.txt +++ b/src/vnode/tsdb/CMakeLists.txt @@ -1,7 +1,7 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) add_library(tsdb STATIC ${SOURCE_LIST}) -target_link_libraries(tsdb common) +target_link_libraries(tsdb common tutil) target_include_directories(tsdb PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" diff --git a/src/vnode/tsdb/inc/tsdbFile.h b/src/vnode/tsdb/inc/tsdbFile.h index 2dda323805..39d1b0b3c2 100644 --- a/src/vnode/tsdb/inc/tsdbFile.h +++ b/src/vnode/tsdb/inc/tsdbFile.h @@ -31,12 +31,13 @@ typedef enum { TSDB_FILE_TYPE_META // .meta file type } TSDB_FILE_TYPE; -const char *tsdbFileSuffix[] = { - ".head", // TSDB_FILE_TYPE_HEAD - ".data", // TSDB_FILE_TYPE_DATA - ".last", // TSDB_FILE_TYPE_LAST - ".meta" // TSDB_FILE_TYPE_META -}; +extern const char *tsdbFileSuffix[]; +// const char *tsdbFileSuffix[] = { +// ".head", // TSDB_FILE_TYPE_HEAD +// ".data", // TSDB_FILE_TYPE_DATA +// ".last", // TSDB_FILE_TYPE_LAST +// ".meta" // TSDB_FILE_TYPE_META +// }; typedef struct { int64_t fileSize; -- GitLab