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

taosdata / TDengine / #5085

17 May 2026 01:15AM UTC coverage: 73.334% (-0.03%) from 73.366%
#5085

push

travis-ci

web-flow
feat (TDgpt): Dynamic Model Synchronization Enhancements (#35344)

* refactor: do some internal refactor.

* fix: fix multiprocess sync issue.

* feat: add dynamic anomaly detection and forecasting services

* fix: log error message for undeploying model in exception handling

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix: handle undeploy when model exists only on disk

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/286aafa0-c3ce-4c27-b803-2707571e9dc1

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: guard dynamic registry concurrent access

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: tighten service list locking scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/5e4db858-6458-40f4-ac28-d1b1b7f97c18

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: restore prophet support and update tests per review feedback

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* fix: improve test name and move copy inside lock scope

Agent-Logs-Url: https://github.com/taosdata/TDengine/sessions/92298ae1-7da6-4d07-b20e-101c7cd0b26b

Co-authored-by: hjxilinx <8252296+hjxilinx@users.noreply.github.com>

* Potential fix for pull request finding

Co-au... (continued)

281451 of 383795 relevant lines covered (73.33%)

137008077.93 hits per line

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

95.35
/source/dnode/vnode/src/tsdb/tsdbUtil2.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 "tsdbUtil2.h"
17

18
// SDelBlock ----------
19
void tTombBlockInit(STombBlock *tombBlock) {
1,677,235✔
20
  tombBlock->numOfRecords = 0;
1,677,235✔
21
  for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
10,063,410✔
22
    tBufferInit(&tombBlock->buffers[i]);
8,386,175✔
23
  }
24
  return;
1,677,235✔
25
}
26

27
void tTombBlockDestroy(STombBlock *tombBlock) {
34,483,563✔
28
  tombBlock->numOfRecords = 0;
34,483,563✔
29
  for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
206,895,010✔
30
    tBufferDestroy(&tombBlock->buffers[i]);
172,410,647✔
31
  }
32
}
34,484,363✔
33

34
void tTombBlockClear(STombBlock *tombBlock) {
12,744,752✔
35
  tombBlock->numOfRecords = 0;
12,744,752✔
36
  for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
76,468,512✔
37
    tBufferClear(&tombBlock->buffers[i]);
63,723,760✔
38
  }
39
}
12,744,752✔
40

41
int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) {
43,763,126✔
42
  for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
262,578,756✔
43
    TAOS_CHECK_RETURN(tBufferPutI64(&tombBlock->buffers[i], record->data[i]));
437,631,260✔
44
  }
45
  tombBlock->numOfRecords++;
43,763,126✔
46
  return 0;
43,763,126✔
47
}
48

49
int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record) {
207,228,882✔
50
  if (idx < 0 || idx >= tombBlock->numOfRecords) {
207,228,882✔
51
    return TSDB_CODE_OUT_OF_RANGE;
×
52
  }
53

54
  for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) {
1,243,372,677✔
55
    SBufferReader br = BUFFER_READER_INITIALIZER(sizeof(int64_t) * idx, &tombBlock->buffers[i]);
1,036,142,565✔
56
    TAOS_CHECK_RETURN(tBufferGetI64(&br, &record->data[i]));
1,036,142,565✔
57
  }
58
  return 0;
207,230,112✔
59
}
60

61
int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) {
36,811,395✔
62
  if (r1->suid < r2->suid) return -1;
36,811,395✔
63
  if (r1->suid > r2->suid) return 1;
36,420,720✔
64
  if (r1->uid < r2->uid) return -1;
1,155,945✔
65
  if (r1->uid > r2->uid) return 1;
1,155,945✔
66
  if (r1->version < r2->version) return -1;
1,155,945✔
67
  if (r1->version > r2->version) return 1;
1,155,945✔
68
  return 0;
×
69
}
70

71
// STbStatisBlock ----------
72
int32_t tStatisBlockInit(STbStatisBlock *statisBlock) {
322,067,359✔
73
  int32_t code = 0;
322,067,359✔
74

75
  statisBlock->numOfPKs = 0;
322,067,359✔
76
  statisBlock->numOfRecords = 0;
322,098,327✔
77
  for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
1,932,258,341✔
78
    tBufferInit(&statisBlock->buffers[i]);
1,610,196,976✔
79
  }
