Skip to content

Commit 9192856

Browse files
mytkomktf
authored andcommitted
use generic get() in row_helpers
1 parent 24f1796 commit 9192856

File tree

3 files changed

+19
-77
lines changed

3 files changed

+19
-77
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ typename C::type getSingleRowData(arrow::Table*, T& rowIterator, uint64_t ci = s
21942194
if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
21952195
rowIterator.setCursor(globalIndex);
21962196
}
2197-
return rowIterator.template getDynamicColumn<C>();
2197+
return static_cast<C>(rowIterator).get();
21982198
}
21992199

22002200
template <typename T, soa::is_index_column C>

Framework/Core/include/Framework/ASoAHelpers.h

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -76,77 +76,19 @@ void dataSizeVariesBetweenColumns();
7676
template <template <typename... Cs> typename BP, typename T, typename... Cs>
7777
std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPolicy, int minCatSize, int outsider)
7878
{
79-
arrow::Table* arrowTable = table.asArrowTable().get();
80-
auto rowIterator = table.begin();
81-
82-
uint64_t ind = 0;
83-
uint64_t selInd = 0;
84-
gsl::span<int64_t const> selectedRows;
8579
std::vector<BinningIndex> groupedIndices;
8680

87-
// Separate check to account for Filtered size different from arrow table
81+
// TODO: Check if this check can be now skipped
8882
if (table.size() == 0) {
8983
return groupedIndices;
9084
}
9185

92-
if constexpr (soa::is_filtered_table<T>) {
93-
selectedRows = table.getSelectedRows(); // vector<int64_t>
94-
}
95-
96-
auto persistentColumns = typename BP<Cs...>::persistent_columns_t{};
97-
constexpr auto persistentColumnsCount = pack_size(persistentColumns);
98-
auto arrowColumns = o2::soa::row_helpers::getArrowColumns(arrowTable, persistentColumns);
99-
auto chunksCount = arrowColumns[0]->num_chunks();
100-
for (int i = 1; i < persistentColumnsCount; i++) {
101-
if (arrowColumns[i]->num_chunks() != chunksCount) {
102-
dataSizeVariesBetweenColumns();
103-
}
104-
}
105-
106-
for (uint64_t ci = 0; ci < chunksCount; ++ci) {
107-
auto chunks = o2::soa::row_helpers::getChunks(arrowTable, persistentColumns, ci);
108-
auto chunkLength = std::get<0>(chunks)->length();
109-
for_<persistentColumnsCount - 1>([&chunks, &chunkLength](auto i) {
110-
if (std::get<i.value + 1>(chunks)->length() != chunkLength) {
111-
dataSizeVariesBetweenColumns();
112-
}
113-
});
114-
115-
if constexpr (soa::is_filtered_table<T>) {
116-
if (selectedRows[ind] >= selInd + chunkLength) {
117-
selInd += chunkLength;
118-
continue; // Go to the next chunk, no value selected in this chunk
119-
}
120-
}
121-
122-
uint64_t ai = 0;
123-
while (ai < chunkLength) {
124-
if constexpr (soa::is_filtered_table<T>) {
125-
ai += selectedRows[ind] - selInd;
126-
selInd = selectedRows[ind];
127-
}
128-
129-
auto values = binningPolicy.getBinningValues(rowIterator, arrowTable, ci, ai, ind);
86+
for(auto rowIterator : table) {
87+
auto values = binningPolicy.getBinningValues(rowIterator);
13088
auto val = binningPolicy.getBin(values);
13189
if (val != outsider) {
132-
groupedIndices.emplace_back(val, ind);
133-
}
134-
ind++;
135-
136-
if constexpr (soa::is_filtered_table<T>) {
137-
if (ind >= selectedRows.size()) {
138-
break;
139-
}
140-
} else {
141-
ai++;
90+
groupedIndices.emplace_back(val, *std::get<1>(rowIterator.getIndices()));
14291
}
143-
}
144-
145-
if constexpr (soa::is_filtered_table<T>) {
146-
if (ind == selectedRows.size()) {
147-
break;
148-
}
149-
}
15092
}
15193

15294
// Do a stable sort so that same categories entries are

Framework/Core/include/Framework/BinningPolicy.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,28 @@ struct FlexibleBinningPolicy<std::tuple<Ls...>, Ts...> : BinningPolicyBase<sizeo
241241
}
242242

243243
template <typename T, typename T2>
244-
auto getBinningValue(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
244+
auto getBinningValue(T& rowIterator, uint64_t globalIndex = -1) const
245245
{
246246
if constexpr (has_type<T2>(pack<Ls...>{})) {
247247
if (globalIndex != -1) {
248248
rowIterator.setCursor(globalIndex);
249249
}
250250
return std::get<T2>(mBinningFunctions)(rowIterator);
251251
} else {
252-
return soa::row_helpers::getSingleRowData<T, T2>(table, rowIterator, ci, ai, globalIndex);
252+
return soa::row_helpers::getSingleRowData<T, T2>(rowIterator, globalIndex);
253253
}
254254
}
255255

256256
template <typename T>
257-
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
257+
auto getBinningValues(T& rowIterator, uint64_t globalIndex = -1) const
258258
{
259-
return std::make_tuple(getBinningValue<T, Ts>(rowIterator, table, ci, ai, globalIndex)...);
259+
return std::make_tuple(getBinningValue<T, Ts>(rowIterator, globalIndex)...);
260260
}
261261

262262
template <typename T>
263-
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
263+
auto getBinningValues(typename T::iterator rowIterator, uint64_t globalIndex = -1) const
264264
{
265-
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
265+
return getBinningValues(rowIterator, globalIndex);
266266
}
267267

268268
template <typename... T2s>
@@ -284,15 +284,15 @@ struct ColumnBinningPolicy : BinningPolicyBase<sizeof...(Ts)> {
284284
}
285285

286286
template <typename T>
287-
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
287+
auto getBinningValues(T& rowIterator, uint64_t globalIndex = -1) const
288288
{
289-
return std::make_tuple(soa::row_helpers::getSingleRowData<T, Ts>(table, rowIterator, ci, ai, globalIndex)...);
289+
return std::make_tuple(soa::row_helpers::getSingleRowData<T, Ts>(rowIterator, globalIndex)...);
290290
}
291291

292292
template <typename T>
293-
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
293+
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t globalIndex = -1) const
294294
{
295-
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
295+
return getBinningValues(rowIterator, globalIndex);
296296
}
297297

298298
int getBin(std::tuple<typename Ts::type...> const& data) const
@@ -309,15 +309,15 @@ struct NoBinningPolicy {
309309
NoBinningPolicy() = default;
310310

311311
template <typename T>
312-
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
312+
auto getBinningValues(T& rowIterator, uint64_t globalIndex = -1) const
313313
{
314-
return std::make_tuple(soa::row_helpers::getSingleRowData<T, C>(table, rowIterator, ci, ai, globalIndex));
314+
return std::make_tuple(soa::row_helpers::getSingleRowData<T, C>(rowIterator, globalIndex));
315315
}
316316

317317
template <typename T>
318-
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
318+
auto getBinningValues(typename T::iterator rowIterator, uint64_t globalIndex = -1) const
319319
{
320-
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
320+
return getBinningValues(rowIterator, globalIndex);
321321
}
322322

323323
int getBin(std::tuple<typename C::type> const& data) const

0 commit comments

Comments
 (0)