tsdb.h 13.4 KB
Newer Older
L
Liu Jicong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * 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 已提交
15 16 17 18

#ifndef _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_

H
Hongze Cheng 已提交
19 20
#include "vnodeInt.h"

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

H
Hongze Cheng 已提交
25 26 27 28 29 30 31 32 33
// tsdbDebug ================
// clang-format off
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}     while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}     while(0)
#define tsdbWarn(...)  do { if (tsdbDebugFlag & DEBUG_WARN)  { taosPrintLog("TSDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}       while(0)
#define tsdbInfo(...)  do { if (tsdbDebugFlag & DEBUG_INFO)  { taosPrintLog("TSDB ", DEBUG_INFO, 255, __VA_ARGS__); }}            while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
H
Hongze Cheng 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
typedef struct TSDBROW       TSDBROW;
typedef struct TSDBKEY       TSDBKEY;
typedef struct TABLEID       TABLEID;
typedef struct SDelOp        SDelOp;
typedef struct SDelDataItem  SDelDataItem;
typedef struct SDelData      SDelData;
typedef struct SDelIdxItem   SDelIdxItem;
typedef struct SDelIdx       SDelIdx;
typedef struct STbData       STbData;
typedef struct SMemTable     SMemTable;
typedef struct STbDataIter   STbDataIter;
typedef struct SMergeInfo    SMergeInfo;
typedef struct STable        STable;
typedef struct SOffset       SOffset;
typedef struct SMapData      SMapData;
typedef struct SColData      SColData;
typedef struct SColDataBlock SColDataBlock;
H
Hongze Cheng 已提交
51
typedef struct SBlockSMA     SBlockSMA;
H
Hongze Cheng 已提交
52

H
Hongze Cheng 已提交
53 54 55 56 57 58 59 60 61 62
// tsdbMemTable ==============================================================================================

// SMemTable
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
void    tsdbMemTableDestroy(SMemTable *pMemTable);
void    tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);

// STbDataIter
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
void   *tsdbTbDataIterDestroy(STbDataIter *pIter);
H
Hongze Cheng 已提交
63
bool    tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter);
H
Hongze Cheng 已提交
64 65 66
bool    tsdbTbDataIterNext(STbDataIter *pIter);
bool    tsdbTbDataIterGet(STbDataIter *pIter, TSDBROW *pRow);

H
refact  
Hongze Cheng 已提交
67
// tsdbFile.c ==============================================================================================
H
Hongze Cheng 已提交
68 69 70 71 72 73 74 75
typedef struct SDelFile       SDelFile;
typedef struct STsdbCacheFile STsdbCacheFile;
typedef struct STsdbIndexFile STsdbIndexFile;
typedef struct STsdbDataFile  STsdbDataFile;
typedef struct STsdbLastFile  STsdbLastFile;
typedef struct STsdbSmaFile   STsdbSmaFile;
typedef struct STsdbSmalFile  STsdbSmalFile;
typedef struct SDFileSet      SDFileSet;
H
Hongze Cheng 已提交
76 77

// tsdbFS.c ==============================================================================================
H
Hongze Cheng 已提交
78 79 80 81 82 83 84
typedef struct STsdbFS STsdbFS;

int32_t tsdbFSOpen(STsdb *pTsdb, STsdbFS **ppFS);
int32_t tsdbFSClose(STsdbFS *pFS);
int32_t tsdbFSStart(STsdbFS *pFS);
int32_t tsdbFSEnd(STsdbFS *pFS, int8_t rollback);

H
Hongze Cheng 已提交
85 86
// tsdbReaderWriter.c ==============================================================================================

H
Hongze Cheng 已提交
87 88 89
// SDataFWriter
typedef struct SDataFWriter SDataFWriter;

