32
32
#include " vec/core/types.h"
33
33
#include " vec/data_types/data_type.h"
34
34
#include " vec/data_types/data_type_nullable.h"
35
- #include " vec/exec/format/format_common.h"
36
35
#include " vec/functions/function.h"
37
36
#if defined(__SSE4_1__) || defined(__aarch64__)
38
37
#include " util/sse_util.hpp"
@@ -127,7 +126,7 @@ struct IntegerRoundingComputation {
127
126
__builtin_unreachable ();
128
127
}
129
128
130
- static ALWAYS_INLINE T compute (T x, T scale, T target_scale) {
129
+ static ALWAYS_INLINE T compute (T x, T scale, size_t target_scale) {
131
130
switch (scale_mode) {
132
131
case ScaleMode::Zero:
133
132
case ScaleMode::Positive:
@@ -164,22 +163,21 @@ class DecimalRoundingImpl {
164
163
Int16 out_scale) {
165
164
Int16 scale_arg = in_scale - out_scale;
166
165
if (scale_arg > 0 ) {
167
- auto scale = DecimalScaleParams::get_scale_factor<T> (scale_arg);
166
+ size_t scale = int_exp10 (scale_arg);
168
167
169
168
const NativeType* __restrict p_in = reinterpret_cast <const NativeType*>(in.data ());
170
169
const NativeType* end_in = reinterpret_cast <const NativeType*>(in.data ()) + in.size ();
171
170
NativeType* __restrict p_out = reinterpret_cast <NativeType*>(out.data ());
172
171
173
172
if (out_scale < 0 ) {
174
- auto negative_scale = DecimalScaleParams::get_scale_factor<T>(-out_scale);
175
173
while (p_in < end_in) {
176
- *p_out = Op::compute (* p_in, scale, negative_scale );
174
+ Op::compute (p_in, scale, p_out, int_exp10 (-out_scale) );
177
175
++p_in;
178
176
++p_out;
179
177
}
180
178
} else {
181
179
while (p_in < end_in) {
182
- *p_out = Op::compute (* p_in, scale, 1 );
180
+ Op::compute (p_in, scale, p_out , 1 );
183
181
++p_in;
184
182
++p_out;
185
183
}
@@ -193,12 +191,11 @@ class DecimalRoundingImpl {
193
191
Int16 out_scale) {
194
192
Int16 scale_arg = in_scale - out_scale;
195
193
if (scale_arg > 0 ) {
196
- auto scale = DecimalScaleParams::get_scale_factor<T> (scale_arg);
194
+ size_t scale = int_exp10 (scale_arg);
197
195
if (out_scale < 0 ) {
198
- auto negative_scale = DecimalScaleParams::get_scale_factor<T>(-out_scale);
199
- out = Op::compute (in, scale, negative_scale);
196
+ Op::compute (&in, scale, &out, int_exp10 (-out_scale));
200
197
} else {
201
- out = Op::compute (in, scale, 1 );
198
+ Op::compute (& in, scale, &out , 1 );
202
199
}
203
200
} else {
204
201
memcpy (&out, &in, sizeof (NativeType));
0 commit comments