From 90a13bf45149531043a9ca2ab4dbd536cee61e79 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 10 Apr 2023 14:50:50 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/tsdb/dev/dev.h | 2 - source/dnode/vnode/src/tsdb/dev/tsdbFSet.h | 18 +++++--- source/dnode/vnode/src/tsdb/dev/tsdbFile.c | 34 ++++++++++----- source/dnode/vnode/src/tsdb/dev/tsdbFile.h | 26 ++++------- source/dnode/vnode/src/tsdb/dev/tsdbFileOp.h | 46 -------------------- 5 files changed, 45 insertions(+), 81 deletions(-) delete mode 100644 source/dnode/vnode/src/tsdb/dev/tsdbFileOp.h diff --git a/source/dnode/vnode/src/tsdb/dev/dev.h b/source/dnode/vnode/src/tsdb/dev/dev.h index 88ae1852a3..4dc39874e2 100644 --- a/source/dnode/vnode/src/tsdb/dev/dev.h +++ b/source/dnode/vnode/src/tsdb/dev/dev.h @@ -26,8 +26,6 @@ extern "C" { #include "tsdbFile.h" -#include "tsdbFileOp.h" - #include "tsdbFSet.h" #include "tsdbFS.h" diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFSet.h b/source/dnode/vnode/src/tsdb/dev/tsdbFSet.h index 1ec885ac47..e0b95d795e 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFSet.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFSet.h @@ -22,14 +22,22 @@ extern "C" { #endif -/* Exposed Handle */ -struct SFileSet; - #define TSDB_STT_FILE_LEVEL_MAX 3 -/* Exposed APIs */ +typedef enum { + TSDB_FOP_EXTEND = -2, + TSDB_FOP_CREATE, + TSDB_FOP_NONE, + TSDB_FOP_DELETE, + TSDB_FOP_TRUNCATE, +} tsdb_fop_t; + +struct SFileOp { + tsdb_fop_t op; + struct STFile oFile; // old file state + struct STFile nFile; // new file state +}; -/* Exposed Structs */ struct SFileSet { int32_t fid; int64_t nextid; diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFile.c b/source/dnode/vnode/src/tsdb/dev/tsdbFile.c index 5306d2bcd6..42a1e4a69c 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFile.c @@ -16,12 +16,12 @@ #include "dev.h" const char *tsdb_ftype_suffix[] = { + NULL, // TSDB_FTYPE_NONE ".head", // TSDB_FTYPE_HEAD ".data", // TSDB_FTYPE_DATA ".sma", // TSDB_FTYPE_SMA ".tomb", // TSDB_FTYPE_TOMB - NULL, // TSDB_FTYPE_MAX - ".stt", + ".stt", // TSDB_FTYPE_STT }; int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile) { @@ -29,18 +29,30 @@ int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile) { STfs *pTfs = pVnode->pTfs; if (pTfs) { - snprintf(pFile->fname, TSDB_FILENAME_LEN, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTfs, pFile->diskId), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pVnode), pFile->fid, pFile->cid, tsdb_ftype_suffix[pFile->type]); + snprintf(pFile->fname, // + TSDB_FILENAME_LEN, // + "%s%s%s%sv%df%dver%" PRId64 "%s", // + tfsGetDiskPath(pTfs, pFile->diskId), // + TD_DIRSEP, // + pTsdb->path, // + TD_DIRSEP, // + TD_VID(pVnode), // + pFile->fid, // + pFile->cid, // + tsdb_ftype_suffix[pFile->type]); } else { - snprintf(pFile->fname, TSDB_FILENAME_LEN, "%s%sv%df%dver%" PRId64 "%s", pTsdb->path, TD_DIRSEP, TD_VID(pVnode), - pFile->fid, pFile->cid, tsdb_ftype_suffix[pFile->type]); + snprintf(pFile->fname, // + TSDB_FILENAME_LEN, // + "%s%sv%df%dver%" PRId64 "%s", // + pTsdb->path, // + TD_DIRSEP, // + TD_VID(pVnode), // + pFile->fid, // + pFile->cid, // + tsdb_ftype_suffix[pFile->type]); } pFile->ref = 1; return 0; } -int32_t tsdbTFileClear(struct STFile *pFile) { - int32_t code = 0; - // TODO - return code; -} \ No newline at end of file +int32_t tsdbTFileClear(struct STFile *pFile) { return 0; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFile.h b/source/dnode/vnode/src/tsdb/dev/tsdbFile.h index 400dd460ad..8f76b47a76 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFile.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFile.h @@ -22,37 +22,29 @@ extern "C" { #endif -/* Exposed Handle */ -struct STFile; -struct SFileOp; - typedef enum { - TSDB_FTYPE_HEAD = 0, // .head + TSDB_FTYPE_NONE = 0, // NONE + TSDB_FTYPE_HEAD, // .head TSDB_FTYPE_DATA, // .data TSDB_FTYPE_SMA, // .sma TSDB_FTYPE_TOMB, // .tomb TSDB_FTYPE_STT, // .stt } tsdb_ftype_t; -/* Exposed APIs */ -int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile); -int32_t tsdbTFileClear(struct STFile *pFile); - -/* Exposed Structs */ -struct FStt { - int32_t level; - int32_t nStt; -}; struct STFile { - char fname[TSDB_FILENAME_LEN]; + tsdb_ftype_t type; SDiskID diskId; int64_t size; int64_t cid; int32_t fid; - int32_t ref; - tsdb_ftype_t type; + + int32_t ref; + char fname[TSDB_FILENAME_LEN]; }; +int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile); +int32_t tsdbTFileClear(struct STFile *pFile); + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFileOp.h b/source/dnode/vnode/src/tsdb/dev/tsdbFileOp.h deleted file mode 100644 index 081c0407b6..0000000000 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFileOp.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 _TSDB_FILE_OP_H -#define _TSDB_FILE_OP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exposed Handle */ -typedef enum { - TSDB_FOP_EXTEND = -2, - TSDB_FOP_CREATE, - TSDB_FOP_NONE, - TSDB_FOP_DELETE, - TSDB_FOP_TRUNCATE, -} EFileOpType; - -struct SFileOp { - EFileOpType op; - struct STFile oFile; // old file state - struct STFile nFile; // new file state -}; - -/* Exposed APIs */ - -/* Exposed Structs */ - -#ifdef __cplusplus -} -#endif - -#endif /*_TSDB_FILE_OP_H*/ \ No newline at end of file -- GitLab