80
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
966,256,020✔
81
    TAOS_CHECK_GOTO(tValueColumnInit(&statisBlock->firstKeyPKs[i]), NULL, _exit);
644,159,096✔
82
    TAOS_CHECK_GOTO(tValueColumnInit(&statisBlock->lastKeyPKs[i]), NULL, _exit);
644,135,750✔
83
  }
84

85
_exit:
322,096,924✔
86
  if (code) {
322,096,924✔
87
    tStatisBlockDestroy(statisBlock);
×
88
  }
89
  return code;
322,095,372✔
90
}
91

92
void tStatisBlockDestroy(STbStatisBlock *statisBlock) {
342,531,706✔
93
  statisBlock->numOfPKs = 0;
342,531,706✔
94
  statisBlock->numOfRecords = 0;
342,544,912✔
95
  for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
2,055,299,262✔
96
    tBufferDestroy(&statisBlock->buffers[i]);
1,712,727,398✔
97
  }
98
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
1,027,680,699✔
99
    tValueColumnDestroy(&statisBlock->firstKeyPKs[i]);
685,132,760✔
100
    tValueColumnDestroy(&statisBlock->lastKeyPKs[i]);
685,122,538✔
101
  }
102
}
342,547,939✔
103

104
void tStatisBlockClear(STbStatisBlock *statisBlock) {
350,956,044✔
105
  statisBlock->numOfPKs = 0;
350,956,044✔
106
  statisBlock->numOfRecords = 0;
350,971,729✔
107
  for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
2,105,590,149✔
108
    tBufferClear(&statisBlock->buffers[i]);
1,754,638,294✔
109
  }
110
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
1,052,786,475✔
111
    tValueColumnClear(&statisBlock->firstKeyPKs[i]);
701,870,029✔
112
    tValueColumnClear(&statisBlock->lastKeyPKs[i]);
701,858,496✔
113
  }
114
  return;
350,916,446✔
115
}
116

117
static int32_t tStatisBlockAppend(STbStatisBlock *block, SRowInfo *row) {
106,078,889✔
118
  STsdbRowKey key;
106,077,281✔
119

120
  tsdbRowGetKey(&row->row, &key);
106,088,046✔
121
  if (block->numOfRecords == 0) {
106,103,090✔
122
    block->numOfPKs = key.key.numOfPKs;
20,724,698✔
123
  } else if (block->numOfPKs != key.key.numOfPKs) {
85,369,216✔
124
    return TSDB_CODE_INVALID_PARA;
47,045✔
125
  } else {
126
    for (int i = 0; i < block->numOfPKs; i++) {
85,816,380✔
127
      if (key.key.pks[i].type != block->firstKeyPKs[i].type) {
550,532✔
128
        return TSDB_CODE_INVALID_PARA;
53,095✔
129
      }
130
    }
131
  }
132

133
  TAOS_CHECK_RETURN(tBufferPutI64(&block->suids, row->suid));
211,979,702✔
134
  TAOS_CHECK_RETURN(tBufferPutI64(&block->uids, row->uid));
211,998,914✔
135
  TAOS_CHECK_RETURN(tBufferPutI64(&block->firstKeyTimestamps, key.key.ts));
212,002,914✔
136
  TAOS_CHECK_RETURN(tBufferPutI64(&block->lastKeyTimestamps, key.key.ts));
212,003,696✔
137
  TAOS_CHECK_RETURN(tBufferPutI64(&block->counts, 1));
212,003,999✔
138
  for (int32_t i = 0; i < block->numOfPKs; ++i) {
106,913,998✔
139
    TAOS_CHECK_RETURN(tValueColumnAppend(block->firstKeyPKs + i, key.key.pks + i));
913,782✔
140
    TAOS_CHECK_RETURN(tValueColumnAppend(block->lastKeyPKs + i, key.key.pks + i));
913,782✔
141
  }
142

143
  block->numOfRecords++;
105,995,410✔
144
  return 0;
105,990,485✔
145
}
146

