Skip to content

Commit 6bfcb7a

Browse files
committed
Further simplification and compilable code
1 parent 3d926b3 commit 6bfcb7a

File tree

2 files changed

+14
-55
lines changed

2 files changed

+14
-55
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,61 +2157,14 @@ void emptyColumnLabel();
21572157

21582158
namespace row_helpers
21592159
{
2160-
template <soa::is_persistent_column... Cs>
2161-
std::array<arrow::ChunkedArray*, sizeof...(Cs)> getArrowColumns(arrow::Table* table, framework::pack<Cs...>)
2162-
{
2163-
return std::array<arrow::ChunkedArray*, sizeof...(Cs)>{o2::soa::getIndexFromLabel(table, Cs::columnLabel())...};
2164-
}
2165-
2166-
template <soa::is_persistent_column... Cs>
2167-
std::array<std::shared_ptr<arrow::Array>, sizeof...(Cs)> getChunks(arrow::Table* table, framework::pack<Cs...>, uint64_t ci)
2168-
{
2169-
return std::array<std::shared_ptr<arrow::Array>, sizeof...(Cs)>{o2::soa::getIndexFromLabel(table, Cs::columnLabel())->chunk(ci)...};
2170-
}
2171-
2172-
template <typename T, soa::is_persistent_column C>
2173-
typename C::type getSingleRowData(arrow::Table* table, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2174-
{
2175-
if (ci == std::numeric_limits<uint64_t>::max() || ai == std::numeric_limits<uint64_t>::max()) {
2176-
auto colIterator = static_cast<C>(rowIterator).getIterator();
2177-
ci = colIterator.mCurrentChunk;
2178-
ai = *(colIterator.mCurrentPos) - colIterator.mFirstIndex;
2179-
}
2180-
return std::static_pointer_cast<o2::soa::arrow_array_for_t<typename C::type>>(o2::soa::getIndexFromLabel(table, C::columnLabel())->chunk(ci))->raw_values()[ai];
2181-
}
2182-
2183-
template <typename T, soa::is_dynamic_column C>
2184-
typename C::type getSingleRowData(arrow::Table*, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2185-
{
2186-
if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2187-
rowIterator.setCursor(globalIndex);
2188-
}
2189-
return rowIterator.template getDynamicColumn<C>();
2190-
}
2191-
2192-
template <typename T, soa::is_index_column C>
2193-
typename C::type getSingleRowData(arrow::Table*, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2194-
{
2195-
if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2196-
rowIterator.setCursor(globalIndex);
2197-
}
2198-
return rowIterator.template getId<C>();
2199-
}
2200-
2201-
template <typename T, typename... Cs>
2202-
std::tuple<typename Cs::type...> getRowData(arrow::Table* table, T rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2203-
{
2204-
return std::make_tuple(getSingleRowData<T, Cs>(table, rowIterator, ci, ai, globalIndex)...);
2205-
}
2206-
2207-
namespace
2208-
{
22092160
template <typename R, typename T, typename C>
22102161
R getColumnValue(const T& rowIterator)
22112162
{
22122163
return static_cast<R>(static_cast<C>(rowIterator).get());
22132164
}
22142165

2166+
namespace
2167+
{
22152168
template <typename R, typename T>
22162169
using ColumnGetterFunction = R (*)(const T&);
22172170

Framework/Core/include/Framework/BinningPolicy.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ struct FlexibleBinningPolicy<std::tuple<Ls...>, Ts...> : BinningPolicyBase<sizeo
243243
template <typename T, typename T2>
244244
auto getBinningValue(T& rowIterator, uint64_t globalIndex = -1) const
245245
{
246+
if (globalIndex != -1) {
247+
rowIterator.setCursor(globalIndex);
248+
}
246249
if constexpr (has_type<T2>(pack<Ls...>{})) {
247-
if (globalIndex != -1) {
248-
rowIterator.setCursor(globalIndex);
249-
}
250250
return std::get<T2>(mBinningFunctions)(rowIterator);
251251
} else {
252-
return soa::row_helpers::getSingleRowData<T, T2>(rowIterator, globalIndex);
252+
return soa::row_helpers::getColumnValue<typename T2::type, T, T2>(rowIterator);
253253
}
254254
}
255255

@@ -286,7 +286,10 @@ struct ColumnBinningPolicy : BinningPolicyBase<sizeof...(Ts)> {
286286
template <typename T>
287287
auto getBinningValues(T& rowIterator, uint64_t globalIndex = -1) const
288288
{
289-
return std::make_tuple(soa::row_helpers::getSingleRowData<T, Ts>(rowIterator, globalIndex)...);
289+
if (globalIndex != -1) {
290+
rowIterator.setCursor(globalIndex);
291+
}
292+
return std::make_tuple(soa::row_helpers::getColumnValue<typename Ts::type, T, Ts>(rowIterator)...);
290293
}
291294

292295
template <typename T>
@@ -311,7 +314,10 @@ struct NoBinningPolicy {
311314
template <typename T>
312315
auto getBinningValues(T& rowIterator, uint64_t globalIndex = -1) const
313316
{
314-
return std::make_tuple(soa::row_helpers::getSingleRowData<T, C>(rowIterator, globalIndex));
317+
if (globalIndex != -1) {
318+
rowIterator.setCursor(globalIndex);
319+
}
320+
return std::make_tuple(soa::row_helpers::getColumnValue<typename C::type, T, C>(rowIterator));
315321
}
316322

317323
template <typename T>

0 commit comments

Comments
 (0)