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

taosdata / TDengine / #3523

06 Nov 2024 02:29AM UTC coverage: 55.861% (-2.4%) from 58.216%
#3523

push

travis-ci

web-flow
Merge pull request #28551 from taosdata/feat/TS-5215-2

test(blob): testing & fixes for blob

106075 of 245834 branches covered (43.15%)

Branch coverage included in aggregate %.

0 of 15 new or added lines in 2 files covered. (0.0%)

17003 existing lines in 254 files now uncovered.

181910 of 269703 relevant lines covered (67.45%)

1527639.59 hits per line

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

0.0
/source/dnode/vnode/src/tsdb/tsdbFSetRAW.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

16
#include "tsdbFSetRAW.h"
17
#include "tsdbFS2.h"
18

19
// SFSetRAWWriter ==================================================
20
typedef struct SFSetRAWWriter {
21
  SFSetRAWWriterConfig config[1];
22

23
  struct {
24
    TFileOpArray fopArr[1];
25
    STFile       file;
26
    int64_t      offset;
27
  } ctx[1];
28

29
  // writer
30
  SDataFileRAWWriter *dataWriter;
31
} SFSetRAWWriter;
32

UNCOV
33
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer) {
×
UNCOV
34
  int32_t code = 0;
×
UNCOV
35
  int32_t lino = 0;
×
36

UNCOV
37
  writer[0] = taosMemoryCalloc(1, sizeof(SFSetRAWWriter));
×
UNCOV
38
  if (writer[0] == NULL) {
×
39
    return terrno;
×
40
  }
41

UNCOV
42
  writer[0]->config[0] = config[0];
×
43

UNCOV
44
  TARRAY2_INIT(writer[0]->ctx->fopArr);
×
45

UNCOV
46
_exit:
×
UNCOV
47
  if (code) {
×
48
    TSDB_ERROR_LOG(TD_VID(config->tsdb->pVnode), lino, code);
×
49
  }
UNCOV
50
  return code;
×
51
}
52

UNCOV
53
static int32_t tsdbFSetRAWWriterFinish(SFSetRAWWriter *writer, TFileOpArray *fopArr) {
×
UNCOV
54
  int32_t code = 0;
×
UNCOV
55
  int32_t lino = 0;
×
56

UNCOV
57
  STsdb *tsdb = writer->config->tsdb;
×
58

59
  STFileOp op;
UNCOV
60
  TARRAY2_FOREACH(writer->ctx->fopArr, op) {
×
UNCOV
61
    code = TARRAY2_APPEND(fopArr, op);
×
UNCOV
62
    TSDB_CHECK_CODE(code, lino, _exit);
×
63
  }
64

UNCOV
65
  TARRAY2_CLEAR(writer->ctx->fopArr, NULL);
×
UNCOV
66
_exit:
×
UNCOV
67
  if (code) {
×
68
    TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code);
×
69
  }
UNCOV
70
  return code;
×
71
}
72

UNCOV
73
static int32_t tsdbFSetRAWWriteFileDataBegin(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr) {
×
UNCOV
74
  int32_t code = 0;
×
UNCOV
75
  int32_t lino = 0;
×
76

UNCOV
77
  SDataFileRAWWriterConfig config = {
×
UNCOV
78
      .tsdb = writer->config->tsdb,
×
UNCOV
79
      .szPage = writer->config->szPage,
×
UNCOV
80
      .fid = bHdr->file.fid,
×
81
      .did = writer->config->did,
UNCOV
82
      .cid = bHdr->file.cid,
×
UNCOV
83
      .level = writer->config->level,
×
84

85
      .file =
86
          {
UNCOV
87
              .type = bHdr->file.type,
×
UNCOV
88
              .fid = bHdr->file.fid,
×
89
              .did = writer->config->did,
UNCOV
90
              .cid = bHdr->file.cid,
×
UNCOV
91
              .size = bHdr->file.size,
×
UNCOV
92
              .minVer = bHdr->file.minVer,
×
UNCOV
93
              .maxVer = bHdr->file.maxVer,
×
94
              .stt = {{
UNCOV
95
                  .level = bHdr->file.stt->level,
×
96
              }},
97
          },
98
  };
99

UNCOV
100
  tsdbFSUpdateEid(config.tsdb->pFS, config.cid);
×
UNCOV
101
  writer->ctx->offset = 0;
×
UNCOV
102
  writer->ctx->file = config.file;
×
103

UNCOV
104
  code = tsdbDataFileRAWWriterOpen(&config, &writer->dataWriter);
×
UNCOV
105
  TSDB_CHECK_CODE(code, lino, _exit);
×
106

UNCOV
107
_exit:
×
UNCOV
108
  if (code) {
×
109
    TSDB_ERROR_LOG(TD_VID(writer->config->tsdb->pVnode), lino, code);
×
110
  }
UNCOV
111
  return code;
×
112
}
113