147
static int32_t tStatisBlockUpdate(STbStatisBlock *block, SRowInfo *row) {
2,147,483,647✔
148
  STbStatisRecord record;
2,147,483,647✔
149
  STsdbRowKey     key;
2,147,483,647✔
150
  int32_t         c;
151

152
  TAOS_CHECK_RETURN(tStatisBlockGet(block, block->numOfRecords - 1, &record));
2,147,483,647✔
153
  tsdbRowGetKey(&row->row, &key);
2,147,483,647✔
154

155
  c = tRowKeyCompare(&record.lastKey, &key.key);
2,147,483,647✔
156
  if (c == 0) {
2,147,483,647✔
157
    return 0;
201,301,312✔
158
  } else if (c < 0) {
2,147,483,647✔
159
    // last ts
160
    TAOS_CHECK_RETURN(tBufferPutAt(&block->lastKeyTimestamps, (block->numOfRecords - 1) * sizeof(record.lastKey.ts),
2,147,483,647✔
161
                                   &key.key.ts, sizeof(key.key.ts)));
162

163
    // last primary keys
164
    for (int i = 0; i < block->numOfPKs; i++) {
2,147,483,647✔
165
      TAOS_CHECK_RETURN(tValueColumnUpdate(&block->lastKeyPKs[i], block->numOfRecords - 1, &key.key.pks[i]));
63,666,436✔
166
    }
167

168
    // count
169
    record.count++;
2,147,483,647✔
170
    TAOS_CHECK_RETURN(tBufferPutAt(&block->counts, (block->numOfRecords - 1) * sizeof(record.count), &record.count,
2,147,483,647✔
171
                                   sizeof(record.count)));
172
  } else {
173
    return TSDB_CODE_INVALID_PARA;
×
174
  }
175

176
  return 0;
2,147,483,647✔
177
}
178

179
int32_t tStatisBlockPut(STbStatisBlock *block, SRowInfo *row, int32_t maxRecords) {
2,147,483,647✔
180
  if (block->numOfRecords > 0) {
2,147,483,647✔
181
    int64_t       lastUid;
2,147,483,647✔
182
    SBufferReader br = BUFFER_READER_INITIALIZER(sizeof(int64_t) * (block->numOfRecords - 1), &block->uids);
2,147,483,647✔
183
    TAOS_CHECK_RETURN(tBufferGetI64(&br, &lastUid));
2,147,483,647✔
184

185
    if (lastUid == row->uid) {
2,147,483,647✔
186
      return tStatisBlockUpdate(block, row);
2,147,483,647✔
187
    } else if (block->numOfRecords >= maxRecords) {
85,378,718✔
188
      return TSDB_CODE_INVALID_PARA;
6,740✔
189
    }
190
  }
191
  return tStatisBlockAppend(block, row);
107,361,151✔
192
}
193

194
int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record) {
2,147,483,647✔
195
  SBufferReader reader;
2,147,483,647✔
196

197
  if (idx < 0 || idx >= statisBlock->numOfRecords) {
2,147,483,647✔
198
    return TSDB_CODE_OUT_OF_RANGE;
×
199
  }
200

201
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->suid), &statisBlock->suids);
2,147,483,647✔
202
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->suid));
2,147,483,647✔
203

204
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->uid), &statisBlock->uids);
2,147,483,647✔
205
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->uid));
2,147,483,647✔
206

207
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->firstKey.ts), &statisBlock->firstKeyTimestamps);
2,147,483,647✔
208
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->firstKey.ts));
2,147,483,647✔
209

210
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->lastKey.ts), &statisBlock->lastKeyTimestamps);
2,147,483,647✔
211
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->lastKey.ts));
2,147,483,647✔
212

213
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->count), &statisBlock->counts);
2,147,483,647✔
214
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->count));
2,147,483,647✔
215

216
  if (statisBlock->numOfPKs > TD_MAX_PK_COLS) {
2,147,483,647✔
217
    return TSDB_CODE_FILE_CORRUPTED;
×
218
  }
219

220
  // primary keys
