MCPcopy Create free account
hub / github.com/apache/impala / BuiltinAdd

Function BuiltinAdd

be/src/benchmarks/overflow-benchmark.cc:144–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142#define HAVE_BUILTIN_ADD_OVERFLOW
143template<typename RESULT_T>
144DecimalValue<RESULT_T> BuiltinAdd(const Decimal16Value& val, int this_scale,
145 const Decimal16Value& other, int other_scale, int result_precision, int result_scale,
146 bool* overflow) {
147 DCHECK_EQ(result_scale, std::max(this_scale, other_scale));
148 RESULT_T x = 0;
149 RESULT_T y = 0;
150 *overflow |= AdjustToSameScale(val, this_scale, other, other_scale,
151 result_precision, &x, &y);
152 if (sizeof(RESULT_T) == 16 && result_precision == ColumnType::MAX_PRECISION) {
153 RESULT_T result = 0;
154 *overflow |= __builtin_add_overflow(x, y, &result);
155 *overflow |= abs(result) > MAX_UNSCALED_DECIMAL16;
156 return DecimalValue<RESULT_T>(result);
157 } else {
158 DCHECK(!*overflow) << "Cannot overflow unless result is Decimal16Value";
159 }
160 return DecimalValue<RESULT_T>(x + y);
161}
162#endif
163
164template<typename RESULT_T>

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
AdjustToSameScaleFunction · 0.85
absFunction · 0.85

Tested by

no test coverage detected