tsdbFile.h 12.4 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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/>.
 */

#ifndef _TS_TSDB_FILE_H_
#define _TS_TSDB_FILE_H_

H
Hongze Cheng 已提交
19 20
#include "tchecksum.h"
#include "tfs.h"
H
Hongze Cheng 已提交
21

H
refact  
Hongze Cheng 已提交
22 23 24
#define TSDB_FILE_HEAD_SIZE 512
#define TSDB_FILE_DELIMITER 0xF00AFA0F
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
H
Hongze Cheng 已提交
25
#define TSDB_IVLD_FID INT_MIN
H
Hongze Cheng 已提交
26 27
#define TSDB_FILE_STATE_OK 0
#define TSDB_FILE_STATE_BAD 1
H
refact  
Hongze Cheng 已提交
28

H
refact  
Hongze Cheng 已提交
29 30
#define TSDB_FILE_INFO(tf) (&((tf)->info))
#define TSDB_FILE_F(tf) (&((tf)->f))
31
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
S
Shengliang Guan 已提交
32
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
33
#define TSDB_FILE_OPENED(tf) (TSDB_FILE_PFILE(tf) != NULL)
H
Hongze Cheng 已提交
34
#define TSDB_FILE_CLOSED(tf) (!TSDB_FILE_OPENED(tf))
35
#define TSDB_FILE_SET_CLOSED(f) (TSDB_FILE_PFILE(f) = NULL)
S
Shengliang Guan 已提交
36 37 38 39 40
#define TSDB_FILE_LEVEL(tf) (TSDB_FILE_F(tf)->did.level)
#define TSDB_FILE_ID(tf) (TSDB_FILE_F(tf)->did.id)
#define TSDB_FILE_DID(tf) (TSDB_FILE_F(tf)->did)
#define TSDB_FILE_REL_NAME(tf) (TSDB_FILE_F(tf)->rname)
#define TSDB_FILE_ABS_NAME(tf) (TSDB_FILE_F(tf)->aname)
41
#define TSDB_FILE_FSYNC(tf) taosFsyncFile(TSDB_FILE_PFILE(tf))
H
Hongze Cheng 已提交
42 43 44 45
#define TSDB_FILE_STATE(tf) ((tf)->state)
#define TSDB_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
H
refact  
Hongze Cheng 已提交
46

C
Cary Xu 已提交
47 48 49 50 51 52 53
typedef enum {
  TSDB_FILE_HEAD = 0,  // .head
  TSDB_FILE_DATA,      // .data
  TSDB_FILE_LAST,      // .last
  TSDB_FILE_SMAD,      // .smad(Block-wise SMA)
  TSDB_FILE_SMAL,      // .smal(Block-wise SMA)
  TSDB_FILE_MAX,       //
C
Cary Xu 已提交
54
  TSDB_FILE_META,      // meta
C
Cary Xu 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
  TSDB_FILE_TSMA,      // .tsma.${sma_index_name}, Time-range-wise SMA
  TSDB_FILE_RSMA,      // .rsma.${sma_index_name}, Time-range-wise Rollup SMA
} TSDB_FILE_T;

typedef enum {
  TSDB_FS_VER_0 = 0,
  TSDB_FS_VER_MAX,
} ETsdbFsVer;

#define TSDB_LATEST_FVER    TSDB_FS_VER_0  // latest version for DFile
#define TSDB_LATEST_SFS_VER TSDB_FS_VER_0  // latest version for 'current' file

static FORCE_INLINE uint32_t tsdbGetDFSVersion(TSDB_FILE_T fType) {  // latest version for DFile
  switch (fType) {
    case TSDB_FILE_HEAD:  // .head
    case TSDB_FILE_DATA:  // .data
    case TSDB_FILE_LAST:  // .last
    case TSDB_FILE_SMAD:  // .smad(Block-wise SMA)
    case TSDB_FILE_SMAL:  // .smal(Block-wise SMA)
    default:
      return TSDB_LATEST_FVER;
  }
}
H
refact  
Hongze Cheng 已提交
78

H
Hongze Cheng 已提交
79
#if 0
H
refact  
Hongze Cheng 已提交
80
// =============== SMFile
H
refact  
Hongze Cheng 已提交
81 82 83 84 85 86 87 88 89
typedef struct {
  int64_t  size;
  int64_t  tombSize;
  int64_t  nRecords;
  int64_t  nDels;
  uint32_t magic;
} SMFInfo;

