tsdbFile.h 1.8 KB
Newer Older
H
more  
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * 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/>.
 */
H
more  
Hongze Cheng 已提交
15 16 17
#if !defined(_TD_TSDB_FILE_H_)
#define _TD_TSDB_FILE_H_

H
more  
hzcheng 已提交
18
#include <stdint.h>
H
hzcheng 已提交
19 20

#include "taosdef.h"
H
more  
Hongze Cheng 已提交
21

H
more  
hzcheng 已提交
22 23 24 25
#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
26 27 28
typedef enum {
  TSDB_FILE_TYPE_HEAD,  // .head file type
  TSDB_FILE_TYPE_DATA,  // .data file type
H
TD-34  
hzcheng 已提交
29
  TSDB_FILE_TYPE_LAST   // .last file type
H
more  
Hongze Cheng 已提交
30 31
} TSDB_FILE_TYPE;

H
more  
hzcheng 已提交
32
extern const char *tsdbFileSuffix[];
H
Hongze Cheng 已提交
33

H
more  
Hongze Cheng 已提交
34
typedef struct {
H
hzcheng 已提交
35 36
  int64_t size;
  int64_t tombSize;
H
more  
Hongze Cheng 已提交
37 38 39
} SFileInfo;

typedef struct {
H
hzcheng 已提交
40 41 42
  int64_t size;     // total size of the file
  int64_t tombSize; // unused file size
} SFile;
H
more  
Hongze Cheng 已提交
43

H
hzcheng 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
typedef struct {
  int32_t fileId;
  SFile   fhead;
  SFile   fdata;
  SFile   flast;
} SFileGroup;

// TSDB file handle
typedef struct {
  int32_t    daysPerFile;
  int32_t    keep;
  int32_t    minRowPerFBlock;
  int32_t    maxRowsPerFBlock;
  SFileGroup fGroup[];
} STsdbFileH;
H
more  
Hongze Cheng 已提交
59

H
TD-34  
hzcheng 已提交
60
#define IS_VALID_TSDB_FILE_TYPE(type) ((type) >= TSDB_FILE_TYPE_HEAD && (type) <= TSDB_FILE_TYPE_LAST)
H
hzcheng 已提交
61

H
hzcheng 已提交
62 63 64 65
STsdbFileH *tsdbInitFile(char *dataDir, int32_t daysPerFile, int32_t keep, int32_t minRowsPerFBlock,
                         int32_t maxRowsPerFBlock);
void        tsdbCloseFile(STsdbFileH *pFileH);

H
Hongze Cheng 已提交
66
char *tsdbGetFileName(char *dirName, char *fname, TSDB_FILE_TYPE type);
H
more  
Hongze Cheng 已提交
67

H
more  
hzcheng 已提交
68 69 70 71
#ifdef __cplusplus
}
#endif

H
more  
Hongze Cheng 已提交
72
#endif  // _TD_TSDB_FILE_H_