tsdbDataFileRW.h 3.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 "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 50 51
// .head
int32_t tsdbDataFileReadBrinBlk(SDataFileReader *reader, const TBrinBlkArray **brinBlkArray);
int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinBlk, SBrinBlock *brinBlock);
// .data
int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData);
H
Hongze Cheng 已提交
52 53
int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData,
                                          STSchema *pTSchema, int16_t cids[], int32_t ncid);
H
Hongze Cheng 已提交
54
// .sma
H
Hongze Cheng 已提交
55 56
int32_t tsdbDataFileReadBlockSma(SDataFileReader *reader, const SBrinRecord *record,
                                 TColumnDataAggArray *columnDataAggArray);
H
Hongze Cheng 已提交
57 58 59 60
// .tomb
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray);
int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombBlk, STombBlock *tData);

H
Hongze Cheng 已提交
61
#if 0
H
Hongze Cheng 已提交
62 63 64
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 已提交
65
#endif
H
Hongze Cheng 已提交
66

H
Hongze Cheng 已提交
67
// SDataFileWriter =============================================
H
Hongze Cheng 已提交
68 69
typedef struct SDataFileWriter SDataFileWriter;
typedef struct SDataFileWriterConfig {
H
Hongze Cheng 已提交
70 71 72 73 74 75 76 77 78 79 80 81
  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 已提交
82 83 84
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
  uint8_t **bufArr;
H
Hongze Cheng 已提交
85
} SDataFileWriterConfig;
H
Hongze Cheng 已提交
86

H
Hongze Cheng 已提交
87
int32_t tsdbDataFileWriterOpen(const SDataFileWriterConfig *config, SDataFileWriter **writer);
H
Hongze Cheng 已提交
88
int32_t tsdbDataFileWriterClose(SDataFileWriter **writer, bool abort, TFileOpArray *opArr);
H
Hongze Cheng 已提交
89

H
Hongze Cheng 已提交
90 91 92
int32_t tsdbDataFileWriteRow(SDataFileWriter *writer, SRowInfo *row);
int32_t tsdbDataFileWriteBlockData(SDataFileWriter *writer, SBlockData *bData);
int32_t tsdbDataFileFlush(SDataFileWriter *writer);
H
Hongze Cheng 已提交
93

H
Hongze Cheng 已提交
94
int32_t tsdbDataFileWriteTombRecord(SDataFileWriter *writer, const STombRecord *record);
H
Hongze Cheng 已提交
95 96 97 98 99

#ifdef __cplusplus
}
#endif

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