typedef struct {
S
Shengliang Guan 已提交
90 91 92 93
  SMFInfo  info;
  STfsFile f;
  int      fd;
  uint8_t  state;
H
refact  
Hongze Cheng 已提交
94 95
} SMFile;

H
Hongze Cheng 已提交
96
void  tsdbInitMFile(SMFile* pMFile, SDiskID did, int vid, uint32_t ver);
H
Hongze Cheng 已提交
97
void  tsdbInitMFileEx(SMFile* pMFile, const SMFile* pOMFile);
H
refact  
Hongze Cheng 已提交
98 99
int   tsdbEncodeSMFile(void** buf, SMFile* pMFile);
void* tsdbDecodeSMFile(void* buf, SMFile* pMFile);
H
Hongze Cheng 已提交
100 101
int   tsdbEncodeSMFileEx(void** buf, SMFile* pMFile);
void* tsdbDecodeSMFileEx(void* buf, SMFile* pMFile);
H
Hongze Cheng 已提交
102
int   tsdbApplyMFileChange(SMFile* from, SMFile* to);
H
Hongze Cheng 已提交
103
int   tsdbCreateMFile(SMFile* pMFile, bool updateHeader);
H
Hongze Cheng 已提交
104
int   tsdbUpdateMFileHeader(SMFile* pMFile);
H
Hongze Cheng 已提交
105
int   tsdbLoadMFileHeader(SMFile* pMFile, SMFInfo* pInfo);
H
Hongze Cheng 已提交
106
int   tsdbScanAndTryFixMFile(STsdb* pRepo);
H
Hongze Cheng 已提交
107 108
int   tsdbEncodeMFInfo(void** buf, SMFInfo* pInfo);
void* tsdbDecodeMFInfo(void* buf, SMFInfo* pInfo);
H
Hongze Cheng 已提交
109

H
Hongze Cheng 已提交
110
static FORCE_INLINE void tsdbSetMFileInfo(SMFile* pMFile, SMFInfo* pInfo) { pMFile->info = *pInfo; }
H
refact  
Hongze Cheng 已提交
111

H
refact  
Hongze Cheng 已提交
112
static FORCE_INLINE int tsdbOpenMFile(SMFile* pMFile, int flags) {
H
Hongze Cheng 已提交
113
  ASSERT(TSDB_FILE_CLOSED(pMFile));
H
refact  
Hongze Cheng 已提交
114 115 116 117 118 119 120 121 122 123

  pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags);
  if (pMFile->fd < 0) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return 0;
}

H
refact  
Hongze Cheng 已提交
124
static FORCE_INLINE void tsdbCloseMFile(SMFile* pMFile) {
H
refact  
Hongze Cheng 已提交
125 126 127 128 129 130
  if (TSDB_FILE_OPENED(pMFile)) {
    close(pMFile->fd);
    TSDB_FILE_SET_CLOSED(pMFile);
  }
}

H
refact  
Hongze Cheng 已提交
131
static FORCE_INLINE int64_t tsdbSeekMFile(SMFile* pMFile, int64_t offset, int whence) {
H
refact  
Hongze Cheng 已提交
132 133
  ASSERT(TSDB_FILE_OPENED(pMFile));

H
Hongze Cheng 已提交
134
  int64_t loffset = taosLSeekFile(TSDB_FILE_FD(pMFile), offset, whence);
H
refact  
Hongze Cheng 已提交
135 136 137 138 139 140 141
  if (loffset < 0) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return loffset;
}
H
refact  
Hongze Cheng 已提交
142

H
refact  
Hongze Cheng 已提交
143
static FORCE_INLINE int64_t tsdbWriteMFile(SMFile* pMFile, void* buf, int64_t nbyte) {
H
refact  
Hongze Cheng 已提交
144 145
  ASSERT(TSDB_FILE_OPENED(pMFile));

H
Hongze Cheng 已提交
146
  int64_t nwrite = taosWriteFile(pMFile->fd, buf, nbyte);
H
refact  
Hongze Cheng 已提交
147 148 149 150 151 152 153 154
  if (nwrite < nbyte) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return nwrite;
}

H
refact  
Hongze Cheng 已提交
155
static FORCE_INLINE void tsdbUpdateMFileMagic(SMFile* pMFile, void* pCksum) {
H
refact  
Hongze Cheng 已提交
156 157 158
  pMFile->info.magic = taosCalcChecksum(pMFile->info.magic, (uint8_t*)(pCksum), sizeof(TSCKSUM));
}

