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

taosdata / TDengine / #5067

17 May 2026 01:15AM UTC coverage: 73.401% (+0.008%) from 73.393%
#5067

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)

281709 of 383795 relevant lines covered (73.4%)

134707409.01 hits per line

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

86.25
/source/dnode/vnode/src/vnd/vnodeHash.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 "vnodeHash.h"
17

18
#define VNODE_HASH_DEFAULT_NUM_BUCKETS 1024
19

20
typedef struct SVHashEntry SVHashEntry;
21

22
struct SVHashEntry {
23
  SVHashEntry* next;
24
  void*        obj;
25
};
26

27
static void vHashRehash(SVHashTable* ht, uint32_t newNumBuckets) {
14,000✔
28
  SVHashEntry** newBuckets = (SVHashEntry**)taosMemoryCalloc(newNumBuckets, sizeof(SVHashEntry*));
14,000✔
29
  if (newBuckets == NULL) {
14,000✔
30
    return;
×
31
  }
32

33
  for (int32_t i = 0; i < ht->numBuckets; i++) {
21,518,000✔
34
    SVHashEntry* entry = ht->buckets[i];
21,504,000✔
35
    while (entry != NULL) {
32,249,000✔
36
      SVHashEntry* next = entry->next;
10,745,000✔
37
      uint32_t     bucketIndex = ht->hash(entry->obj) % newNumBuckets;
10,745,000✔
38
      entry->next = newBuckets[bucketIndex];
10,745,000✔
39
      newBuckets[bucketIndex] = entry;
10,745,000✔
40
      entry = next;
10,745,000✔
41
    }
42
  }
43

44
  taosMemoryFree(ht->buckets);
14,000✔
45
  ht->buckets = newBuckets;
14,000✔
46
  ht->numBuckets = newNumBuckets;
14,000✔
47

48
  return;
14,000✔
49
}
50

51
int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*)) {
10,520,052✔
52
  if (ht == NULL || hash == NULL || compare == NULL) {
10,520,052✔
53
    return TSDB_CODE_INVALID_PARA;
36✔
54
  }
55

56
  (*ht) = (SVHashTable*)taosMemoryMalloc(sizeof(SVHashTable));
10,520,016✔
57
  if (*ht == NULL) {
10,520,052✔
58
    return terrno;
×
59
  }
60

61
  (*ht)->hash = hash;
10,520,052✔
62
  (*ht)->compare = compare;
10,520,052✔
63
  (*ht)->numEntries = 0;
10,520,427✔
64
  (*ht)->numBuckets = VNODE_HASH_DEFAULT_NUM_BUCKETS;
10,519,688✔
65
  (*ht)->buckets = (SVHashEntry**)taosMemoryCalloc((*ht)->numBuckets, sizeof(SVHashEntry*));
10,520,052✔
66
  if ((*ht)->buckets == NULL) {
10,520,427✔
67
    taosMemoryFree(*ht);
×
68
    return terrno;
×
69
  }
70

71
  return 0;
10,520,427✔
72
}
73

74
void vHashDestroy(SVHashTable** ht) {
10,520,427✔
75
  if (ht == NULL) {
10,520,427✔
76
    return;
×
77
  }
78

79
  if (*ht) {
10,520,427✔
80
    taosMemoryFree((*ht)->buckets);
10,520,427✔
81
    taosMemoryFree(*ht);
10,519,765✔
82
    (*ht) = NULL;
10,519,765✔
83
  }
84
}
85

86
int32_t vHashPut(SVHashTable* ht, void* obj) {
24,705,753✔
87
  if (ht == NULL || obj == NULL) {
24,705,753✔
88
    return TSDB_CODE_INVALID_PARA;
×
89
  }
90

91
  uint32_t bucketIndex = ht->hash(obj) % ht->numBuckets;
24,706,129✔
92
  for (SVHashEntry* entry = ht->buckets[bucketIndex]; entry != NULL; entry = entry->next) {
31,393,677✔
93
    if (ht->compare(entry->obj, obj) == 0) {
6,688,009✔
94
      return TSDB_CODE_DUP_KEY;
×
95
    }
96
  }
97

98
  if (ht->numEntries >= ht->numBuckets) {
24,704,307✔
99
    vHashRehash(ht, ht->numBuckets * 2);
7,000✔
100
    bucketIndex = ht->hash(obj) % ht->numBuckets;
7,000✔
101
  }
102

103
  SVHashEntry* entry = (SVHashEntry*)taosMemoryMalloc(sizeof(SVHashEntry));
24,705,668✔
104
  if (entry == NULL) {
24,705,057✔
105
    return terrno;
×
106
  }
107
  entry->obj = obj;
24,705,057✔
108
  entry->next = ht->buckets[bucketIndex];
24,704,837✔
109
  ht->buckets[bucketIndex] = entry;
24,704,045✔
110
  ht->numEntries++;
24,705,087✔
111

112
  return 0;
24,704,629✔
113
}
114

115
int32_t vHashGet(SVHashTable* ht, const void* obj, void** retObj) {
112,617,775✔
116
  if (ht == NULL || obj == NULL || retObj == NULL) {
112,617,775✔
117
    return TSDB_CODE_INVALID_PARA;
×
118
  }
119

120
  uint32_t bucketIndex = ht->hash(obj) % ht->numBuckets;
112,623,943✔
121
  for (SVHashEntry* entry = ht->buckets[bucketIndex]; entry != NULL; entry = entry->next) {
126,558,272✔
122
    if (ht->compare(entry->obj, obj) == 0) {
102,742,582✔
123
      *retObj = entry->obj;
88,786,679✔
124
      return 0;
88,788,290✔
125
    }
126
  }
127

128
  *retObj = NULL;
23,816,750✔
129
  return TSDB_CODE_NOT_FOUND;
23,816,919✔
130
}
131

132
int32_t vHashDrop(SVHashTable* ht, const void* obj) {
24,706,129✔
133
  if (ht == NULL || obj == NULL) {
24,706,129✔
134
    return TSDB_CODE_INVALID_PARA;
×
135
  }
136

137
  uint32_t bucketIndex = ht->hash(obj) % ht->numBuckets;
24,706,129✔
138
  for (SVHashEntry** entry = &ht->buckets[bucketIndex]; *entry != NULL; entry = &(*entry)->next) {
27,548,143✔
139
    if (ht->compare((*entry)->obj, obj) == 0) {
27,548,143✔
140
      SVHashEntry* tmp = *entry;
24,705,467✔
141
      *entry = (*entry)->next;
24,706,129✔
142
      taosMemoryFree(tmp);
24,706,129✔
143
      ht->numEntries--;
24,706,129✔
144
      if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) {
24,706,129✔
145
        vHashRehash(ht, ht->numBuckets / 2);
7,000✔
146
      }
147
      return 0;
24,706,129✔
148
    }
149
  }
150

151
  return TSDB_CODE_NOT_FOUND;
×
152
}
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