tsdbFS.h 1.6 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_SYSTEM_H
#define _TSDB_FILE_SYSTEM_H

H
Hongze Cheng 已提交
19
#include "tsdbDef.h"
H
Hongze Cheng 已提交
20

H
Hongze Cheng 已提交
21 22 23 24 25
#ifdef __cplusplus
extern "C" {
#endif

/* Exposed Handle */
H
Hongze Cheng 已提交
26
struct STFileSystem {
H
Hongze Cheng 已提交
27 28
  STsdb *pTsdb;
  // int32_t state; // TODO
H
Hongze Cheng 已提交
29 30
  tsem_t  canEdit;
  int64_t nextEditId;
H
Hongze Cheng 已提交
31
  SArray *aFileSet;  // SArray<struct SFileSet>
H
Hongze Cheng 已提交
32
  SArray *nState;    // SArray<struct SFileSet>
H
Hongze Cheng 已提交
33
};
H
Hongze Cheng 已提交
34

H
Hongze Cheng 已提交
35
typedef enum {
H
Hongze Cheng 已提交
36 37
  TSDB_FS_EDIT_NONE = 0,
  TSDB_FS_EDIT_COMMIT,
H
Hongze Cheng 已提交
38
  TSDB_FS_EDIT_MERGE,
H
Hongze Cheng 已提交
39 40
  TSDB_FS_EDIT_MAX,
} tsdb_fs_edit_t;
H
Hongze Cheng 已提交
41

H
Hongze Cheng 已提交
42
/* Exposed APIs */
H
Hongze Cheng 已提交
43
// open/close
H
Hongze Cheng 已提交
44
int32_t tsdbOpenFileSystem(STsdb *pTsdb, struct STFileSystem **ppFS, int8_t rollback);
H
Hongze Cheng 已提交
45
int32_t tsdbCloseFileSystem(struct STFileSystem **ppFS);
H
Hongze Cheng 已提交
46
// txn
H
Hongze Cheng 已提交
47 48 49
int32_t tsdbFileSystemEditBegin(struct STFileSystem *pFS, const SArray *aFileOp, tsdb_fs_edit_t etype);
int32_t tsdbFileSystemEditCommit(struct STFileSystem *pFS, tsdb_fs_edit_t etype);
int32_t tsdbFileSystemEditAbort(struct STFileSystem *pFS, tsdb_fs_edit_t etype);
H
Hongze Cheng 已提交
50 51 52 53 54 55 56

/* Exposed Structs */
#ifdef __cplusplus
}
#endif

#endif /*_TSDB_FILE_SYSTEM_H*/