TDengine/source/dnode/vnode/src/tsdb/dev/inc/tsdbFile.h

74 lines
1.9 KiB
C
Raw Normal View History

2023-03-23 09:15:51 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
2023-05-08 02:27:55 +00:00
#include "tsdbDef.h"
2023-03-23 09:15:51 +00:00
#ifndef _TSDB_FILE_H
#define _TSDB_FILE_H
#ifdef __cplusplus
extern "C" {
#endif
2023-05-15 09:26:00 +00:00
typedef struct STFile STFile;
typedef struct STFileObj STFileObj;
2023-04-23 07:31:23 +00:00
2023-03-24 09:57:37 +00:00
typedef enum {
2023-05-08 02:53:39 +00:00
TSDB_FTYPE_HEAD = 0, // .head
TSDB_FTYPE_DATA, // .data
TSDB_FTYPE_SMA, // .sma
TSDB_FTYPE_TOMB, // .tomb
TSDB_FTYPE_STT = TSDB_FTYPE_TOMB + 2, // .stt
2023-03-24 09:57:37 +00:00
} tsdb_ftype_t;
2023-03-23 09:15:51 +00:00
2023-05-08 08:16:45 +00:00
#define TSDB_FTYPE_MIN TSDB_FTYPE_HEAD
2023-05-08 02:53:39 +00:00
#define TSDB_FTYPE_MAX (TSDB_FTYPE_TOMB + 1)
2023-05-16 03:39:53 +00:00
// STFile
2023-05-08 08:16:45 +00:00
int32_t tsdbTFileToJson(const STFile *f, cJSON *json);
2023-05-16 03:09:15 +00:00
int32_t tsdbJsonToTFile(const cJSON *json, tsdb_ftype_t ftype, STFile *f);
2023-05-08 02:27:55 +00:00
int32_t tsdbTFileInit(STsdb *pTsdb, STFile *pFile);
int32_t tsdbTFileClear(STFile *pFile);
2023-04-23 07:31:23 +00:00
2023-05-16 03:39:53 +00:00
// STFileObj
int32_t tsdbTFileObjCreate(STFileObj **fobj);
int32_t tsdbTFileObjDestroy(STFileObj *fobj);
2023-03-24 09:57:37 +00:00
struct STFile {
2023-05-15 07:47:06 +00:00
char fname[TSDB_FILENAME_LEN];
2023-04-10 06:50:50 +00:00
tsdb_ftype_t type;
2023-05-15 09:14:45 +00:00
SDiskID did; // disk id
2023-05-11 10:16:55 +00:00
int32_t fid; // file id
int64_t cid; // commit id
2023-05-08 08:16:45 +00:00
int64_t size;
2023-04-23 07:31:23 +00:00
union {
struct {
2023-05-16 07:19:13 +00:00
int32_t level;
2023-05-08 02:53:39 +00:00
int32_t nseg;
2023-04-26 07:35:16 +00:00
} stt;
2023-04-23 07:31:23 +00:00
};
};
2023-04-10 06:50:50 +00:00
2023-05-15 09:14:45 +00:00
struct STFileObj {
2023-05-16 03:39:53 +00:00
SRBTreeNode rbtn;
volatile int32_t ref;
STFile f;
2023-05-15 09:14:45 +00:00
};
2023-03-23 09:15:51 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TSDB_FILE_H*/