H
Hongze Cheng 已提交
90 91 92 93 94 95 96 97
int32_t tsdbDataFWriterOpen(SDataFWriter *pWriter, STsdb *pTsdb, SDFileSet *pSet);
int32_t tsdbDataFWriterClose(SDataFWriter *pWriter);
int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SMapData *pMapData, uint8_t **ppBuf);
int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *pMapData, uint8_t **ppBuf, int64_t *rOffset, int64_t *rSize);
int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SColDataBlock *pBlockData, uint8_t **ppBuf, int64_t *rOffset,
                           int64_t *rSize);
int32_t tsdbWriteBlockSMA(SDataFWriter *pWriter, SBlockSMA *pBlockSMA, int64_t *rOffset, int64_t *rSize);

H
Hongze Cheng 已提交
98 99 100
// SDataFReader
typedef struct SDataFReader SDataFReader;

H
Hongze Cheng 已提交
101 102 103 104 105 106 107
int32_t tsdbDataFReaderOpen(SDataFReader *pReader, STsdb *pTsdb, SDFileSet *pSet);
int32_t tsdbDataFReaderClose(SDataFReader *pReader);
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SMapData *pMapData, uint8_t **ppBuf);
int32_t tsdbReadBlock(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *pMapData, uint8_t **ppBuf);
int32_t tsdbReadBlockData(SDataFReader *pReader, SBlock *pBlock, SColDataBlock *pBlockData, uint8_t **ppBuf);
int32_t tsdbReadBlockSMA(SDataFReader *pReader, SBlockSMA *pBlkSMA);

H
Hongze Cheng 已提交
108 109 110
// SDelFWriter
typedef struct SDelFWriter SDelFWriter;

H
Hongze Cheng 已提交
111
int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb);
H
Hongze Cheng 已提交
112
int32_t tsdbDelFWriterClose(SDelFWriter *pWriter, int8_t sync);
H
Hongze Cheng 已提交
113
int32_t tsdbWriteDelData(SDelFWriter *pWriter, SDelData *pDelData, uint8_t **ppBuf, int64_t *rOffset, int64_t *rSize);
H
Hongze Cheng 已提交
114
int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SDelIdx *pDelIdx, uint8_t **ppBuf);
H
Hongze Cheng 已提交
115
int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter, uint8_t **ppBuf);
H
Hongze Cheng 已提交
116 117 118 119

// SDelFReader
typedef struct SDelFReader SDelFReader;

H
Hongze Cheng 已提交
120
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb, uint8_t **ppBuf);
H
Hongze Cheng 已提交
121
int32_t tsdbDelFReaderClose(SDelFReader *pReader);
H
Hongze Cheng 已提交
122
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdxItem *pItem, SDelData *pDelData, uint8_t **ppBuf);
H
Hongze Cheng 已提交
123
int32_t tsdbReadDelIdx(SDelFReader *pReader, SDelIdx *pDelIdx, uint8_t **ppBuf);
H
Hongze Cheng 已提交
124

H
Hongze Cheng 已提交
125 126 127 128 129 130
// SCacheFWriter
typedef struct SCacheFWriter SCacheFWriter;

// SCacheFReader
typedef struct SCacheFReader SCacheFReader;

H
Hongze Cheng 已提交
131 132
// tsdbCommit.c ==============================================================================================

H
refact  
Hongze Cheng 已提交
133
// tsdbReadImpl.c ==============================================================================================
H
Hongze Cheng 已提交
134 135 136 137 138 139 140 141 142
typedef struct SBlockIdxItem SBlockIdxItem;
typedef struct SBlockIdx     SBlockIdx;
typedef struct SBlockInfo    SBlockInfo;
typedef struct SBlock        SBlock;
typedef struct SBlockCol     SBlockCol;
typedef struct SBlockStatis  SBlockStatis;
typedef struct SAggrBlkCol   SAggrBlkCol;
typedef struct SBlockData    SBlockData;
typedef struct SReadH        SReadH;
H
refact  
Hongze Cheng 已提交
143

