Skip to content

Commit fb60726

Browse files
committed
Replace NumericHelper
1 parent d038d96 commit fb60726

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

cpp/src/arrow/array/array_test.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,10 +2120,13 @@ void CheckSliceApproxEquals() {
21202120
ASSERT_TRUE(slice1->ApproxEquals(slice2));
21212121
}
21222122

2123+
template <typename ArrowType>
2124+
using NumericArgType = std::conditional_t<is_half_float_type<ArrowType>::value, Float16,
2125+
typename ArrowType::c_type>;
2126+
21232127
template <typename TYPE>
21242128
void CheckFloatingNanEquality() {
2125-
using V =
2126-
std::conditional_t<is_half_float_type<TYPE>::value, Float16, typename TYPE::c_type>;
2129+
using V = NumericArgType<TYPE>;
21272130
std::shared_ptr<Array> a, b;
21282131
std::shared_ptr<DataType> type = TypeTraits<TYPE>::type_singleton();
21292132

@@ -2184,8 +2187,7 @@ void CheckFloatingNanEquality() {
21842187

21852188
template <typename TYPE>
21862189
void CheckFloatingInfinityEquality() {
2187-
using V =
2188-
std::conditional_t<is_half_float_type<TYPE>::value, Float16, typename TYPE::c_type>;
2190+
using V = NumericArgType<TYPE>;
21892191
std::shared_ptr<Array> a, b;
21902192
std::shared_ptr<DataType> type = TypeTraits<TYPE>::type_singleton();
21912193

@@ -2253,8 +2255,7 @@ void CheckFloatingInfinityEquality() {
22532255

22542256
template <typename TYPE>
22552257
void CheckFloatingZeroEquality() {
2256-
using V =
2257-
std::conditional_t<is_half_float_type<TYPE>::value, Float16, typename TYPE::c_type>;
2258+
using V = NumericArgType<TYPE>;
22582259
std::shared_ptr<Array> a, b;
22592260
std::shared_ptr<DataType> type = TypeTraits<TYPE>::type_singleton();
22602261

cpp/src/arrow/scalar_test.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,9 @@ TEST(TestScalar, IdentityCast) {
203203
*/
204204
}
205205

206-
template <typename ARROW_TYPE>
207-
struct NumericHelper {
208-
using ArgType = typename ARROW_TYPE::c_type;
209-
};
210-
template <>
211-
struct NumericHelper<HalfFloatType> {
212-
using ArgType = Float16;
213-
};
206+
template <typename ArrowType>
207+
using NumericArgType = std::conditional_t<is_half_float_type<ArrowType>::value, Float16,
208+
typename ArrowType::c_type>;
214209

215210
template <typename T>
216211
class TestNumericScalar : public ::testing::Test {
@@ -224,7 +219,7 @@ using NumericArrowTypesPlusHalfFloat =
224219
TYPED_TEST_SUITE(TestNumericScalar, NumericArrowTypesPlusHalfFloat);
225220

226221
TYPED_TEST(TestNumericScalar, Basics) {
227-
using T = typename NumericHelper<TypeParam>::ArgType;
222+
using T = NumericArgType<TypeParam>;
228223
using ScalarType = typename TypeTraits<TypeParam>::ScalarType;
229224

230225
T value = static_cast<T>(1);
@@ -291,7 +286,7 @@ TYPED_TEST(TestNumericScalar, Basics) {
291286
}
292287

293288
TYPED_TEST(TestNumericScalar, Hashing) {
294-
using T = typename NumericHelper<TypeParam>::ArgType;
289+
using T = NumericArgType<TypeParam>;
295290
using ScalarType = typename TypeTraits<TypeParam>::ScalarType;
296291

297292
std::unordered_set<std::shared_ptr<Scalar>, Scalar::Hash, Scalar::PtrsEqual> set;
@@ -307,7 +302,7 @@ TYPED_TEST(TestNumericScalar, Hashing) {
307302
}
308303

309304
TYPED_TEST(TestNumericScalar, MakeScalar) {
310-
using T = typename NumericHelper<TypeParam>::ArgType;
305+
using T = NumericArgType<TypeParam>;
311306
using ScalarType = typename TypeTraits<TypeParam>::ScalarType;
312307
auto type = TypeTraits<TypeParam>::type_singleton();
313308

@@ -323,8 +318,7 @@ TYPED_TEST(TestNumericScalar, MakeScalar) {
323318
template <typename T>
324319
class TestRealScalar : public ::testing::Test {
325320
public:
326-
using ValueType =
327-
std::conditional_t<is_half_float_type<T>::value, Float16, typename T::c_type>;
321+
using ValueType = NumericArgType<T>;
328322
using ScalarType = typename TypeTraits<T>::ScalarType;
329323

330324
void SetUp() {

0 commit comments

Comments
 (0)