tsdbDataFileRW.h 3.5 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 52 53 54 55 56 57 58 59
// .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);
int32_t tsdbDataFileReadBlockDataByCol(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData,
                                       STSchema *pTSchema, int32_t cidArr[], int32_t numCid);
// .sma
int32_t tsdbDataFileReadBlockSma(SDataFileReader *reader);
// .tomb
int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **tombBlkArray);
int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombBlk, STombBlock *tData);

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

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

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

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

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

#ifdef __cplusplus
}
#endif

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