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

Function AdjustToSameScale

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

Source from the content-addressed store, hash-verified

94
95template <typename RESULT_T>
96static bool AdjustToSameScale(const Decimal16Value& x, int x_scale,
97 const Decimal16Value& y, int y_scale, int result_precision, RESULT_T* x_scaled,
98 RESULT_T* y_scaled) {
99 int delta_scale = x_scale - y_scale;
100 RESULT_T scale_factor = DecimalUtil::GetScaleMultiplier<RESULT_T>(abs(delta_scale));
101 if (delta_scale == 0) {
102 *x_scaled = x.value();
103 *y_scaled = y.value();
104 } else if (delta_scale > 0) {
105 if (sizeof(RESULT_T) == 16 && result_precision == ColumnType::MAX_PRECISION &&
106 MAX_UNSCALED_DECIMAL16 / scale_factor < abs(y.value())) {
107 return true;
108 }
109 *x_scaled = x.value();
110 *y_scaled = y.value() * scale_factor;
111 } else {
112 if (sizeof(RESULT_T) == 16 && result_precision == ColumnType::MAX_PRECISION &&
113 MAX_UNSCALED_DECIMAL16 / scale_factor < abs(x.value())) {
114 return true;
115 }
116 *x_scaled = x.value() * scale_factor;
117 *y_scaled = y.value();
118 }
119 return false;
120}
121
122// Accelerate using lookup table.
123template <typename RESULT_T>

Callers 5

AddMethod · 0.85
ModMethod · 0.85
CompareMethod · 0.85
BuiltinAddFunction · 0.85
AddFunction · 0.85

Calls 2

absFunction · 0.85
valueMethod · 0.45

Tested by

no test coverage detected