From 23e78dd908a35a7c7a30ebdf32adf240b6776f4d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Mar 2023 19:12:25 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/tsdb/dev/tsdbCommit.c | 15 +++++++-- source/dnode/vnode/src/tsdb/dev/tsdbFS.c | 6 ++-- source/dnode/vnode/src/tsdb/dev/tsdbFS.h | 2 +- .../dnode/vnode/src/tsdb/dev/tsdbSttFReader.c | 14 ++++++++ .../dnode/vnode/src/tsdb/dev/tsdbSttFReader.h | 33 +++++++++++++++++++ source/dnode/vnode/src/tsdb/tsdbOpen.c | 15 ++++++++- 6 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c create mode 100644 source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c index 083db8d9a7..5b7a083d2b 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c @@ -40,9 +40,20 @@ static int32_t tsdbCommitOpenWriter(SCommitter *pCommitter) { int32_t code; int32_t lino; - SSttFile sttFile = {0}; // TODO + struct SSttFWriterConf conf = { + .pTsdb = pCommitter->pTsdb, + .file = {0}, + .pSkmTb = NULL, + .pSkmRow = NULL, + .maxRow = pCommitter->maxRow, + .szPage = pCommitter->pTsdb->pVnode->config.tsdbPageSize, + .cmprAlg = pCommitter->cmprAlg, + .aBuf = NULL, + }; - code = tsdbSttFWriterOpen(NULL /*TODO*/, &pCommitter->pWriter); + // taosArraySearch(pCommitter->pTsdb); + + code = tsdbSttFWriterOpen(&conf, &pCommitter->pWriter); TSDB_CHECK_CODE(code, lino, _exit); _exit: diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFS.c b/source/dnode/vnode/src/tsdb/dev/tsdbFS.c index e516f36204..6b0d2f69ea 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFS.c @@ -37,7 +37,7 @@ static int32_t destroy_file_system(struct STFileSystem **ppFS) { return 0; } -static int32_t open_file_system(struct STFileSystem *pFS) { +static int32_t open_file_system(struct STFileSystem *pFS, int8_t rollback) { // TODO return 0; } @@ -47,14 +47,14 @@ static int32_t close_file_system(struct STFileSystem *pFS) { return 0; } -int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS) { +int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS, int8_t rollback) { int32_t code; int32_t lino; code = create_file_system(pTsdb, ppFS); TSDB_CHECK_CODE(code, lino, _exit); - code = open_file_system(ppFS[0]); + code = open_file_system(ppFS[0], rollback); TSDB_CHECK_CODE(code, lino, _exit); _exit: diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h index dc1bba69b8..d12b5be33e 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h @@ -26,7 +26,7 @@ extern "C" { struct STFileSystem; /* Exposed APIs */ -int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS); +int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS, int8_t rollback); int32_t tsdbCloseFileSystem(struct STFileSystem **ppFS); /* Exposed Structs */ diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c new file mode 100644 index 0000000000..6dea4a4e57 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h new file mode 100644 index 0000000000..f739659570 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_TSDB_STT_FILE_READER_H +#define _TD_TSDB_STT_FILE_READER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exposed Handle */ + +/* Exposed APIs */ + +/* Exposed Structs */ + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_TSDB_STT_FILE_READER_H*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 8901f64459..21fe9bf471 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -14,6 +14,9 @@ */ #include "tsdb.h" +#ifdef USE_DEV_CODE +#include "dev/dev.h" +#endif int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) { STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg; @@ -65,10 +68,16 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee taosMkDir(pTsdb->path); } - // open tsdb +// open tsdb +#ifdef USE_DEV_CODE + if (tsdbOpenFileSystem(pTsdb, &pTsdb->pFS, rollback) < 0) { + goto _err; + } +#else if (tsdbFSOpen(pTsdb, rollback) < 0) { goto _err; } +#endif if (tsdbOpenCache(pTsdb) < 0) { goto _err; @@ -94,7 +103,11 @@ int tsdbClose(STsdb **pTsdb) { taosThreadRwlockDestroy(&(*pTsdb)->rwLock); +#ifndef USE_DEV_CODE tsdbFSClose(*pTsdb); +#else + tsdbCloseFileSystem(&(*pTsdb)->pFS); +#endif tsdbCloseCache(*pTsdb); taosMemoryFreeClear(*pTsdb); }