tsdbDataFileRW.h 2.6 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
#include "tsdbDef.h"
H
Hongze Cheng 已提交
17
#include "tsdbFSet.h"
H
Hongze Cheng 已提交
18
#include "tsdbUtil.h"
H
Hongze Cheng 已提交
19

H
Hongze Cheng 已提交
20 21
#ifndef _TSDB_DATA_FILE_RW_H
#define _TSDB_DATA_FILE_RW_H
H
Hongze Cheng 已提交
22

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

H
Hongze Cheng 已提交
27 28
typedef TARRAY2(SBlockIdx) TBlockIdxArray;
typedef TARRAY2(SDataBlk) TDataBlkArray;
H
Hongze Cheng 已提交
29
typedef TARRAY2(SColumnDataAgg) TColumnDataAggArray;
H
Hongze Cheng 已提交
30

H
Hongze Cheng 已提交
31 32 33 34 35
// SDataFileReader =============================================
typedef struct SDataFileReader SDataFileReader;
typedef struct SDataFileReaderConfig {
  STsdb  *tsdb;
  int32_t szPage;
H
Hongze Cheng 已提交
36 37 38 39 40
  struct {
    bool   exist;
    STFile file;
  } files[TSDB_FTYPE_MAX];
  uint8_t **bufArr;
H
Hongze Cheng 已提交
41 42 43 44
} SDataFileReaderConfig;

int32_t tsdbDataFileReaderOpen(const char *fname[/* TSDB_FTYPE_MAX */], const SDataFileReaderConfig *config,
                               SDataFileReader **reader);
H
Hongze Cheng 已提交
45
int32_t tsdbDataFileReaderClose(SDataFileReader **reader);
H
Hongze Cheng 已提交
46 47 48
int32_t tsdbDataFileReadBlockIdx(SDataFileReader *reader, const TBlockIdxArray **blockIdxArray);
int32_t tsdbDataFileReadDataBlk(SDataFileReader *reader, const SBlockIdx *blockIdx, const TDataBlkArray **dataBlkArray);
int32_t tsdbDataFileReadDataBlock(SDataFileReader *reader, const SDataBlk *dataBlk, SBlockData *bData);
H
Hongze Cheng 已提交
49

H
Hongze Cheng 已提交
50
// SDataFileWriter =============================================
H
Hongze Cheng 已提交
51 52
typedef struct SDataFileWriter SDataFileWriter;
typedef struct SDataFileWriterConfig {
H
Hongze Cheng 已提交
53 54 55 56 57 58 59 60 61 62 63 64
  STsdb  *tsdb;
  int8_t  cmprAlg;
  int32_t maxRow;
  int32_t szPage;
  int32_t fid;
  int64_t cid;
  SDiskID did;
  int64_t compactVersion;
  struct {
    bool   exist;
    STFile file;
  } files[TSDB_FTYPE_MAX];
H
Hongze Cheng 已提交
65 66 67
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
  uint8_t **bufArr;
H
Hongze Cheng 已提交
68
} SDataFileWriterConfig;
H
Hongze Cheng 已提交
69

H
Hongze Cheng 已提交
70
int32_t tsdbDataFileWriterOpen(const SDataFileWriterConfig *config, SDataFileWriter **writer);
H
Hongze Cheng 已提交
71
int32_t tsdbDataFileWriterClose(SDataFileWriter **writer, bool abort, TFileOpArray *opArr);
H
Hongze Cheng 已提交
72
int32_t tsdbDataFileWriteTSData(SDataFileWriter *writer, SRowInfo *row);
H
Hongze Cheng 已提交
73
int32_t tsdbDataFileWriteTSDataBlock(SDataFileWriter *writer, SBlockData *bData);
H
Hongze Cheng 已提交
74
int32_t tsdbDataFileFlushTSDataBlock(SDataFileWriter *writer);
H
Hongze Cheng 已提交
75 76 77 78 79

#ifdef __cplusplus
}
#endif

H
Hongze Cheng 已提交
80
#endif /*_TSDB_DATA_FILE_RW_H*/