H
Hongze Cheng 已提交
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
static FORCE_INLINE int tsdbAppendMFile(SMFile* pMFile, void* buf, int64_t nbyte, int64_t* offset) {
  ASSERT(TSDB_FILE_OPENED(pMFile));

  int64_t toffset;

  if ((toffset = tsdbSeekMFile(pMFile, 0, SEEK_END)) < 0) {
    return -1;
  }

  ASSERT(pMFile->info.size == toffset);

  if (offset) {
    *offset = toffset;
  }

  if (tsdbWriteMFile(pMFile, buf, nbyte) < 0) {
    return -1;
  }

  pMFile->info.size += nbyte;

S
TD-1207  
Shengliang Guan 已提交
180
  return (int)nbyte;
H
Hongze Cheng 已提交
181 182 183 184 185 186 187
}

static FORCE_INLINE int tsdbRemoveMFile(SMFile* pMFile) { return tfsremove(TSDB_FILE_F(pMFile)); }

static FORCE_INLINE int64_t tsdbReadMFile(SMFile* pMFile, void* buf, int64_t nbyte) {
  ASSERT(TSDB_FILE_OPENED(pMFile));

H
Hongze Cheng 已提交
188
  int64_t nread = taosReadFile(pMFile->fd, buf, nbyte);
H
Hongze Cheng 已提交
189 190 191 192 193 194 195
  if (nread < 0) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return nread;
}
H
refact  
Hongze Cheng 已提交
196

H
Hongze Cheng 已提交
197 198
#endif

H
refact  
Hongze Cheng 已提交
199
// =============== SDFile
H
refact  
Hongze Cheng 已提交
200 201
typedef struct {
  uint32_t magic;
C
Cary Xu 已提交
202
  uint32_t fver;
H
refact  
Hongze Cheng 已提交
203 204 205 206 207 208 209 210 211
  uint32_t len;
  uint32_t totalBlocks;
  uint32_t totalSubBlocks;
  uint32_t offset;
  uint64_t size;
  uint64_t tombSize;
} SDFInfo;

typedef struct {
212 213 214 215
  SDFInfo   info;
  STfsFile  f;
  TdFilePtr pFile;
  uint8_t   state;
H
refact  
Hongze Cheng 已提交
216 217
} SDFile;

S
Shengliang Guan 已提交
218
void  tsdbInitDFile(STsdb *pRepo, SDFile* pDFile, SDiskID did, int fid, uint32_t ver, TSDB_FILE_T ftype);
H
Hongze Cheng 已提交
219
void  tsdbInitDFileEx(SDFile* pDFile, SDFile* pODFile);
H
refact  
Hongze Cheng 已提交
220
int   tsdbEncodeSDFile(void** buf, SDFile* pDFile);
S
Shengliang Guan 已提交
221
void* tsdbDecodeSDFile(STsdb *pRepo, void* buf, SDFile* pDFile);
C
Cary Xu 已提交
222
int   tsdbCreateDFile(STsdb *pRepo, SDFile* pDFile, bool updateHeader, TSDB_FILE_T fType);
H
Hongze Cheng 已提交
223
int   tsdbUpdateDFileHeader(SDFile* pDFile);
H
Hongze Cheng 已提交
224 225
int   tsdbLoadDFileHeader(SDFile* pDFile, SDFInfo* pInfo);
int   tsdbParseDFilename(const char* fname, int* vid, int* fid, TSDB_FILE_T* ftype, uint32_t* version);
H
Hongze Cheng 已提交
226 227

static FORCE_INLINE void tsdbSetDFileInfo(SDFile* pDFile, SDFInfo* pInfo) { pDFile->info = *pInfo; }
H
refact  
Hongze Cheng 已提交
228

H
Hongze Cheng 已提交
229
static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) {
H
refact  
Hongze Cheng 已提交
230 231
  ASSERT(!TSDB_FILE_OPENED(pDFile));

232 233
  pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), flags);
  if (pDFile->pFile == NULL) {
H
refact  
Hongze Cheng 已提交
234 235 236 237 238 239 240
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return 0;
}

H
refact  
Hongze Cheng 已提交
241
static FORCE_INLINE void tsdbCloseDFile(SDFile* pDFile) {
H
refact  
Hongze Cheng 已提交
242
  if (TSDB_FILE_OPENED(pDFile)) {
243
    taosCloseFile(&pDFile->pFile);
H
refact  
Hongze Cheng 已提交
244 245 246 247
    TSDB_FILE_SET_CLOSED(pDFile);
  }
}

