Skip to content

Commit aec2bdb

Browse files
saganattktf
authored andcommitted
Further simplification and compilable code
1 parent 73793c8 commit aec2bdb

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
@@ -2165,61 +2165,14 @@ void emptyColumnLabel();
21652165

21662166
namespace row_helpers
21672167
{
2168-
template <soa::is_persistent_column... Cs>
2169-
std::array<arrow::ChunkedArray*, sizeof...(Cs)> getArrowColumns(arrow::Table* table, framework::pack<Cs...>)
2170-
{
2171-
return std::array<arrow::ChunkedArray*, sizeof...(Cs)>{o2::soa::getIndexFromLabel(table, Cs::columnLabel())...};
2172-
}
2173-
2174-
template <soa::is_persistent_column... Cs>
2175-
std::array<std::shared_ptr<arrow::Array>, sizeof...(Cs)> getChunks(arrow::Table* table, framework::pack<Cs...>, uint64_t ci)
2176-
{
2177-
return std::array<std::shared_ptr<arrow::Array>, sizeof...(Cs)>{o2::soa::getIndexFromLabel(table, Cs::columnLabel())->chunk(ci)...};
2178-
}
2179-
2180-
template <typename T, soa::is_persistent_column C>
2181-
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())
2182-
{
2183-
if (ci == std::numeric_limits<uint64_t>::max() || ai == std::numeric_limits<uint64_t>::max()) {
2184-
auto colIterator = static_cast<C>(rowIterator).getIterator();
2185-
ci = colIterator.mCurrentChunk;
2186-
ai = *(colIterator.mCurrentPos) - colIterator.mFirstIndex;
2187-
}
2188-
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];
2189-
}
2190-
2191-
template <typename T, soa::is_dynamic_column C>
2192-
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())
2193-
{
2194-
if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2195-
rowIterator.setCursor(globalIndex);
2196-
}
2197-
return rowIterator.template getDynamicColumn<C>();
2198-
}
2199-
2200-
template <typename T, soa::is_index_column C>
2201-
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())
2202-
{
2203-
if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2204-
rowIterator.setCursor(globalIndex);
2205-
}
2206-
return rowIterator.template getId<C>();
2207-
}
2208-
2209-
template <typename T, typename... Cs>
2210-
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())
2211-
{
2212-
return std::make_tuple(getSingleRowData<T, Cs>(table, rowIterator, ci, ai, globalIndex)...);
2213-
}
2214-
2215-
namespace
2216-
{
22172168
template <typename R, typename T, typename C>
22182169
R getColumnValue(const T& rowIterator)
22192170
{
22202171
return static_cast<R>(static_cast<C>(rowIterator).get());
22212172
}
22222173

2174+
namespace
2175+
{
22232176
template <typename R, typename T>
22242177
using ColumnGetterFunction = R (*)(const T&);
22252178

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)