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

H
Hongze Cheng 已提交
18 19 20 21 22 23 24
#ifndef _TSDB_FILE_SET_H
#define _TSDB_FILE_SET_H

#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
25
typedef struct STFileSet STFileSet;
H
Hongze Cheng 已提交
26
typedef struct STFileOp  STFileOp;
H
Hongze Cheng 已提交
27
typedef struct SSttLvl   SSttLvl;
H
Hongze Cheng 已提交
28
typedef TARRAY2(STFileObj *) TFileObjArray;
H
Hongze Cheng 已提交
29
typedef TARRAY2(SSttLvl *) TSttLvlArray;
H
Hongze Cheng 已提交
30
typedef TARRAY2(STFileOp) TFileOpArray;
H
Hongze Cheng 已提交
31

H
Hongze Cheng 已提交
32
// init/clear
H
Hongze Cheng 已提交
33
int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset);
H
Hongze Cheng 已提交
34
int32_t tsdbTFileSetInitEx(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
H
Hongze Cheng 已提交
35
int32_t tsdbTFileSetClear(STFileSet **fset);
H
Hongze Cheng 已提交
36
int32_t tsdbTFileSetRemove(STFileSet **fset);
H
Hongze Cheng 已提交
37
// to/from json
H
Hongze Cheng 已提交
38
int32_t tsdbTFileSetToJson(const STFileSet *fset, cJSON *json);
H
Hongze Cheng 已提交
39 40
int32_t tsdbJsonToTFileSet(STsdb *pTsdb, const cJSON *json, STFileSet **fset);
// cmpr
H
Hongze Cheng 已提交
41
int32_t tsdbTFileSetCmprFn(const STFileSet **fset1, const STFileSet **fset2);
H
Hongze Cheng 已提交
42
// edit
H
Hongze Cheng 已提交
43
int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op);
H
Hongze Cheng 已提交
44
int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *fset);
H
Hongze Cheng 已提交
45 46
// max commit id
int64_t tsdbTFileSetMaxCid(const STFileSet *fset);
H
Hongze Cheng 已提交
47
// get
H
Hongze Cheng 已提交
48
SSttLvl *tsdbTFileSetGetLvl(STFileSet *fset, int32_t level);
H
Hongze Cheng 已提交
49 50
// is empty
bool tsdbTFileSetIsEmpty(const STFileSet *fset);
H
Hongze Cheng 已提交
51

H
Hongze Cheng 已提交
52
struct STFileOp {
H
Hongze Cheng 已提交
53 54 55 56
  int32_t fid;
  STFile *of;  // old file
  STFile *nf;  // new file
  STFile  fArr[2];
H
Hongze Cheng 已提交
57
};
H
Hongze Cheng 已提交
58

H
Hongze Cheng 已提交
59
struct SSttLvl {
H
Hongze Cheng 已提交
60 61
  int32_t       level;
  TFileObjArray farr;
H
Hongze Cheng 已提交
62
};
H
Hongze Cheng 已提交
63

H
Hongze Cheng 已提交
64
struct STFileSet {
H
Hongze Cheng 已提交
65 66 67
  int32_t      fid;
  STFileObj   *farr[TSDB_FTYPE_MAX];  // file array
  TSttLvlArray lvlArr;                // level array
H
Hongze Cheng 已提交
68
};
H
Hongze Cheng 已提交
69 70 71 72 73 74

#ifdef __cplusplus
}
#endif

#endif /*_TSDB_FILE_SET_H*/