H
Hongze Cheng 已提交
248
static FORCE_INLINE int64_t tsdbSeekDFile(SDFile* pDFile, int64_t offset, int whence) {
249
  // ASSERT(TSDB_FILE_OPENED(pDFile));
H
refact  
Hongze Cheng 已提交
250

251
  int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
H
refact  
Hongze Cheng 已提交
252 253 254 255 256 257 258 259
  if (loffset < 0) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return loffset;
}

H
refact  
Hongze Cheng 已提交
260
static FORCE_INLINE int64_t tsdbWriteDFile(SDFile* pDFile, void* buf, int64_t nbyte) {
H
refact  
Hongze Cheng 已提交
261 262
  ASSERT(TSDB_FILE_OPENED(pDFile));

263
  int64_t nwrite = taosWriteFile(pDFile->pFile, buf, nbyte);
H
refact  
Hongze Cheng 已提交
264 265 266 267 268 269 270 271
  if (nwrite < nbyte) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return nwrite;
}

H
Hongze Cheng 已提交
272 273 274 275 276
static FORCE_INLINE void tsdbUpdateDFileMagic(SDFile* pDFile, void* pCksm) {
  pDFile->info.magic = taosCalcChecksum(pDFile->info.magic, (uint8_t*)(pCksm), sizeof(TSCKSUM));
}

static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte, int64_t* offset) {
H
refact  
Hongze Cheng 已提交
277 278
  ASSERT(TSDB_FILE_OPENED(pDFile));

H
Hongze Cheng 已提交
279
  int64_t toffset;
H
refact  
Hongze Cheng 已提交
280

H
Hongze Cheng 已提交
281 282 283
  if ((toffset = tsdbSeekDFile(pDFile, 0, SEEK_END)) < 0) {
    return -1;
  }
H
refact  
Hongze Cheng 已提交
284

H
Hongze Cheng 已提交
285 286 287 288 289 290 291 292 293 294 295 296
  ASSERT(pDFile->info.size == toffset);

  if (offset) {
    *offset = toffset;
  }

  if (tsdbWriteDFile(pDFile, buf, nbyte) < 0) {
    return -1;
  }

  pDFile->info.size += nbyte;

S
TD-1207  
Shengliang Guan 已提交
297
  return (int)nbyte;
H
refact  
Hongze Cheng 已提交
298 299
}

S
Shengliang Guan 已提交
300
static FORCE_INLINE int tsdbRemoveDFile(SDFile* pDFile) { return tfsRemoveFile(TSDB_FILE_F(pDFile)); }
H
Hongze Cheng 已提交
301

H
refact  
Hongze Cheng 已提交
302
static FORCE_INLINE int64_t tsdbReadDFile(SDFile* pDFile, void* buf, int64_t nbyte) {
H
refact  
Hongze Cheng 已提交
303 304
  ASSERT(TSDB_FILE_OPENED(pDFile));

305
  int64_t nread = taosReadFile(pDFile->pFile, buf, nbyte);
H
refact  
Hongze Cheng 已提交
306 307 308 309 310 311 312 313
  if (nread < 0) {
    terrno = TAOS_SYSTEM_ERROR(errno);
    return -1;
  }

  return nread;
}

H
Hongze Cheng 已提交
314
static FORCE_INLINE int tsdbCopyDFile(SDFile* pSrc, SDFile* pDest) {
S
Shengliang Guan 已提交
315
  if (tfsCopyFile(TSDB_FILE_F(pSrc), TSDB_FILE_F(pDest)) < 0) {
H
Hongze Cheng 已提交
316
    terrno = TAOS_SYSTEM_ERROR(errno);
H
Hongze Cheng 已提交
317 318 319
    return -1;
  }

H
Hongze Cheng 已提交
320
  tsdbSetDFileInfo(pDest, TSDB_FILE_INFO(pSrc));
H
Hongze Cheng 已提交
321 322 323
  return 0;
}

H
refact  
Hongze Cheng 已提交
324
// =============== SDFileSet
H
refact  
Hongze Cheng 已提交
325
typedef struct {
C
Cary Xu 已提交
326 327 328 329 330
  int      fid;
  int8_t   state;    // -128~127
  uint8_t  ver;      // 0~255, DFileSet version
  uint16_t reserve;
  SDFile   files[TSDB_FILE_MAX];
H
refact  
Hongze Cheng 已提交
331 332
} SDFileSet;

C
Cary Xu 已提交
333 334
#define TSDB_LATEST_FSET_VER 0

