From fd16a6b3b7d8da26b74a5bee998a291cb1e5e4ce Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 6 Apr 2023 14:27:18 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/tsdb/dev/tsdbCommit.c | 104 ++++++++++-------- source/dnode/vnode/src/tsdb/dev/tsdbFS.h | 3 + .../dnode/vnode/src/tsdb/dev/tsdbSttFReader.c | 16 ++- .../dnode/vnode/src/tsdb/dev/tsdbSttFReader.h | 9 ++ 4 files changed, 84 insertions(+), 48 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c index a3d6fc2faf..db78db2e28 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c @@ -262,6 +262,11 @@ static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCom code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); } + pCommitter->aFileOp = taosArrayInit(10, sizeof(struct SFileOp)); + if (pCommitter->aFileOp == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } // start loop pCommitter->nextKey = pTsdb->imem->minKey; // TODO @@ -277,7 +282,12 @@ _exit: static int32_t close_committer(SCommitter *pCommiter, int32_t eno) { int32_t code = 0; - // TODO + int32_t lino; + + // code = tsdbFSBegin(pCommiter->pTsdb, pCommiter->aFileOp); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: return code; } @@ -327,49 +337,49 @@ _exit: return code; } -int32_t tsdbCommitCommit(STsdb *pTsdb) { - int32_t code = 0; - int32_t lino = 0; - SMemTable *pMemTable = pTsdb->imem; - - // lock - taosThreadRwlockWrlock(&pTsdb->rwLock); - - code = tsdbFSCommit(pTsdb); - if (code) { - taosThreadRwlockUnlock(&pTsdb->rwLock); - TSDB_CHECK_CODE(code, lino, _exit); - } - - pTsdb->imem = NULL; - - // unlock - taosThreadRwlockUnlock(&pTsdb->rwLock); - if (pMemTable) { - tsdbUnrefMemTable(pMemTable, NULL, true); - } - -_exit: - if (code) { - tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); - } else { - tsdbInfo("vgId:%d, tsdb finish commit", TD_VID(pTsdb->pVnode)); - } - return code; -} - -int32_t tsdbCommitAbort(STsdb *pTsdb) { - int32_t code = 0; - int32_t lino = 0; - - code = tsdbFSRollback(pTsdb); - TSDB_CHECK_CODE(code, lino, _exit); - -_exit: - if (code) { - tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); - } else { - tsdbInfo("vgId:%d, tsdb rollback commit", TD_VID(pTsdb->pVnode)); - } - return code; -} \ No newline at end of file +// int32_t tsdbCommitCommit(STsdb *pTsdb) { +// int32_t code = 0; +// int32_t lino = 0; +// SMemTable *pMemTable = pTsdb->imem; + +// // lock +// taosThreadRwlockWrlock(&pTsdb->rwLock); + +// code = tsdbFSCommit(pTsdb); +// if (code) { +// taosThreadRwlockUnlock(&pTsdb->rwLock); +// TSDB_CHECK_CODE(code, lino, _exit); +// } + +// pTsdb->imem = NULL; + +// // unlock +// taosThreadRwlockUnlock(&pTsdb->rwLock); +// if (pMemTable) { +// tsdbUnrefMemTable(pMemTable, NULL, true); +// } + +// _exit: +// if (code) { +// tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); +// } else { +// tsdbInfo("vgId:%d, tsdb finish commit", TD_VID(pTsdb->pVnode)); +// } +// return code; +// } + +// int32_t tsdbCommitAbort(STsdb *pTsdb) { +// int32_t code = 0; +// int32_t lino = 0; + +// code = tsdbFSRollback(pTsdb); +// TSDB_CHECK_CODE(code, lino, _exit); + +// _exit: +// if (code) { +// tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); +// } else { +// tsdbInfo("vgId:%d, tsdb rollback commit", TD_VID(pTsdb->pVnode)); +// } +// return code; +// } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h index eb9dcc6dab..eeac3a1404 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h @@ -26,8 +26,11 @@ extern "C" { struct STFileSystem; /* Exposed APIs */ +// open/close int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS, int8_t rollback); int32_t tsdbCloseFileSystem(struct STFileSystem **ppFS); +// txn +// int32_t tsdb /* Exposed Structs */ struct STFileSystem { diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c index 6dea4a4e57..ab07f48dfd 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.c @@ -11,4 +11,18 @@ * * 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 + */ + +#include "tsdbSttFReader.h" + +int32_t tsdbSttFReaderOpen(const struct SSttFReaderConf *pConf, struct SSttFReader **ppReader) { + int32_t code = 0; + // TODO + return code; +} + +int32_t tsdbSttFReaderClose(struct SSttFReader *pReader) { + int32_t code = 0; + // TODO + return code; +} diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h index f739659570..bda94a96a3 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbSttFReader.h @@ -16,15 +16,24 @@ #ifndef _TD_TSDB_STT_FILE_READER_H #define _TD_TSDB_STT_FILE_READER_H +#include "tsdb.h" + #ifdef __cplusplus extern "C" { #endif /* Exposed Handle */ +struct SSttFReader; +struct SSttFReaderConf; /* Exposed APIs */ +int32_t tsdbSttFReaderOpen(const struct SSttFReaderConf *pConf, struct SSttFReader **ppReader); +int32_t tsdbSttFReaderClose(struct SSttFReader *pReader); /* Exposed Structs */ +struct SSttFReaderConf { + // TODO +}; #ifdef __cplusplus } -- GitLab