221
  for (record->firstKey.numOfPKs = 0; record->firstKey.numOfPKs < statisBlock->numOfPKs; record->firstKey.numOfPKs++) {
2,147,483,647✔
222
    TAOS_CHECK_RETURN(tValueColumnGet(&statisBlock->firstKeyPKs[record->firstKey.numOfPKs], idx,
117,445,618✔
223
                                      &record->firstKey.pks[record->firstKey.numOfPKs]));
224
  }
225

226
  for (record->lastKey.numOfPKs = 0; record->lastKey.numOfPKs < statisBlock->numOfPKs; record->lastKey.numOfPKs++) {
2,147,483,647✔
227
    TAOS_CHECK_RETURN(tValueColumnGet(&statisBlock->lastKeyPKs[record->lastKey.numOfPKs], idx,
117,444,424✔
228
                                      &record->lastKey.pks[record->lastKey.numOfPKs]));
229
  }
230

231
  return 0;
2,147,483,647✔
232
}
233

234
// SBrinRecord ----------
235
int32_t tBrinBlockInit(SBrinBlock *brinBlock) {
27,928✔
236
  int32_t code;
237

238
  brinBlock->numOfPKs = 0;
27,928✔
239
  brinBlock->numOfRecords = 0;
27,928✔
240
  for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
446,848✔
241
    tBufferInit(&brinBlock->buffers[i]);
418,920✔
242
  }
243
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
83,784✔
244
    TAOS_CHECK_GOTO(tValueColumnInit(&brinBlock->firstKeyPKs[i]), NULL, _exit);
55,856✔
245
    TAOS_CHECK_GOTO(tValueColumnInit(&brinBlock->lastKeyPKs[i]), NULL, _exit);
55,856✔
246
  }
247

248
_exit:
27,928✔
249
  if (code) {
27,928✔
250
    tBrinBlockDestroy(brinBlock);
×
251
  }
252
  return code;
27,928✔
253
}
254

255
void tBrinBlockDestroy(SBrinBlock *brinBlock) {
552,044,953✔
256
  brinBlock->numOfPKs = 0;
552,044,953✔
257
  brinBlock->numOfRecords = 0;
552,123,730✔
258
  for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
2,147,483,647✔
259
    tBufferDestroy(&brinBlock->buffers[i]);
2,147,483,647✔
260
  }
261
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
1,656,400,222✔
262
    tValueColumnDestroy(&brinBlock->firstKeyPKs[i]);
1,104,210,052✔
263
    tValueColumnDestroy(&brinBlock->lastKeyPKs[i]);
1,104,256,957✔
264
  }
265
}
552,190,170✔
266

267
void tBrinBlockClear(SBrinBlock *brinBlock) {
50,754,234✔
268
  brinBlock->numOfPKs = 0;
50,754,234✔
269
  brinBlock->numOfRecords = 0;
50,763,152✔
270
  for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
811,808,418✔
271
    tBufferClear(&brinBlock->buffers[i]);
761,037,710✔
272
  }
273
  for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
152,285,902✔
274
    tValueColumnClear(&brinBlock->firstKeyPKs[i]);
101,522,490✔
275
    tValueColumnClear(&brinBlock->lastKeyPKs[i]);
101,516,293✔
276
  }
277
}
50,763,412✔
278

