more code
This commit is contained in:
parent
fe4dca9b1e
commit
90a13bf451
|
@ -26,8 +26,6 @@ extern "C" {
|
|||
|
||||
#include "tsdbFile.h"
|
||||
|
||||
#include "tsdbFileOp.h"
|
||||
|
||||
#include "tsdbFSet.h"
|
||||
|
||||
#include "tsdbFS.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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
int32_t tsdbTFileClear(struct STFile *pFile) { return 0; }
|
|
@ -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;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
};
|
||||
|
||||
int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile);
|
||||
int32_t tsdbTFileClear(struct STFile *pFile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#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*/
|
Loading…
Reference in New Issue