Skip to content

Commit c0b4a35

Browse files
authored
DPL Analysis: make sure all supported types can be used in vector columns (#7796)
1 parent 7981a12 commit c0b4a35

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

Framework/Core/include/Framework/ArrowTypes.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,26 @@ struct arrow_array_for<double[N]> {
7777
using type = arrow::FixedSizeListArray;
7878
using value_type = double;
7979
};
80-
template <>
81-
struct arrow_array_for<std::vector<int>> {
82-
using type = arrow::ListArray;
83-
using value_type = int;
84-
};
85-
template <>
86-
struct arrow_array_for<std::vector<float>> {
87-
using type = arrow::ListArray;
88-
using value_type = float;
89-
};
90-
template <>
91-
struct arrow_array_for<std::vector<double>> {
92-
using type = arrow::ListArray;
93-
using value_type = double;
94-
};
80+
81+
#define ARROW_VECTOR_FOR(_type_) \
82+
template <> \
83+
struct arrow_array_for<std::vector<_type_>> { \
84+
using type = arrow::ListArray; \
85+
using value_type = _type_; \
86+
};
87+
88+
ARROW_VECTOR_FOR(uint8_t);
89+
ARROW_VECTOR_FOR(uint16_t);
90+
ARROW_VECTOR_FOR(uint32_t);
91+
ARROW_VECTOR_FOR(uint64_t);
92+
93+
ARROW_VECTOR_FOR(int8_t);
94+
ARROW_VECTOR_FOR(int16_t);
95+
ARROW_VECTOR_FOR(int32_t);
96+
ARROW_VECTOR_FOR(int64_t);
97+
98+
ARROW_VECTOR_FOR(float);
99+
ARROW_VECTOR_FOR(double);
95100

96101
template <typename T>
97102
using arrow_array_for_t = typename arrow_array_for<T>::type;

Framework/Core/test/test_TreeToTable.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ namespace cols
166166
DECLARE_SOA_COLUMN(Ivec, ivec, std::vector<int>);
167167
DECLARE_SOA_COLUMN(Fvec, fvec, std::vector<float>);
168168
DECLARE_SOA_COLUMN(Dvec, dvec, std::vector<double>);
169+
DECLARE_SOA_COLUMN(UIvec, uivec, std::vector<uint8_t>);
169170
} // namespace cols
170171

171-
DECLARE_SOA_TABLE(Vectors, "AOD", "VECS", o2::soa::Index<>, cols::Ivec, cols::Fvec, cols::Dvec);
172+
DECLARE_SOA_TABLE(Vectors, "AOD", "VECS", o2::soa::Index<>, cols::Ivec, cols::Fvec, cols::Dvec, cols::UIvec);
172173
} // namespace o2::aod
173174

174175
BOOST_AUTO_TEST_CASE(VariableLists)
@@ -178,16 +179,19 @@ BOOST_AUTO_TEST_CASE(VariableLists)
178179
std::vector<int> iv;
179180
std::vector<float> fv;
180181
std::vector<double> dv;
182+
std::vector<uint8_t> ui;
181183
for (auto i = 1; i < 11; ++i) {
182184
iv.clear();
183185
fv.clear();
184186
dv.clear();
187+
ui.clear();
185188
for (auto j = 0; j < i; ++j) {
186189
iv.push_back(j + 2);
187190
fv.push_back((j + 2) * 0.2134f);
188191
dv.push_back((j + 4) * 0.192873819237);
192+
ui.push_back(j);
189193
}
190-
writer(0, iv, fv, dv);
194+
writer(0, iv, fv, dv, ui);
191195
}
192196
auto table = b.finalize();
193197

@@ -209,10 +213,12 @@ BOOST_AUTO_TEST_CASE(VariableLists)
209213
auto iv = row.ivec();
210214
auto fv = row.fvec();
211215
auto dv = row.dvec();
216+
auto uv = row.uivec();
212217
for (auto j = 0; j < i; ++j) {
213218
BOOST_CHECK_EQUAL(iv[j], j + 2);
214219
BOOST_CHECK_EQUAL(fv[j], (j + 2) * 0.2134f);
215220
BOOST_CHECK_EQUAL(dv[j], (j + 4) * 0.192873819237);
221+
BOOST_CHECK_EQUAL(uv[j], j);
216222
}
217223
++i;
218224
}

0 commit comments

Comments
 (0)