tsdbSttFileRW.h 3.1 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 "tsdbFS2.h"
#include "tsdbUtil2.h"
H
Hongze Cheng 已提交
18

H
Hongze Cheng 已提交
19 20
#ifndef _TSDB_STT_FILE_RW_H
#define _TSDB_STT_FILE_RW_H
H
Hongze Cheng 已提交
21 22 23 24 25

#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
26
typedef TARRAY2(SSttBlk) TSttBlkArray;
H
Hongze Cheng 已提交
27
typedef TARRAY2(SStatisBlk) TStatisBlkArray;
H
Hongze Cheng 已提交
28

H
Hongze Cheng 已提交
29
// SSttFileReader ==========================================
H
Hongze Cheng 已提交
30 31
typedef struct SSttFileReader       SSttFileReader;
typedef struct SSttFileReaderConfig SSttFileReaderConfig;
H
Hongze Cheng 已提交
32
typedef TARRAY2(SSttFileReader *) TSttFileReaderArray;
H
Hongze Cheng 已提交
33

H
Hongze Cheng 已提交
34
// SSttFileReader
H
Hongze Cheng 已提交
35 36
int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *config, SSttFileReader **reader);
int32_t tsdbSttFileReaderClose(SSttFileReader **reader);
H
Hongze Cheng 已提交
37 38

// SSttSegReader
39 40 41
int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray);
int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray **statisBlkArray);
int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **delBlkArray);
H
Hongze Cheng 已提交
42

43 44
int32_t tsdbSttFileReadBlockData(SSttFileReader *reader, const SSttBlk *sttBlk, SBlockData *bData);
int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *sttBlk, SBlockData *bData,
H
Hongze Cheng 已提交
45
                                         STSchema *pTSchema, int16_t cids[], int32_t ncid);
46 47
int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *statisBlk, STbStatisBlock *sData);
int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *delBlk, STombBlock *dData);
H
Hongze Cheng 已提交
48

H
Hongze Cheng 已提交
49
struct SSttFileReaderConfig {
H
Hongze Cheng 已提交
50
  STsdb    *tsdb;
H
Hongze Cheng 已提交
51 52
  int32_t   szPage;
  STFile    file[1];
H
Hongze Cheng 已提交
53
  uint8_t **bufArr;
H
Hongze Cheng 已提交
54 55
};

H
Hongze Cheng 已提交
56
// SSttFileWriter ==========================================
H
Hongze Cheng 已提交
57 58
typedef struct SSttFileWriter       SSttFileWriter;
typedef struct SSttFileWriterConfig SSttFileWriterConfig;
H
Hongze Cheng 已提交
59

H
Hongze Cheng 已提交
60
int32_t tsdbSttFileWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **writer);
H
Hongze Cheng 已提交
61
int32_t tsdbSttFileWriterClose(SSttFileWriter **writer, int8_t abort, TFileOpArray *opArray);
H
Hongze Cheng 已提交
62 63
int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row);
int32_t tsdbSttFileWriteBlockData(SSttFileWriter *writer, SBlockData *pBlockData);
H
Hongze Cheng 已提交
64
int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *record);
H
Hongze Cheng 已提交
65
bool    tsdbSttFileWriterIsOpened(SSttFileWriter *writer);
H
Hongze Cheng 已提交
66

H
Hongze Cheng 已提交
67
struct SSttFileWriterConfig {
H
Hongze Cheng 已提交
68
  STsdb    *tsdb;
H
Hongze Cheng 已提交
69 70 71
  int32_t   maxRow;
  int32_t   szPage;
  int8_t    cmprAlg;
H
Hongze Cheng 已提交
72
  int64_t   compactVersion;
H
Hongze Cheng 已提交
73 74 75 76
  SDiskID   did;
  int32_t   fid;
  int64_t   cid;
  int32_t   level;
H
Hongze Cheng 已提交
77 78
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
H
Hongze Cheng 已提交
79
  uint8_t **bufArr;
H
Hongze Cheng 已提交
80 81 82 83 84 85
};

#ifdef __cplusplus
}
#endif

H
Hongze Cheng 已提交
86
#endif /*_TSDB_STT_FILE_RW_H*/