Skip to content

Commit 044b606

Browse files
committed
Fully working version
1 parent 3885717 commit 044b606

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

Framework/Core/include/Framework/BinningPolicy.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -238,36 +238,28 @@ struct FlexibleBinningPolicy<std::tuple<Ls...>, Ts...> : BinningPolicyBase<sizeo
238238
}
239239

240240
template <typename T, typename T2>
241-
auto getBinningValue(T& rowIterator, arrow::Table* table, uint64_t globalIndex = -1, uint64_t ci = -1, uint64_t ai = -1) const
241+
auto getBinningValue(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
242242
{
243-
using decayed = std::decay_t<T2>;
244-
if (globalIndex == -1) {
245-
globalIndex = *(std::get<0>(rowIterator.getIndices()));
246-
}
247-
248243
if constexpr (has_type_v<T2, pack<Ls...>>) {
249-
rowIterator.setCursor(globalIndex);
244+
if (globalIndex != -1) {
245+
rowIterator.setCursor(globalIndex);
246+
}
250247
return std::get<T2>(mBinningFunctions)(rowIterator);
251248
} else {
252-
if (ci == -1 && ai == -1) {
253-
auto colIterator = static_cast<decayed>(rowIterator).mColumnIterator;
254-
ci = colIterator.mCurrentChunk;
255-
ai = *(colIterator.mCurrentPos) - colIterator.mFirstIndex;
256-
}
257249
return soa::row_helpers::getSingleRowData<T, T2>(table, rowIterator, ci, ai, globalIndex);
258250
}
259251
}
260252

261253
template <typename T>
262-
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t globalIndex = -1, uint64_t ci = -1, uint64_t ai = -1) const
254+
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
263255
{
264-
return std::make_tuple(getBinningValue<T, Ts>(rowIterator, table, globalIndex, ci, ai)...);
256+
return std::make_tuple(getBinningValue<T, Ts>(rowIterator, table, ci, ai, globalIndex)...);
265257
}
266258

267259
template <typename T>
268-
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t globalIndex = -1, uint64_t ci = -1, uint64_t ai = -1) const
260+
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
269261
{
270-
return getBinningValues(rowIterator, table.asArrowTable().get(), globalIndex, ci, ai);
262+
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
271263
}
272264

273265
template <typename... T2s>
@@ -289,11 +281,17 @@ struct ColumnBinningPolicy : BinningPolicyBase<sizeof...(Ts)> {
289281
}
290282

291283
template <typename T>
292-
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci, uint64_t ai, uint64_t globalIndex) const
284+
auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
293285
{
294286
return std::make_tuple(soa::row_helpers::getSingleRowData<T, Ts>(table, rowIterator, ci, ai, globalIndex)...);
295287
}
296288

289+
template <typename T>
290+
auto getBinningValues(typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1) const
291+
{
292+
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
293+
}
294+
297295
int getBin(std::tuple<typename Ts::type...> const& data) const
298296
{
299297
return BinningPolicyBase<sizeof...(Ts)>::template getBin<typename Ts::type...>(data);
@@ -311,11 +309,17 @@ struct NoBinningPolicy {
311309
NoBinningPolicy() = default;
312310

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

317+
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
319+
{
320+
return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
321+
}
322+
319323
int getBin(std::tuple<typename C::type> const& data) const
320324
{
321325
return std::get<0>(data);

0 commit comments

Comments
 (0)