H
Hongze Cheng 已提交
144
// tsdbUtil.c ==============================================================================================
H
Hongze Cheng 已提交
145
int32_t tsdbKeyFid(TSKEY key, int32_t minutes, int8_t precision);
H
Hongze Cheng 已提交
146
void    tsdbFidKeyRange(int32_t fid, int32_t minutes, int8_t precision, TSKEY *minKey, TSKEY *maxKey);
H
Hongze Cheng 已提交
147

H
Hongze Cheng 已提交
148 149 150
int32_t tsdbRealloc(uint8_t **ppBuf, int64_t size);
void    tsdbFree(uint8_t *pBuf);

H
Hongze Cheng 已提交
151 152 153
int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
int32_t tsdbKeyCmprFn(const void *p1, const void *p2);

H
Hongze Cheng 已提交
154
// SMapData
H
Hongze Cheng 已提交
155 156
void    tMapDataReset(SMapData *pMapData);
void    tMapDataClear(SMapData *pMapData);
H
Hongze Cheng 已提交
157 158 159 160 161
int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *));
int32_t tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *));
int32_t tPutMapData(uint8_t *p, SMapData *pMapData);
int32_t tGetMapData(uint8_t *p, SMapData *pMapData);

H
Hongze Cheng 已提交
162 163 164 165 166 167 168 169 170
// SBlockIdx
int32_t tBlockIdxClear(SBlockIdx *pBlockIdx);
int32_t tBlockIdxPutItem(SBlockIdx *pBlockIdx, SBlockIdxItem *pItem);
int32_t tBlockIdxGetItemByIdx(SBlockIdx *pBlockIdx, SBlockIdxItem *pItem, int32_t idx);
int32_t tBlockIdxGetItem(SBlockIdx *pBlockIdx, SBlockIdxItem *pItem, TABLEID id);
int32_t tPutBlockIdx(uint8_t *p, SBlockIdx *pBlockIdx);
int32_t tGetBlockIdx(uint8_t *p, SBlockIdx *pBlockIdx);

// SBlock
H
Hongze Cheng 已提交
171
int32_t tBlockCmprFn(const void *p1, const void *p2);
H
Hongze Cheng 已提交
172

H
Hongze Cheng 已提交
173
// SDelIdx
H
more  
Hongze Cheng 已提交
174
int32_t tDelIdxClear(SDelIdx *pDelIdx);
H
Hongze Cheng 已提交
175
int32_t tDelIdxPutItem(SDelIdx *pDelIdx, SDelIdxItem *pItem);
H
Hongze Cheng 已提交
176 177
int32_t tDelIdxGetItemByIdx(SDelIdx *pDelIdx, SDelIdxItem *pItem, int32_t idx);
int32_t tDelIdxGetItem(SDelIdx *pDelIdx, SDelIdxItem *pItem, TABLEID id);
H
Hongze Cheng 已提交
178 179 180
int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx);
int32_t tGetDelIdx(uint8_t *p, SDelIdx *pDelIdx);

H
Hongze Cheng 已提交
181
// SDelData
H
Hongze Cheng 已提交
182
int32_t tDelDataClear(SDelData *pDelData);
H
Hongze Cheng 已提交
183
int32_t tDelDataPutItem(SDelData *pDelData, SDelDataItem *pItem);
H
Hongze Cheng 已提交
184 185
int32_t tDelDataGetItemByIdx(SDelData *pDelData, SDelDataItem *pItem, int32_t idx);
int32_t tDelDataGetItem(SDelData *pDelData, SDelDataItem *pItem, int64_t version);
H
Hongze Cheng 已提交
186 187 188
int32_t tPutDelData(uint8_t *p, SDelData *pDelData);
int32_t tGetDelData(uint8_t *p, SDelData *pDelData);

