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

taosdata / TDengine / #4821

22 Oct 2025 06:02AM UTC coverage: 61.242% (-0.1%) from 61.353%
#4821

push

travis-ci

web-flow
Merge pull request #33334 from taosdata/3.0

fix(stream): reset tableScan operator (#33225)

156089 of 324573 branches covered (48.09%)

Branch coverage included in aggregate %.

184 of 244 new or added lines in 9 files covered. (75.41%)

789 existing lines in 124 files now uncovered.

207891 of 269759 relevant lines covered (77.07%)

244003752.29 hits per line

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

43.3
/source/libs/decimal/src/detail/wideInteger.cpp
1
#include "wideInteger.h"
2
#include "intx/int128.hpp"
3
#include "intx/intx.hpp"
4

5

6
const UInt128  uInt128Zero = {0, 0};
7
const uint64_t k1e18 = 1000000000000000000LL;
8
const UInt128  uInt128_1e18 = {k1e18, 0};
9
const UInt128 uInt128One = {1, 0};
10
const UInt128 uInt128Two = {2, 0};
11

12
void makeUInt128(uint128* pUint128, uint64_t high, uint64_t low) {
2,147,483,647✔
13
  intx::uint128* pIntxUint = (intx::uint128*)pUint128;
2,147,483,647✔
14
  pIntxUint->hi = high;
2,147,483,647✔
15
  pIntxUint->lo = low;
2,147,483,647✔
16
}
2,147,483,647✔
17

18
uint64_t uInt128Hi(const UInt128* pInt) {
2,147,483,647✔
19
  intx::uint128 *pIntUint = (intx::uint128*)pInt;
2,147,483,647✔
20
  return pIntUint->hi;
2,147,483,647✔
21
}
22

23
uint64_t uInt128Lo(const UInt128* pInt) {
2,147,483,647✔
24
  intx::uint128 *pIntUint = (intx::uint128*)pInt;
2,147,483,647✔
25
  return pIntUint->lo;
2,147,483,647✔
26
}
27

28
void uInt128Add(UInt128* pLeft, const UInt128* pRight) {
×
29
  intx::uint128 *pX = (intx::uint128*)pLeft;
×
30
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
31
  *pX += *pY;
×
32
}
×
33
void uInt128Subtract(UInt128* pLeft, const UInt128* pRight) {
×
34
  intx::uint128 *pX = (intx::uint128*)pLeft;
×
35
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
36
  *pX -= *pY;
×
37
}
×
38
void uInt128Multiply(UInt128* pLeft, const UInt128* pRight) {
2,147,483,647✔
39
  intx::uint128 *pX = (intx::uint128*)pLeft;
2,147,483,647✔
40
  const intx::uint128 *pY = (const intx::uint128*)pRight;
2,147,483,647✔
41
  *pX *= *pY;
2,147,483,647✔
42
  /* __uint128_t *px = (__uint128_t*)pLeft;
43
  const __uint128_t *py = (__uint128_t*)pRight;
44
  *px = *px * *py; */
45
}
2,147,483,647✔
46
void uInt128Divide(UInt128* pLeft, const UInt128* pRight) {
2,147,483,647✔
47
  intx::uint128 *pX = (intx::uint128*)pLeft;
2,147,483,647✔
48
  const intx::uint128 *pY = (const intx::uint128*)pRight;
2,147,483,647✔
49
  *pX /= *pY;
2,147,483,647✔
50
  /* __uint128_t *px = (__uint128_t*)pLeft;
51
  const __uint128_t *py = (__uint128_t*)pRight;
52
  *px = *px / *py; */
53
}
2,147,483,647✔
54
void uInt128Mod(UInt128* pLeft, const UInt128* pRight) {
2,147,483,647✔
55
  intx::uint128 *pX = (intx::uint128*)pLeft;
2,147,483,647✔
56
  const intx::uint128 *pY = (const intx::uint128*)pRight;
2,147,483,647✔
57
  *pX %= *pY;
2,147,483,647✔
58
  /* __uint128_t *px = (__uint128_t*)pLeft;
59
  const __uint128_t *py = (__uint128_t*)pRight;
60
  *px = *px % *py; */
61
}
2,147,483,647✔
62
bool uInt128Lt(const UInt128* pLeft, const UInt128* pRight) {
4,891✔
63
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
4,891✔
64
  const intx::uint128 *pY = (const intx::uint128*)pRight;
4,891✔
65
  return *pX < *pY;
4,891✔
66
}
67
bool uInt128Gt(const UInt128* pLeft, const UInt128* pRight) {
×
68
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
×
69
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
70
  return *pX > *pY;
×
71
}
72
bool uInt128Eq(const UInt128* pLeft, const UInt128* pRight) {
2,147,483,647✔
73
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
2,147,483,647✔
74
  const intx::uint128 *pY = (const intx::uint128*)pRight;
2,147,483,647✔
75
  return *pX == *pY;
2,147,483,647✔
76
}
77

78
Int128 makeInt128(int64_t high, uint64_t low) {
×
79
  Int128 int128 = {low, high};
×
80
  return int128;
×
81
}
82
int64_t int128Hi(const Int128* pUint128) {
×
83
  return pUint128->high;
×
84
}
85
uint64_t int128Lo(const Int128* pUint128) {
×
86
  return pUint128->low;
×
87
}
88
Int128 int128Abs(const Int128* pInt128) {
×
89
  if (int128Lt(pInt128, &int128Zero)) {
×
90
    return int128Negate(pInt128);
×
91
  }
92
  return *pInt128;
×
93
}
94
Int128 int128Negate(const Int128* pInt128) {
×
95
  uint64_t low = ~pInt128->low + 1;
×
96
  int64_t  high = ~pInt128->high;
×
97
  if (low == 0) high += 1;
×
98
  return makeInt128(high, low);
×
99
}
100
Int128 int128Add(const Int128* pLeft, const Int128* pRight) {
×
101
  intx::uint128 result = *(intx::uint128*)pLeft + *(intx::uint128*)pRight;
×
102
  return *(Int128*)&result;
×
103
}
104
Int128 int128Subtract(const Int128* pLeft, const Int128* pRight) {
×
105
  intx::uint128 result = *(intx::uint128*)pLeft - *(intx::uint128*)pRight;
×
106
  return *(Int128*)&result;
×
107
}
108
Int128 int128Multiply(const Int128* pLeft, const Int128* pRight) {
×
109
  intx::uint128 result = *(intx::uint128*)pLeft * *(intx::uint128*)pRight;
×
110
  return *(Int128*)&result;
×
111
}
112
Int128 int128Divide(const Int128* pLeft, const Int128* pRight) {
×
113
  intx::uint128 result = *(intx::uint128*)pLeft / *(intx::uint128*)pRight;
×
114
  return *(Int128*)&result;
×
115
}
116
Int128 int128Mod(const Int128* pLeft, const Int128* pRight) {
×
117
  intx::uint128 result = *(intx::uint128*)pLeft % *(intx::uint128*)pRight;
×
118
  return *(Int128*)&result;
×
119
}
120
bool int128Lt(const Int128* pLeft, const Int128* pRight) {
6,059✔
121
  return pLeft->high < pRight->high || (pLeft->high == pRight->high && pLeft->low < pRight->low);
6,059!
122
}
123
bool int128Gt(const Int128* pLeft, const Int128* pRight) {
×
124
  return int128Lt(pRight, pLeft);
×
125
}
126
bool int128Eq(const Int128* pLeft, const Int128* pRight) {
5,986✔
127
  return pLeft->high == pRight->high && pLeft->low == pRight->low;
5,986!
128
}
129
Int128 int128RightShift(const Int128* pLeft, int32_t shift) {
×
130
  intx::uint128 result = *(intx::uint128*)pLeft >> shift;
×
131
  return *(Int128*)&result;
×
132
}
133

134
const Int128 int128Zero = {0, 0};
135
const Int128 int128One = {1, 0};
136

137
UInt256 makeUint256(UInt128 high, UInt128 low) {
×
138
  UInt256 uint256 = {high, low};
×
139
  return uint256;
×
140
}
141
uint128 uInt256Hi(const UInt256* pUint256) {
×
142
  return pUint256->high;
×
143
}
144
uint128 uInt256Lo(const UInt256* pUint256) {
×
145
  return pUint256->low;
×
146
}
147
UInt256 uInt256Add(const UInt256* pLeft, const UInt256* pRight) {
×
148
  intx::uint256 result = *(intx::uint256*)pLeft + *(intx::uint256*)pRight;
×
149
  return *(UInt256*)&result;
×
150
}
151
UInt256 uInt256Subtract(const UInt256* pLeft, const UInt256* pRight) {
×
152
  intx::uint256 result = *(intx::uint256*)pLeft - *(intx::uint256*)pRight;
×
153
  return *(UInt256*)&result;
×
154
}
155
UInt256 uInt256Multiply(const UInt256* pLeft, const UInt256* pRight) {
×
156
  intx::uint256 result = *(intx::uint256*)pLeft * *(intx::uint256*)pRight;
×
157
  return *(UInt256*)&result;
×
158
}
159
UInt256 uInt256Divide(const UInt256* pLeft, const UInt256* pRight) {
×
160
  intx::uint256 result = *(intx::uint256*)pLeft / *(intx::uint256*)pRight;
×
161
  return *(UInt256*)&result;
×
162
}
163
UInt256 uInt256Mod(const UInt256* pLeft, const UInt256* pRight) {
×
164
  intx::uint256 result = *(intx::uint256*)pLeft % *(intx::uint256*)pRight;
×
165
  return *(UInt256*)&result;
×
166
}
167
bool uInt256Lt(const UInt256* pLeft, const UInt256* pRight) {
×
168
  return *(intx::uint256*)pLeft < *(intx::uint256*)pRight;
×
169
}
170
bool uInt256Gt(const UInt256* pLeft, const UInt256* pRight) {
×
171
  return *(intx::uint256*)pLeft > *(intx::uint256*)pRight;
×
172
}
173
bool uInt256Eq(const UInt256* pLeft, const UInt256* pRight) {
×
174
  return *(intx::uint256*)pLeft == *(intx::uint256*)pRight;
×
175
}
176
UInt256 uInt256RightShift(const UInt256* pLeft, int32_t shift) {
×
177
  intx::uint256 result = *(intx::uint256*)pLeft >> shift;
×
178
  return *(UInt256*)&result;
×
179
}
180

181
Int256 makeInt256(Int128 high, UInt128 low) {
2,628✔
182
  Int256 int256 = {low, high};
2,628✔
183
  return int256;
2,628✔
184
}
185
Int128 int256Hi(const Int256* pUint256) {
12,118✔
186
  return pUint256->high;
12,118✔
187
}
188
UInt128 int256Lo(const Int256* pUint256) {
12,775✔
189
  return pUint256->low;
12,775✔
190
}
191
Int256 int256Abs(const Int256* pInt256) {
1,387✔
192
  if (int256Lt(pInt256, &int256Zero)) {
1,387!
UNCOV
193
    return int256Negate(pInt256);
×
194
  }
195
  return *pInt256;
1,387✔
196
}
197

UNCOV
198
Int256 int256Negate(const Int256* pInt256) {
×
UNCOV
199
  return int256Subtract(&int256Zero, pInt256);
×
200
}
201
Int256 int256Add(const Int256* pLeft, const Int256* pRight) {
73✔
202
  intx::uint256 result = *(intx::uint256*)pLeft + *(intx::uint256*)pRight;
73✔
203
  return *(Int256*)&result;
73✔
204
}
UNCOV
205
Int256 int256Subtract(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
206
  intx::uint256 result = *(intx::uint256*)pLeft - *(intx::uint256*)pRight;
×
UNCOV
207
  return *(Int256*)&result;
×
208
}
209
Int256 int256Multiply(const Int256* pLeft, const Int256* pRight) {
1,022✔
210
  intx::uint256 result = *(intx::uint256*)pLeft * *(intx::uint256*)pRight;
1,022✔
211
  return *(Int256*)&result;
1,022✔
212
}
213
Int256 int256Divide(const Int256* pLeft, const Int256* pRight) {
584✔
214
  Int256 l = *pLeft, r = *pRight;
584✔
215
  bool   leftNegative = int256Lt(pLeft, &int256Zero), rightNegative = int256Lt(pRight, &int256Zero);
584!
216
  if (leftNegative) {
584!
UNCOV
217
    l = int256Abs(pLeft);
×
218
  }
219
  if (rightNegative) {
584!
220
    r = int256Abs(pRight);
×
221
  }
222
  intx::uint256 result = *(intx::uint256*)&l / *(intx::uint256*)&r;
584✔
223
  Int256 res =  *(Int256*)&result;
584✔
224
  if (leftNegative != rightNegative)
584!
UNCOV
225
    res = int256Negate(&res);
×
226
  return res;
1,168✔
227
}
228

229
Int256 int256Mod(const Int256* pLeft, const Int256* pRight) {
657✔
230
  Int256 left = *pLeft, right = *pRight;
657✔
231
  bool leftNegative = int256Lt(pLeft, &int256Zero);
657!
232
  if (leftNegative) {
657!
UNCOV
233
    left = int256Abs(&left);
×
234
  }
235
  bool rightNegate = int256Lt(pRight, &int256Zero);
657!
236
  if (rightNegate) right = int256Abs(pRight);
657!
237
  intx::uint256 result = *(intx::uint256*)&left % *(intx::uint256*)&right;
657✔
238
  Int256 res =  *(Int256*)&result;
657✔
239
  if (leftNegative) res = int256Negate(&res);
657!
240
  return res;
1,314✔
241
}
242
bool int256Lt(const Int256* pLeft, const Int256* pRight) {
6,059✔
243
  Int128  hiLeft = int256Hi(pLeft), hiRight = int256Hi(pRight);
6,059!
244
  UInt128 lowLeft = int256Lo(pLeft), lowRight = int256Lo(pRight);
6,059!
245
  return int128Lt(&hiLeft, &hiRight) || (int128Eq(&hiLeft, &hiRight) && uInt128Lt(&lowLeft, &lowRight));
6,059!
246
}
247
bool int256Gt(const Int256* pLeft, const Int256* pRight) {
1,387✔
248
  return int256Lt(pRight, pLeft);
1,387✔
249
}
250
bool int256Eq(const Int256* pLeft, const Int256* pRight) {
×
251
  Int128  hiLeft = int256Hi(pLeft), hiRight = int256Hi(pRight);
×
252
  UInt128 lowLeft = int256Lo(pLeft), lowRight = int256Lo(pRight);
×
253
  return int128Eq(&hiLeft, &hiRight) && uInt128Eq(&lowLeft, &lowRight);
×
254
}
255
Int256 int256RightShift(const Int256* pLeft, int32_t shift) {
1,095✔
256
  intx::uint256 result = *(intx::uint256*)pLeft >> shift;
1,095✔
257
  return *(Int256*)&result;
1,095✔
258
}
259

260
const Int256 int256One = {uInt128One, int128Zero};
261
const Int256 int256Zero = {uInt128Zero, int128Zero};
262
const Int256 int256Two = {uInt128Two, int128Zero};
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