279
int32_t tBrinBlockPut(SBrinBlock *brinBlock, const SBrinRecord *record) {
51,090,728✔
280
  if (record->firstKey.key.numOfPKs != record->lastKey.key.numOfPKs) {
51,090,728✔
281
    return TSDB_CODE_INVALID_PARA;
×
282
  }
283

284
  if (brinBlock->numOfRecords == 0) {  // the first row
51,090,500✔
285
    brinBlock->numOfPKs = record->firstKey.key.numOfPKs;
820,180✔
286
  } else if (brinBlock->numOfPKs != record->firstKey.key.numOfPKs) {
50,272,477✔
287
    // if the number of primary keys are not the same,
288
    // return an error code and the caller should handle it
289
    return TSDB_CODE_INVALID_PARA;
×
290
  } else {
291
    for (int i = 0; i < brinBlock->numOfPKs; i++) {
50,331,635✔
292
      if (record->firstKey.key.pks[i].type != brinBlock->firstKeyPKs[i].type) {
58,555✔
293
        return TSDB_CODE_INVALID_PARA;
×
294
      }
295
    }
296
  }
297

298
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->suids, record->suid));
102,180,875✔
299
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->uids, record->uid));
102,180,721✔
300
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->firstKeyTimestamps, record->firstKey.key.ts));
102,181,656✔
301
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->firstKeyVersions, record->firstKey.version));
102,180,182✔
302
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->lastKeyTimestamps, record->lastKey.key.ts));
102,177,923✔
303
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->lastKeyVersions, record->lastKey.version));
102,176,053✔
304
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->minVers, record->minVer));
102,174,197✔
305
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->maxVers, record->maxVer));
102,172,440✔
306
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->blockOffsets, record->blockOffset));
102,175,500✔
307
  TAOS_CHECK_RETURN(tBufferPutI64(&brinBlock->smaOffsets, record->smaOffset));
102,177,646✔
308
  TAOS_CHECK_RETURN(tBufferPutI32(&brinBlock->blockSizes, record->blockSize));
102,177,129✔
309
  TAOS_CHECK_RETURN(tBufferPutI32(&brinBlock->blockKeySizes, record->blockKeySize));
102,175,355✔
310
  TAOS_CHECK_RETURN(tBufferPutI32(&brinBlock->smaSizes, record->smaSize));
102,169,899✔
311
  TAOS_CHECK_RETURN(tBufferPutI32(&brinBlock->numRows, record->numRow));
102,169,181✔
312
  TAOS_CHECK_RETURN(tBufferPutI32(&brinBlock->counts, record->count));
102,175,478✔
313

314
  if (brinBlock->numOfPKs > 0) {
51,089,548✔
315
    for (int32_t i = 0; i < brinBlock->numOfPKs; ++i) {
125,154✔
316
      TAOS_CHECK_RETURN(tValueColumnAppend(&brinBlock->firstKeyPKs[i], &record->firstKey.key.pks[i]));
62,577✔
317
    }
318

319
    for (int32_t i = 0; i < brinBlock->numOfPKs; ++i) {
125,154✔
320
      TAOS_CHECK_RETURN(tValueColumnAppend(&brinBlock->lastKeyPKs[i], &record->lastKey.key.pks[i]));
62,577✔
321
    }
322
  }
323

324
  brinBlock->numOfRecords++;
51,089,153✔
325

326
  return 0;
51,089,945✔
327
}
328

329
int32_t tBrinBlockGet(SBrinBlock *brinBlock, int32_t idx, SBrinRecord *record) {
955,810,085✔
330
  SBufferReader reader;
955,810,085✔
331

332
  if (idx < 0 || idx >= brinBlock->numOfRecords) {
955,962,686✔
333
    return TSDB_CODE_OUT_OF_RANGE;
×
334
  }
335

336
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->suids);
956,050,141✔
337
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->suid));
956,375,383✔
338

339
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->uids);
956,094,284✔
340
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->uid));
956,128,909✔
341

342
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->firstKeyTimestamps);
955,780,413✔
343
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->firstKey.key.ts));
955,788,299✔
344

345
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->firstKeyVersions);
955,329,206✔
346
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->firstKey.version));
955,311,934✔
347

348
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->lastKeyTimestamps);
955,389,283✔
349
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->lastKey.key.ts));
955,326,475✔
350

351
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->lastKeyVersions);
955,484,473✔
352
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->lastKey.version));
955,430,261✔
353

354
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->minVers);
955,432,964✔
355
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->minVer));
955,417,724✔
356

357
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->maxVers);
955,628,697✔
358
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->maxVer));
955,779,077✔
359

360
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->blockOffsets);
955,156,863✔
361
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->blockOffset));
955,534,944✔
362

363
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->smaOffsets);
955,776,603✔
364
  TAOS_CHECK_RETURN(tBufferGetI64(&reader, &record->smaOffset));
955,809,319✔
365