UNCOV
114
static int32_t tsdbFSetRAWWriteFileDataEnd(SFSetRAWWriter *writer) {
×
UNCOV
115
  int32_t code = 0;
×
UNCOV
116
  int32_t lino = 0;
×
117

UNCOV
118
  code = tsdbDataFileRAWWriterClose(&writer->dataWriter, false, writer->ctx->fopArr);
×
UNCOV
119
  TSDB_CHECK_CODE(code, lino, _exit);
×
120

UNCOV
121
_exit:
×
UNCOV
122
  if (code) {
×
123
    TSDB_ERROR_LOG(TD_VID(writer->config->tsdb->pVnode), lino, code);
×
124
  }
UNCOV
125
  return code;
×
126
}
127

UNCOV
128
int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr) {
×
UNCOV
129
  if (writer[0] == NULL) return 0;
×
130

UNCOV
131
  int32_t code = 0;
×
UNCOV
132
  int32_t lino = 0;
×
133

UNCOV
134
  STsdb *tsdb = writer[0]->config->tsdb;
×
135

136
  // end
UNCOV
137
  code = tsdbFSetRAWWriteFileDataEnd(writer[0]);
×
UNCOV
138
  TSDB_CHECK_CODE(code, lino, _exit);
×
139

UNCOV
140
  code = tsdbDataFileRAWWriterClose(&writer[0]->dataWriter, abort, writer[0]->ctx->fopArr);
×
UNCOV
141
  TSDB_CHECK_CODE(code, lino, _exit);
×
142

UNCOV
143
  code = tsdbFSetRAWWriterFinish(writer[0], fopArr);
×
UNCOV
144
  TSDB_CHECK_CODE(code, lino, _exit);
×
145
  // free
UNCOV
146
  TARRAY2_DESTROY(writer[0]->ctx->fopArr, NULL);
×
UNCOV
147
  taosMemoryFree(writer[0]);
×
UNCOV
148
  writer[0] = NULL;
×
149

UNCOV
150
_exit:
×
UNCOV
151
  if (code) {
×
152
    TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code);
×
153
  }
UNCOV
154
  return code;
×
155
}
156

UNCOV
157
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm,
×
158
                                  char *encryptKey) {
UNCOV
159
  int32_t code = 0;
×
UNCOV
160
  int32_t lino = 0;
×
161

UNCOV
162
  if (writer->ctx->offset == writer->ctx->file.size) {
×
UNCOV
163
    code = tsdbFSetRAWWriteFileDataEnd(writer);
×
UNCOV
164
    TSDB_CHECK_CODE(code, lino, _exit);
×
165

UNCOV
166
    code = tsdbFSetRAWWriteFileDataBegin(writer, bHdr);
×
UNCOV
167
    TSDB_CHECK_CODE(code, lino, _exit);
×
168
  }
169

UNCOV
170
  code = tsdbDataFileRAWWriteBlockData(writer->dataWriter, bHdr, encryptAlgorithm, encryptKey);
×
UNCOV
171
  TSDB_CHECK_CODE(code, lino, _exit);
×
172

UNCOV
173
  writer->ctx->offset += bHdr->dataLength;
×
174

UNCOV
175
_exit:
×
UNCOV
176
  if (code) {
×
177
    TSDB_ERROR_LOG(TD_VID(writer->config->tsdb->pVnode), lino, code);
×
178
  }
UNCOV
179
  return code;
×
180
}
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