H
Hongze Cheng 已提交
189 190
int32_t tPutDelFileHdr(uint8_t *p, SDelFile *pDelFile);
int32_t tGetDelFileHdr(uint8_t *p, SDelFile *pDelFile);
H
Hongze Cheng 已提交
191

H
Hongze Cheng 已提交
192
// structs
H
Hongze Cheng 已提交
193 194 195 196 197 198
struct SOffset {
  int32_t  nOffset;
  uint8_t  flag;
  uint8_t *pOffset;
};

H
Hongze Cheng 已提交
199 200 201 202 203 204 205
typedef struct {
  int   minFid;
  int   midFid;
  int   maxFid;
  TSKEY minKey;
} SRtn;

C
Cary Xu 已提交
206
#define TSDB_DATA_DIR_LEN 6  // adapt accordingly
H
Hongze Cheng 已提交
207
struct STsdb {
H
refact  
Hongze Cheng 已提交
208 209 210 211 212 213 214 215 216 217
  char         *path;
  SVnode       *pVnode;
  TdThreadMutex mutex;
  char          dir[TSDB_DATA_DIR_LEN];
  bool          repoLocked;
  STsdbKeepCfg  keepCfg;
  SMemTable    *mem;
  SMemTable    *imem;
  SRtn          rtn;
  STsdbFS      *fs;
H
Hongze Cheng 已提交
218 219
};

H
Hongze Cheng 已提交
220
struct STable {
H
Hongze Cheng 已提交
221
  uint64_t  suid;
H
Hongze Cheng 已提交
222
  uint64_t  uid;
223 224
  STSchema *pSchema;       // latest schema
  STSchema *pCacheSchema;  // cached cache
H
Hongze Cheng 已提交
225
};
H
Hongze Cheng 已提交
226

H
refact  
Hongze Cheng 已提交
227 228 229 230 231
struct TSDBKEY {
  int64_t version;
  TSKEY   ts;
};

H
Hongze Cheng 已提交
232 233 234 235 236 237 238 239 240 241 242 243 244 245
typedef struct SMemSkipListNode SMemSkipListNode;
struct SMemSkipListNode {
  int8_t            level;
  SMemSkipListNode *forwards[0];
};
typedef struct SMemSkipList {
  uint32_t          seed;
  int64_t           size;
  int8_t            maxLevel;
  int8_t            level;
  SMemSkipListNode *pHead;
  SMemSkipListNode *pTail;
} SMemSkipList;

H
Hongze Cheng 已提交
246
struct STbData {
H
Hongze Cheng 已提交
247 248 249 250 251 252 253
  tb_uid_t     suid;
  tb_uid_t     uid;
  TSDBKEY      minKey;
  TSDBKEY      maxKey;
  SDelOp      *pHead;
  SDelOp      *pTail;
  SMemSkipList sl;
H
Hongze Cheng 已提交
254
};
H
Hongze Cheng 已提交
255

H
refact  
Hongze Cheng 已提交
256
struct SMemTable {
H
Hongze Cheng 已提交
257 258 259 260 261 262
  SRWLatch latch;
  STsdb   *pTsdb;
  int32_t  nRef;
  TSDBKEY  minKey;
  TSDBKEY  maxKey;
  int64_t  nRow;
H
Hongze Cheng 已提交
263
  int64_t  nDel;
H
Hongze Cheng 已提交
264
  SArray  *aTbData;  // SArray<STbData*>
H
Hongze Cheng 已提交
265
};
H
Hongze Cheng 已提交
266 267 268 269

int tsdbLockRepo(STsdb *pTsdb);
int tsdbUnlockRepo(STsdb *pTsdb);

H
Hongze Cheng 已提交
270
struct TSDBROW {
H
Hongze Cheng 已提交
271 272 273 274 275 276 277 278 279 280
  union {
    struct {
      int64_t version;
      STSRow *pTSRow;
    };
    struct {
      SColDataBlock *pColDataBlock;
      int32_t        iRow;
    };
  };
H
Hongze Cheng 已提交
281 282
};

H
Hongze Cheng 已提交
283
struct SBlockIdx {
H
Hongze Cheng 已提交
284 285
  int64_t suid;
  int64_t uid;
H
Hongze Cheng 已提交
286 287
  TSDBKEY minKey;
  TSDBKEY maxKey;
H
Hongze Cheng 已提交
288
  int64_t minVersion;
H
Hongze Cheng 已提交
289
  int64_t maxVersion;
H
Hongze Cheng 已提交
290 291
  int64_t offset;
  int64_t size;
H
refact  
Hongze Cheng 已提交
292
};
H
Hongze Cheng 已提交
293 294 295 296 297 298 299 300

typedef enum {
  TSDB_SBLK_VER_0 = 0,
  TSDB_SBLK_VER_MAX,
} ESBlockVer;

#define SBlockVerLatest TSDB_SBLK_VER_0

H
Hongze Cheng 已提交
301
struct SBlockItem {
H
Hongze Cheng 已提交
302 303
  TSDBKEY minKey;
  TSDBKEY maxKey;
H
Hongze Cheng 已提交
304
  int64_t minVerion;
H
Hongze Cheng 已提交
305
  int64_t maxVersion;
H
refact  
Hongze Cheng 已提交
306
};
H
Hongze Cheng 已提交
307

H
Hongze Cheng 已提交
308 309 310 311 312 313 314 315 316 317
struct SBlockInfo {
  uint8_t flags;
  int32_t nCols;
  int64_t offset;
  int64_t size;
  int32_t nSmaCols;
  int64_t smaOffset;
  int64_t smaSize;
};

H
Hongze Cheng 已提交
318
struct SBlock {
H
Hongze Cheng 已提交
319 320 321 322 323 324 325
  TSDBKEY    minKey;
  TSDBKEY    maxKey;
  int64_t    minVersion;
  int64_t    maxVersion;
  int32_t    nRows;
  int8_t     nBlockInfo;
  SBlockInfo blockInfos[];
H
refact  
Hongze Cheng 已提交
326
};
H
Hongze Cheng 已提交
327

H
refact  
Hongze Cheng 已提交
328
struct SBlockCol {
H
Hongze Cheng 已提交
329 330
  int16_t  colId;
  uint16_t type : 6;
C
Cary Xu 已提交
331 332
  uint16_t blen : 10;  // 0 no bitmap if all rows are NORM, > 0 bitmap length
  uint32_t len;        // data length + bitmap length
H
Hongze Cheng 已提交
333
  uint32_t offset;
H
refact  
Hongze Cheng 已提交
334
};
H
Hongze Cheng 已提交
335

H
refact  
Hongze Cheng 已提交
336
struct SAggrBlkCol {
H
Hongze Cheng 已提交
337 338 339 340 341 342 343
  int16_t colId;
  int16_t maxIndex;
  int16_t minIndex;
  int16_t numOfNull;
  int64_t sum;
  int64_t max;
  int64_t min;
H
refact  
Hongze Cheng 已提交
344
};
H
Hongze Cheng 已提交
345

H
refact  
Hongze Cheng 已提交
346
struct SBlockData {
H
Hongze Cheng 已提交
347 348 349 350
  int32_t   delimiter;  // For recovery usage
  int32_t   numOfCols;  // For recovery usage
  uint64_t  uid;        // For recovery usage
  SBlockCol cols[];
H
refact  
Hongze Cheng 已提交
351
};
H
Hongze Cheng 已提交
352 353 354 355 356 357

typedef void SAggrBlkData;  // SBlockCol cols[];

// ================== TSDB global config
extern bool tsdbForceKeepFile;

H
Hongze Cheng 已提交
358
#define TSDB_FS_ITER_FORWARD  TSDB_ORDER_ASC
H
Hongze Cheng 已提交
359 360
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC

H
Hongze Cheng 已提交
361 362 363 364 365
struct TABLEID {
  tb_uid_t suid;
  tb_uid_t uid;
};

H
Hongze Cheng 已提交
366 367 368 369 370 371
struct STbDataIter {
  STbData          *pTbData;
  int8_t            backward;
  SMemSkipListNode *pNode;
};

H
more  
Hongze Cheng 已提交
372 373 374 375
struct SDelOp {
  int64_t version;
  TSKEY   sKey;  // included
  TSKEY   eKey;  // included
H
Hongze Cheng 已提交
376
  SDelOp *pNext;
H
more  
Hongze Cheng 已提交
377 378
};

H
Hongze Cheng 已提交
379
struct SDelDataItem {
H
Hongze Cheng 已提交
380 381 382
  int64_t version;
  TSKEY   sKey;
  TSKEY   eKey;
H
Hongze Cheng 已提交
383
};
H
Hongze Cheng 已提交
384 385

struct SDelData {
H
Hongze Cheng 已提交
386 387 388
  uint32_t delimiter;
  tb_uid_t suid;
  tb_uid_t uid;
H
Hongze Cheng 已提交
389
  SOffset  offset;
H
Hongze Cheng 已提交
390 391
  uint32_t nData;
  uint8_t *pData;
H
Hongze Cheng 已提交
392
};
H
Hongze Cheng 已提交
393

H
Hongze Cheng 已提交
394
struct SDelIdxItem {
H
Hongze Cheng 已提交
395 396 397 398 399
  tb_uid_t suid;
  tb_uid_t uid;
  TSKEY    minKey;
  TSKEY    maxKey;
  int64_t  minVersion;
H
Hongze Cheng 已提交
400
  int64_t  maxVersion;
H
Hongze Cheng 已提交
401 402
  int64_t  offset;
  int64_t  size;
H
Hongze Cheng 已提交
403
};
H
Hongze Cheng 已提交
404

H
Hongze Cheng 已提交
405 406
struct SDelIdx {
  uint32_t delimiter;
H
Hongze Cheng 已提交
407
  SOffset  offset;
H
Hongze Cheng 已提交
408 409
  uint32_t nData;
  uint8_t *pData;
H
Hongze Cheng 已提交
410 411
};

H
Hongze Cheng 已提交
412 413 414 415 416 417 418 419
struct SDelFile {
  TSKEY   minKey;
  TSKEY   maxKey;
  int64_t minVersion;
  int64_t maxVersion;
  int64_t size;
  int64_t offset;
};
H
Hongze Cheng 已提交
420

H
Hongze Cheng 已提交
421 422 423 424 425 426
struct SMapData {
  int32_t  nItem;
  uint8_t  flag;
  uint8_t *pOfst;
  uint32_t nData;
  uint8_t *pData;
H
Hongze Cheng 已提交
427
  uint8_t *pBuf;
H
Hongze Cheng 已提交
428 429
};

H
Hongze Cheng 已提交
430 431 432 433 434 435 436 437 438 439 440 441 442
struct SColData {
  int16_t  cid;
  uint8_t  flags;
  uint32_t nData;
  uint8_t *pData;
};

struct SColDataBlock {
  int32_t   nRow;
  int64_t  *aVersion;
  TSKEY    *aTSKey;
  int32_t   nColData;
  SColData *aColData;
H
Hongze Cheng 已提交
443 444
};

H
Hongze Cheng 已提交
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
typedef struct {
  int16_t colId;
  int16_t maxIndex;
  int16_t minIndex;
  int16_t numOfNull;
  int64_t sum;
  int64_t max;
  int64_t min;
} SColSMA;

struct SBlockSMA {
  int32_t  nCol;
  SColSMA *aColSMA;
};

H
Hongze Cheng 已提交
460 461 462 463 464
#ifdef __cplusplus
}
#endif

#endif /*_TD_VNODE_TSDB_H_*/