366
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->blockSizes);
955,652,722✔
367
  TAOS_CHECK_RETURN(tBufferGetI32(&reader, &record->blockSize));
955,478,547✔
368

369
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->blockKeySizes);
955,900,986✔
370
  TAOS_CHECK_RETURN(tBufferGetI32(&reader, &record->blockKeySize));
955,914,266✔
371

372
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->smaSizes);
955,706,469✔
373
  TAOS_CHECK_RETURN(tBufferGetI32(&reader, &record->smaSize));
955,634,876✔
374

375
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->numRows);
955,614,274✔
376
  TAOS_CHECK_RETURN(tBufferGetI32(&reader, &record->numRow));
955,532,216✔
377

378
  reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->counts);
955,739,334✔
379
  TAOS_CHECK_RETURN(tBufferGetI32(&reader, &record->count));
955,684,469✔
380

381
  // primary keys
382
  for (record->firstKey.key.numOfPKs = 0; record->firstKey.key.numOfPKs < brinBlock->numOfPKs;
955,965,777✔
383
       record->firstKey.key.numOfPKs++) {
191,240✔
384
    TAOS_CHECK_RETURN(tValueColumnGet(&brinBlock->firstKeyPKs[record->firstKey.key.numOfPKs], idx,
191,240✔
385
                                      &record->firstKey.key.pks[record->firstKey.key.numOfPKs]));
386
  }
387

388
  for (record->lastKey.key.numOfPKs = 0; record->lastKey.key.numOfPKs < brinBlock->numOfPKs;
956,137,416✔
389
       record->lastKey.key.numOfPKs++) {
191,240✔
390
    TAOS_CHECK_RETURN(tValueColumnGet(&brinBlock->lastKeyPKs[record->lastKey.key.numOfPKs], idx,
191,240✔
391
                                      &record->lastKey.key.pks[record->lastKey.key.numOfPKs]));
392
  }
393

394
  return 0;
955,966,974✔
395
}
396

397
// other apis ----------
398
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb) {
79,460,252✔
399
  if (tbid->suid) {
79,460,252✔
400
    if (pSkmTb->suid == tbid->suid) {
72,155,143✔
401
      pSkmTb->uid = tbid->uid;
51,328,341✔
402
      return 0;
51,329,793✔
403
    }
404
  } else if (pSkmTb->uid == tbid->uid) {
7,319,131✔
405
    return 0;
350,330✔
406
  }
407

408
  pSkmTb->suid = tbid->suid;
27,811,549✔
409
  pSkmTb->uid = tbid->uid;
27,811,629✔
410
  tDestroyTSchema(pSkmTb->pTSchema);
27,803,443✔
411
  return metaGetTbTSchemaEx(pTsdb->pVnode->pMeta, tbid->suid, tbid->uid, -1, &pSkmTb->pTSchema);
27,811,518✔
412
}
413

414
int32_t tsdbUpdateSkmRow(STsdb *pTsdb, const TABLEID *tbid, int32_t sver, SSkmInfo *pSkmRow) {
2,147,483,647✔
415
  if (pSkmRow->pTSchema && pSkmRow->suid == tbid->suid) {
2,147,483,647✔
416
    if (pSkmRow->suid) {
2,147,483,647✔
417
      if (sver == pSkmRow->pTSchema->version) return 0;
2,147,483,647✔
418
    } else if (pSkmRow->uid == tbid->uid && pSkmRow->pTSchema->version == sver) {
2,147,483,647✔
419
      return 0;
2,147,483,647✔
420
    }
421
  }
422

423
  pSkmRow->suid = tbid->suid;
21,794,840✔
424
  pSkmRow->uid = tbid->uid;
27,045,838✔
425
  tDestroyTSchema(pSkmRow->pTSchema);
27,045,996✔
426
  return metaGetTbTSchemaEx(pTsdb->pVnode->pMeta, tbid->suid, tbid->uid, sver, &pSkmRow->pTSchema);
27,042,901✔
427
}
428
int32_t tsdbUpdateColCmprObj(STsdb *pTsdb, const TABLEID *tbid, SHashObj **ppColCmpr) { return 0; }
×
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