tsdbDataFileRW.h 2.7 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 "tsdbUtil.h"
H
Hongze Cheng 已提交
19

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

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

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

H
Hongze Cheng 已提交
31 32 33 34 35 36 37 38 39 40
// SDataFileReader =============================================
typedef struct SDataFileReader SDataFileReader;
typedef struct SDataFileReaderConfig {
  STsdb  *tsdb;
  STFile  f[TSDB_FTYPE_MAX];
  int32_t szPage;
} SDataFileReaderConfig;

int32_t tsdbDataFileReaderOpen(const char *fname[/* TSDB_FTYPE_MAX */], const SDataFileReaderConfig *config,
                               SDataFileReader **reader);
H
Hongze Cheng 已提交
41
int32_t tsdbDataFileReaderClose(SDataFileReader *reader);
H
Hongze Cheng 已提交
42 43 44 45 46
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);
int32_t tsdbDataFileReadDelData(SDataFileReader *reader, const SDelBlk *delBlk, SDelData *dData);
H
Hongze Cheng 已提交
47

H
Hongze Cheng 已提交
48
// SDataFileWriter =============================================
H
Hongze Cheng 已提交
49 50
typedef struct SDataFileWriter SDataFileWriter;
typedef struct SDataFileWriterConfig {
H
Hongze Cheng 已提交
51 52 53
  STsdb    *tsdb;
  bool      hasOldFile;
  STFile    of[TSDB_FTYPE_MAX];
H
Hongze Cheng 已提交
54
  int8_t    cmprAlg;
H
Hongze Cheng 已提交
55 56 57 58 59 60 61 62
  int32_t   maxRow;
  int32_t   szPage;
  int64_t   cid;
  SDiskID   did[1];
  int64_t   compactVersion;
  SSkmInfo *skmTb;
  SSkmInfo *skmRow;
  uint8_t **bufArr;
H
Hongze Cheng 已提交
63
} SDataFileWriterConfig;
H
Hongze Cheng 已提交
64

H
Hongze Cheng 已提交
65
int32_t tsdbDataFileWriterOpen(const SDataFileWriterConfig *config, SDataFileWriter **writer);
H
Hongze Cheng 已提交
66
int32_t tsdbDataFileWriterClose(SDataFileWriter **writer, bool abort, STFileOp op[/*TSDB_FTYPE_MAX*/]);
H
Hongze Cheng 已提交
67
int32_t tsdbDataFileWriteTSData(SDataFileWriter *writer, SRowInfo *row);
H
Hongze Cheng 已提交
68
int32_t tsdbDataFileWriteTSDataBlock(SDataFileWriter *writer, SBlockData *bData);
H
Hongze Cheng 已提交
69
int32_t tsdbDataFileFLushTSDataBlock(SDataFileWriter *writer);
H
Hongze Cheng 已提交
70 71 72 73 74

#ifdef __cplusplus
}
#endif

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