tsdbFile.h 1.8 KB
Newer Older
H
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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_H
#define _TSDB_FILE_H

H
Hongze Cheng 已提交
19
#include "tsdbDef.h"
H
Hongze Cheng 已提交
20 21 22 23 24

#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
25 26
typedef struct STFile STFile;

H
Hongze Cheng 已提交
27
typedef enum {
H
Hongze Cheng 已提交
28
  TSDB_FTYPE_HEAD = 0,  // .head
H
Hongze Cheng 已提交
29 30 31
  TSDB_FTYPE_DATA,      // .data
  TSDB_FTYPE_SMA,       // .sma
  TSDB_FTYPE_TOMB,      // .tomb
H
Hongze Cheng 已提交
32
  TSDB_FTYPE_MAX,       // max
H
Hongze Cheng 已提交
33
  TSDB_FTYPE_STT,       // .stt
H
Hongze Cheng 已提交
34
} tsdb_ftype_t;
H
Hongze Cheng 已提交
35

H
Hongze Cheng 已提交
36 37 38 39 40
int32_t tsdbTFileCreate(const struct STFile *config, struct STFile **ppFile);
int32_t tsdbTFileDestroy(struct STFile *pFile);
int32_t tsdbTFileInit(STsdb *pTsdb, struct STFile *pFile);
int32_t tsdbTFileClear(struct STFile *pFile);

H
Hongze Cheng 已提交
41
struct STFile {
H
Hongze Cheng 已提交
42 43
  char         fname[TSDB_FILENAME_LEN];
  int32_t      ref;
H
Hongze Cheng 已提交
44
  int32_t      state;
H
Hongze Cheng 已提交
45
  tsdb_ftype_t type;
H
Hongze Cheng 已提交
46
  SDiskID      did;
H
Hongze Cheng 已提交
47 48 49
  int64_t      size;
  int64_t      cid;
  int32_t      fid;
H
Hongze Cheng 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  union {
    struct {
      int32_t level;  // level of .stt
      int32_t nSeg;   // number of segments in .stt
    } stt;
    struct {
      // TODO
    } head;
    struct {
      // TODO
    } data;
    struct {
      // TODO
    } sma;
    struct {
      // TODO
    } tomb;
  };
H
Hongze Cheng 已提交
68

H
Hongze Cheng 已提交
69 70
  LISTD(struct STFile) listNode;
};
H
Hongze Cheng 已提交
71

H
Hongze Cheng 已提交
72 73 74 75 76
#ifdef __cplusplus
}
#endif

#endif /*_TSDB_FILE_H*/