• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #3549

06 Dec 2024 09:44AM UTC coverage: 59.948% (+0.1%) from 59.846%
#3549

push

travis-ci

web-flow
Merge pull request #29057 from taosdata/docs/TD-33031-3.0

docs: description of user privileges

118833 of 254191 branches covered (46.75%)

Branch coverage included in aggregate %.

199893 of 277480 relevant lines covered (72.04%)

19006119.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.35
/source/dnode/vnode/src/tq/tqOffset.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15
#define _DEFAULT_SOURCE
16

17
#include "tq.h"
18

19
int32_t tqBuildFName(char** data, const char* path, char* name) {
37,141✔
20
  int32_t len = strlen(path) + strlen(name) + 2;
37,141✔
21
  char*   fname = taosMemoryCalloc(1, len);
37,141✔
22
  if(fname == NULL) {
37,160!
23
    return terrno;
×
24
  }
25
  int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
37,160✔
26
  if (code < 0){
37,158!
27
    code = TAOS_SYSTEM_ERROR(errno);
×
28
    taosMemoryFree(fname);
×
29
    return code;
×
30
  }
31
  *data = fname;
37,158✔
32
  return TDB_CODE_SUCCESS;
37,158✔
33
}
34

35
int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
×
36
  int32_t   code = TDB_CODE_SUCCESS;
×
37
  void*     pMemBuf = NULL;
×
38

39
  TdFilePtr pFile = taosOpenFile(name, TD_FILE_READ);
×
40
  if (pFile == NULL) {
×
41
    code = TDB_CODE_SUCCESS;
×
42
    goto END;
×
43
  }
44

45
  int64_t ret = 0;
×
46
  int32_t size = 0;
×
47
  int32_t total = 0;
×
48
  while (1) {
×
49
    if ((ret = taosReadFile(pFile, &size, INT_BYTES)) != INT_BYTES) {
×
50
      if (ret != 0) {
×
51
        code = TSDB_CODE_INVALID_MSG;
×
52
      }
53
      break;
×
54
    }
55
    total += INT_BYTES;
×
56
    size = htonl(size);
×
57
    pMemBuf = taosMemoryCalloc(1, size);
×
58
    if (pMemBuf == NULL) {
×
59
      code = terrno;
×
60
      goto END;
×
61
    }
62

63
    if (taosReadFile(pFile, pMemBuf, size) != size) {
×
64
      terrno = TSDB_CODE_INVALID_MSG;
×
65
      goto END;
×
66
    }
67

68
    total += size;
×
69
    STqOffset offset = {0};
×
70
    TQ_ERR_GO_TO_END(tqMetaDecodeOffsetInfo(&offset, pMemBuf, size));
×
71
    code = taosHashPut(pTq->pOffset, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset));
×
72
    if (code != TDB_CODE_SUCCESS) {
×
73
      tDeleteSTqOffset(&offset);
×
74
      goto END;
×
75
    }
76

77
    tqInfo("tq: offset restore from file to tdb, size:%d, hash size:%d subkey:%s", total, taosHashGetSize(pTq->pOffset), offset.subKey);
×
78
    taosMemoryFree(pMemBuf);
×
79
    pMemBuf = NULL;
×
80
  }
81

82
  void *pIter = NULL;
×
83
  while ((pIter = taosHashIterate(pTq->pOffset, pIter))) {
×
84
    STqOffset* pOffset = (STqOffset*)pIter;
×
85
    code = tqMetaSaveOffset(pTq, pOffset);
×
86
    if(code != 0){
×
87
      taosHashCancelIterate(pTq->pOffset, pIter);
×
88
      goto END;
×
89
    }
90
  }
91

92
END:
×
93
  taosCloseFile(&pFile);
×
94
  taosMemoryFree(pMemBuf);
×
95

96
  return code;
×
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc