Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions Framework/Core/include/Framework/ArrowTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,26 @@ struct arrow_array_for<double[N]> {
using type = arrow::FixedSizeListArray;
using value_type = double;
};
template <>
struct arrow_array_for<std::vector<int>> {
using type = arrow::ListArray;
using value_type = int;
};
template <>
struct arrow_array_for<std::vector<float>> {
using type = arrow::ListArray;
using value_type = float;
};
template <>
struct arrow_array_for<std::vector<double>> {
using type = arrow::ListArray;
using value_type = double;
};

#define ARROW_VECTOR_FOR(_type_) \
template <> \
struct arrow_array_for<std::vector<_type_>> { \
using type = arrow::ListArray; \
using value_type = _type_; \
};

ARROW_VECTOR_FOR(uint8_t);
ARROW_VECTOR_FOR(uint16_t);
ARROW_VECTOR_FOR(uint32_t);
ARROW_VECTOR_FOR(uint64_t);

ARROW_VECTOR_FOR(int8_t);
ARROW_VECTOR_FOR(int16_t);
ARROW_VECTOR_FOR(int32_t);
ARROW_VECTOR_FOR(int64_t);

ARROW_VECTOR_FOR(float);
ARROW_VECTOR_FOR(double);

template <typename T>
using arrow_array_for_t = typename arrow_array_for<T>::type;
Expand Down
10 changes: 8 additions & 2 deletions Framework/Core/test/test_TreeToTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ namespace cols
DECLARE_SOA_COLUMN(Ivec, ivec, std::vector<int>);
DECLARE_SOA_COLUMN(Fvec, fvec, std::vector<float>);
DECLARE_SOA_COLUMN(Dvec, dvec, std::vector<double>);
DECLARE_SOA_COLUMN(UIvec, uivec, std::vector<uint8_t>);
} // namespace cols

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

BOOST_AUTO_TEST_CASE(VariableLists)
Expand All @@ -178,16 +179,19 @@ BOOST_AUTO_TEST_CASE(VariableLists)
std::vector<int> iv;
std::vector<float> fv;
std::vector<double> dv;
std::vector<uint8_t> ui;
for (auto i = 1; i < 11; ++i) {
iv.clear();
fv.clear();
dv.clear();
ui.clear();
for (auto j = 0; j < i; ++j) {
iv.push_back(j + 2);
fv.push_back((j + 2) * 0.2134f);
dv.push_back((j + 4) * 0.192873819237);
ui.push_back(j);
}
writer(0, iv, fv, dv);
writer(0, iv, fv, dv, ui);
}
auto table = b.finalize();

Expand All @@ -209,10 +213,12 @@ BOOST_AUTO_TEST_CASE(VariableLists)
auto iv = row.ivec();
auto fv = row.fvec();
auto dv = row.dvec();
auto uv = row.uivec();
for (auto j = 0; j < i; ++j) {
BOOST_CHECK_EQUAL(iv[j], j + 2);
BOOST_CHECK_EQUAL(fv[j], (j + 2) * 0.2134f);
BOOST_CHECK_EQUAL(dv[j], (j + 4) * 0.192873819237);
BOOST_CHECK_EQUAL(uv[j], j);
}
++i;
}
Expand Down