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 18
#include "tsdbFS.h"
#include "tsdbUtil.h"

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 28
typedef TARRAY2(SDelBlk) TDelBlkArray;
typedef TARRAY2(STbStatisBlk) TStatisBlkArray;
H
Hongze Cheng 已提交
29

H
Hongze Cheng 已提交
30
// SSttFileReader ==========================================
H
Hongze Cheng 已提交
31 32
typedef struct SSttFileReader       SSttFileReader;
typedef struct SSttFileReaderConfig SSttFileReaderConfig;
H
Hongze Cheng 已提交
33
typedef struct SSttSegReader        SSttSegReader;
H
Hongze Cheng 已提交
34
typedef TARRAY2(SSttFileReader *) TSttFileReaderArray;
H
Hongze Cheng 已提交
35
typedef TARRAY2(SSttSegReader *) TSttSegReaderArray;
H
Hongze Cheng 已提交
36

H
Hongze Cheng 已提交
37
// SSttFileReader
H
Hongze Cheng 已提交
38
int32_t tsdbSttFReaderOpen(const char *fname, const SSttFileReaderConfig *config, SSttFileReader **reader);
H
Hongze Cheng 已提交
39
int32_t tsdbSttFReaderClose(SSttFileReader **reader);
H
Hongze Cheng 已提交
40
int32_t tsdbSttFReaderGetSegReader(SSttFileReader *reader, const TSttSegReaderArray **readerArray);
H
Hongze Cheng 已提交
41 42 43 44 45 46 47 48 49

// SSttSegReader
int32_t tsdbSttFReadSttBlk(SSttSegReader *reader, const TSttBlkArray **sttBlkArray);
int32_t tsdbSttFReadDelBlk(SSttSegReader *reader, const TDelBlkArray **delBlkArray);
int32_t tsdbSttFReadStatisBlk(SSttSegReader *reader, const TStatisBlkArray **statisBlkArray);

int32_t tsdbSttFReadSttBlock(SSttSegReader *reader, const SSttBlk *sttBlk, SBlockData *bData);
int32_t tsdbSttFReadDelBlock(SSttSegReader *reader, const SDelBlk *delBlk, SDelBlock *dData);
int32_t tsdbSttFReadStatisBlock(SSttSegReader *reader, const STbStatisBlk *statisBlk, STbStatisBlock *sData);
H
Hongze Cheng 已提交
50

H
Hongze Cheng 已提交
51
struct SSttFileReaderConfig {
H
Hongze Cheng 已提交
52
  STsdb    *tsdb;
H
Hongze Cheng 已提交
53 54
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
H
Hongze Cheng 已提交
55
  uint8_t **aBuf;
H
Hongze Cheng 已提交
56
  int32_t   szPage;
H
Hongze Cheng 已提交
57
  STFile    file[1];
H
Hongze Cheng 已提交
58 59
};

H
Hongze Cheng 已提交
60
// SSttFileWriter ==========================================
H
Hongze Cheng 已提交
61 62
typedef struct SSttFileWriter       SSttFileWriter;
typedef struct SSttFileWriterConfig SSttFileWriterConfig;
H
Hongze Cheng 已提交
63

H
Hongze Cheng 已提交
64 65 66 67 68
int32_t tsdbSttFileWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **writer);
int32_t tsdbSttFileWriterClose(SSttFileWriter **writer, int8_t abort, STFileOp *op);
int32_t tsdbSttFileWriteTSData(SSttFileWriter *writer, SRowInfo *row);
int32_t tsdbSttFileWriteTSDataBlock(SSttFileWriter *writer, SBlockData *pBlockData);
int32_t tsdbSttFileWriteDLData(SSttFileWriter *writer, TABLEID *tbid, SDelData *pDelData);
H
Hongze Cheng 已提交
69

H
Hongze Cheng 已提交
70
struct SSttFileWriterConfig {
H
Hongze Cheng 已提交
71
  STsdb    *tsdb;
H
Hongze Cheng 已提交
72 73 74
  int32_t   maxRow;
  int32_t   szPage;
  int8_t    cmprAlg;
H
Hongze Cheng 已提交
75
  int64_t   compactVersion;  // compact version
H
Hongze Cheng 已提交
76 77
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
H
Hongze Cheng 已提交
78
  uint8_t **aBuf;
H
Hongze Cheng 已提交
79
  STFile    file;
H
Hongze Cheng 已提交
80 81 82 83 84 85
};

#ifdef __cplusplus
}
#endif

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