tsdbDataFileRW.h 2.9 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 "tsdbSttFileRW.h"
H
Hongze Cheng 已提交
19
#include "tsdbUtil.h"
H
Hongze Cheng 已提交
20

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

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

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

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

int32_t tsdbDataFileReaderOpen(const char *fname[/* TSDB_FTYPE_MAX */], const SDataFileReaderConfig *config,
                               SDataFileReader **reader);
H
Hongze Cheng 已提交
46
int32_t tsdbDataFileReaderClose(SDataFileReader **reader);
H
Hongze Cheng 已提交
47 48 49
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 已提交
50 51
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray);
int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombBlk, STombBlock *tData);
H
Hongze Cheng 已提交
52

H
Hongze Cheng 已提交
53
// SDataFileWriter =============================================
H
Hongze Cheng 已提交
54 55
typedef struct SDataFileWriter SDataFileWriter;
typedef struct SDataFileWriterConfig {
H
Hongze Cheng 已提交
56 57 58 59 60 61 62 63 64 65 66 67
  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 已提交
68 69 70
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
  uint8_t **bufArr;
H
Hongze Cheng 已提交
71
} SDataFileWriterConfig;
H
Hongze Cheng 已提交
72

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

#ifdef __cplusplus
}
#endif

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