H
refact  
Hongze Cheng 已提交
335
#define TSDB_FSET_FID(s) ((s)->fid)
C
Cary Xu 已提交
336 337
#define TSDB_FSET_STATE(s) ((s)->state)
#define TSDB_FSET_VER(s) ((s)->ver)
H
refact  
Hongze Cheng 已提交
338
#define TSDB_DFILE_IN_SET(s, t) ((s)->files + (t))
H
Hongze Cheng 已提交
339 340
#define TSDB_FSET_LEVEL(s) TSDB_FILE_LEVEL(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_ID(s) TSDB_FILE_ID(TSDB_DFILE_IN_SET(s, 0))
H
Hongze Cheng 已提交
341 342 343 344 345 346
#define TSDB_FSET_SET_CLOSED(s)                                                \
  do {                                                                         \
    for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
      TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype));                       \
    }                                                                          \
  } while (0);
H
Hongze Cheng 已提交
347 348 349 350 351 352
#define TSDB_FSET_FSYNC(s)                                                     \
  do {                                                                         \
    for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
      TSDB_FILE_FSYNC(TSDB_DFILE_IN_SET(s, ftype));                            \
    }                                                                          \
  } while (0);
H
refact  
Hongze Cheng 已提交
353

S
Shengliang Guan 已提交
354
void  tsdbInitDFileSet(STsdb *pRepo, SDFileSet* pSet, SDiskID did, int fid, uint32_t ver);
H
Hongze Cheng 已提交
355 356
void  tsdbInitDFileSetEx(SDFileSet* pSet, SDFileSet* pOSet);
int   tsdbEncodeDFileSet(void** buf, SDFileSet* pSet);
S
Shengliang Guan 已提交
357
void* tsdbDecodeDFileSet(STsdb *pRepo, void* buf, SDFileSet* pSet);
H
Hongze Cheng 已提交
358 359
int   tsdbEncodeDFileSetEx(void** buf, SDFileSet* pSet);
void* tsdbDecodeDFileSetEx(void* buf, SDFileSet* pSet);
H
Hongze Cheng 已提交
360
int   tsdbApplyDFileSetChange(SDFileSet* from, SDFileSet* to);
S
Shengliang Guan 已提交
361
int   tsdbCreateDFileSet(STsdb *pRepo, SDFileSet* pSet, bool updateHeader);
H
Hongze Cheng 已提交
362
int   tsdbUpdateDFileSetHeader(SDFileSet* pSet);
H
Hongze Cheng 已提交
363
int   tsdbScanAndTryFixDFileSet(STsdb* pRepo, SDFileSet* pSet);
H
Hongze Cheng 已提交
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382

static FORCE_INLINE void tsdbCloseDFileSet(SDFileSet* pSet) {
  for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
    tsdbCloseDFile(TSDB_DFILE_IN_SET(pSet, ftype));
  }
}

static FORCE_INLINE int tsdbOpenDFileSet(SDFileSet* pSet, int flags) {
  for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
    if (tsdbOpenDFile(TSDB_DFILE_IN_SET(pSet, ftype), flags) < 0) {
      tsdbCloseDFileSet(pSet);
      return -1;
    }
  }
  return 0;
}

static FORCE_INLINE void tsdbRemoveDFileSet(SDFileSet* pSet) {
  for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
383
    (void)tsdbRemoveDFile(TSDB_DFILE_IN_SET(pSet, ftype));
H
Hongze Cheng 已提交
384 385 386 387 388 389 390 391 392 393 394 395 396
  }
}

static FORCE_INLINE int tsdbCopyDFileSet(SDFileSet* pSrc, SDFileSet* pDest) {
  for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
    if (tsdbCopyDFile(TSDB_DFILE_IN_SET(pSrc, ftype), TSDB_DFILE_IN_SET(pDest, ftype)) < 0) {
      tsdbRemoveDFileSet(pDest);
      return -1;
    }
  }

  return 0;
}
H
refact  
Hongze Cheng 已提交
397

H
refact  
Hongze Cheng 已提交
398
static FORCE_INLINE void tsdbGetFidKeyRange(int days, int8_t precision, int fid, TSKEY* minKey, TSKEY* maxKey) {
399 400
  *minKey = fid * days * tsTickPerDay[precision];
  *maxKey = *minKey + days * tsTickPerDay[precision] - 1;
H
refact  
Hongze Cheng 已提交
401 402
}

H
Hongze Cheng 已提交
403 404 405 406 407 408 409 410 411 412
static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet* pSet) {
  for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
    if (TSDB_FILE_IS_BAD(TSDB_DFILE_IN_SET(pSet, ftype))) {
      return false;
    }
  }

  return true;
}

H
refact  
Hongze Cheng 已提交
413
#endif /* _TS_TSDB_FILE_H_ */