Skip to content

Commit

Permalink
DPL Analysis: workaround for setting self-index binding before invoki…
Browse files Browse the repository at this point in the history
…ng process() (#8588)
  • Loading branch information
aalkin authored Apr 21, 2022
1 parent 8fa8fe4 commit 70727d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
55 changes: 27 additions & 28 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,8 @@ struct RowViewCore : public IP, C... {
(Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
}

template <typename... Cs, typename E>
void doSetCurrentInternal(framework::pack<Cs...>, E* ptr)
template <typename... Cs>
void doSetCurrentInternal(framework::pack<Cs...>, void const* ptr)
{
(Cs::setCurrentRaw(ptr), ...);
}
Expand All @@ -839,8 +839,7 @@ struct RowViewCore : public IP, C... {
doSetCurrentIndexRaw(external_index_columns_t{}, std::forward<std::vector<void const*>>(ptrs));
}

template <typename E>
void bindInternalIndices(E* table)
void bindInternalIndices(void const* table)
{
doSetCurrentInternal(internal_index_columns_t{}, table);
}
Expand Down Expand Up @@ -1075,7 +1074,7 @@ class Table
mColumnChunks[ci] = lookups[ci];
}
mBegin = unfiltered_iterator{mColumnChunks, {table->num_rows(), offset}};
bindInternalIndices();
mBegin.bindInternalIndices(this);
}
}

Expand Down Expand Up @@ -1157,13 +1156,7 @@ class Table
mBegin.bindExternalIndices(current...);
}

void bindInternalIndices()
{
mBegin.bindInternalIndices(this);
}

template <typename T>
void bindInternalIndicesTo(T* ptr)
void bindInternalIndicesTo(void const* ptr)
{
mBegin.bindInternalIndices(ptr);
}
Expand Down Expand Up @@ -2124,8 +2117,8 @@ struct Join : JoinBase<Ts...> {
using base = JoinBase<Ts...>;
using originals = originals_pack_t<Ts...>;

template <typename... TA>
void bindExternalIndices(TA*... externals);
using base::bindExternalIndices;
using base::bindInternalIndicesTo;

using table_t = base;
using persistent_columns_t = typename table_t::persistent_columns_t;
Expand All @@ -2139,37 +2132,35 @@ template <typename... Ts>
Join<Ts...>::Join(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t offset)
: JoinBase<Ts...>{ArrowHelpers::joinTables(std::move(tables)), offset}
{
bindInternalIndicesTo(this);
}

template <typename... Ts>
template <typename... ATs>
Join<Ts...>::Join(uint64_t offset, std::shared_ptr<arrow::Table> t1, std::shared_ptr<arrow::Table> t2, ATs... ts)
: Join<Ts...>(std::vector<std::shared_ptr<arrow::Table>>{t1, t2, ts...}, offset)
{
}

template <typename... Ts>
template <typename... TA>
void Join<Ts...>::bindExternalIndices(TA*... externals)
{
base::bindExternalIndices(externals...);
bindInternalIndicesTo(this);
}

template <typename T1, typename T2>
struct Concat : ConcatBase<T1, T2> {
Concat(std::shared_ptr<arrow::Table> t1, std::shared_ptr<arrow::Table> t2, uint64_t offset = 0)
: ConcatBase<T1, T2>{ArrowHelpers::concatTables({t1, t2}), offset} {}
: ConcatBase<T1, T2>{ArrowHelpers::concatTables({t1, t2}), offset}
{
bindInternalIndicesTo(this);
}
Concat(std::vector<std::shared_ptr<arrow::Table>> tables, uint64_t offset = 0)
: ConcatBase<T1, T2>{ArrowHelpers::concatTables(std::move(tables)), offset} {}
: ConcatBase<T1, T2>{ArrowHelpers::concatTables(std::move(tables)), offset}
{
bindInternalIndicesTo(this);
}

using base = ConcatBase<T1, T2>;
using originals = framework::concatenated_pack_t<originals_pack_t<T1>, originals_pack_t<T2>>;

template <typename... TA>
void bindExternalIndices(TA*... externals)
{
base::bindExternalIndices(externals...);
}
using base::bindExternalIndices;
using base::bindInternalIndicesTo;

// FIXME: can be remove when we do the same treatment we did for Join to Concatenate
using left_t = T1;
Expand Down Expand Up @@ -2216,6 +2207,7 @@ class FilteredBase : public T
mSelectedRows{getSpan(selection)}
{
resetRanges();
mFilteredBegin.bindInternalIndices(this);
}

FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
Expand All @@ -2224,13 +2216,15 @@ class FilteredBase : public T
mCached{true}
{
resetRanges();
mFilteredBegin.bindInternalIndices(this);
}

FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
: T{std::move(tables), offset},
mSelectedRows{selection}
{
resetRanges();
mFilteredBegin.bindInternalIndices(this);
}

iterator begin()
Expand Down Expand Up @@ -2298,6 +2292,11 @@ class FilteredBase : public T
mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<void const*>>(ptrs));
}

void bindInternalIndicesTo(void const* ptr)
{
mFilteredBegin.bindInternalIndices(ptr);
}

template <typename T1, typename... Cs>
void doCopyIndexBindings(framework::pack<Cs...>, T1& dest) const
{
Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/include/Framework/AnalysisTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ struct AnalysisDataProcessorBuilder {
}
} else {
// non-grouping case

overwriteInternalIndices(associatedTables, associatedTables);
// bind partitions and grouping table
homogeneous_apply_refs([&groupingTable](auto& x) {
PartitionManager<std::decay_t<decltype(x)>>::bindExternalIndices(x, &groupingTable);
Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/test/test_ASoA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ BOOST_AUTO_TEST_CASE(TestAdvancedIndices)
}
auto t3 = b3.finalize();
auto pst = PointsSelfIndex{t3};
pst.bindInternalIndices();
pst.bindInternalIndicesTo(&pst);
auto i = 0;
c1 = 0;
c2 = 0;
Expand Down

0 comments on commit 70727d2

Please sign in to comment.