Skip to content

Commit fcd7a33

Browse files
committed
DPL Analysis: remove std::set from analysis task
1 parent 4e94192 commit fcd7a33

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

Framework/Core/include/Framework/ASoA.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,12 @@ class Table
17621762

17631763
using columns_t = decltype(getColumns<ref, Ts...>());
17641764

1765+
static constexpr auto column_hashes = []<typename... C>(framework::pack<C...>) consteval {
1766+
auto hashes = []<typename... CC>() consteval { return std::array{CC::hash...}; }.template operator()<C...>();
1767+
std::ranges::sort(hashes);
1768+
return hashes;
1769+
}(columns_t{});
1770+
17651771
using persistent_columns_t = decltype([]<typename... C>(framework::pack<C...>&&) -> framework::selected_pack<soa::is_persistent_column_t, C...> {}(columns_t{}));
17661772
using column_types = decltype([]<typename... C>(framework::pack<C...>) -> framework::pack<typename C::type...> {}(persistent_columns_t{}));
17671773

@@ -1945,11 +1951,6 @@ class Table
19451951
using const_iterator = iterator;
19461952
using unfiltered_const_iterator = unfiltered_iterator;
19471953

1948-
static constexpr auto hashes()
1949-
{
1950-
return []<typename... C>(framework::pack<C...>) { return std::set{{C::hash...}}; }(columns_t{});
1951-
}
1952-
19531954
Table(o2::soa::ArrowTableRef tableRef)
19541955
: mArrowTableRef(tableRef),
19551956
mEnd{tableRef.range.size}

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ auto getTableFromFilter(soa::is_not_filtered_table auto const& table, soa::Selec
953953
return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table.asArrowTableRef()}, std::forward<soa::SelectionVector>(selection));
954954
}
955955

956-
void initializePartitionCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter);
956+
void initializePartitionCaches(const std::span<const uint32_t>& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter);
957957

958958
/// Partition ties directly to the argument type
959959
/// in a case with several origins in subscriptions it will get the correct input, as the type contains the origin
@@ -975,14 +975,14 @@ struct Partition {
975975
setTable(table);
976976
}
977977

978-
void intializeCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema)
978+
void intializeCaches(std::span<const uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema)
979979
{
980980
initializePartitionCaches(hashes, schema, filter, tree, gfilter);
981981
}
982982

983983
void bindTable(T const& table)
984984
{
985-
intializeCaches(T::table_t::hashes(), table.asArrowTableRef()->schema());
985+
intializeCaches(T::table_t::column_hashes, table.asArrowTableRef()->schema());
986986
if (dataframeChanged) {
987987
mFiltered = getTableFromFilter(table, soa::selectionToVector(framework::expressions::createSelection(table.asArrowTable(), gfilter)));
988988
dataframeChanged = false;

Framework/Core/include/Framework/AnalysisTask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct AnalysisDataProcessorBuilder {
126126
static void addExpression(int ai, uint32_t hash, std::vector<ExpressionInfo>& eInfos)
127127
{
128128
auto fields = soa::createFieldsFromColumns(typename std::decay_t<A>::persistent_columns_t{});
129-
eInfos.emplace_back(ai, hash, std::decay_t<A>::hashes(), std::make_shared<arrow::Schema>(fields));
129+
eInfos.emplace_back(ai, hash, std::span{std::decay_t<A>::column_hashes}, std::make_shared<arrow::Schema>(fields));
130130
}
131131

132132
template <soa::is_iterator A>

Framework/Core/include/Framework/Expressions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class Projector;
3939
#include <variant>
4040
#include <string>
4141
#include <memory>
42-
#include <set>
4342
#include <stack>
4443
namespace gandiva
4544
{
@@ -49,7 +48,8 @@ using FilterPtr = std::shared_ptr<gandiva::Filter>;
4948

5049
using atype = arrow::Type;
5150
struct ExpressionInfo {
52-
ExpressionInfo(int ai, size_t hash, std::set<uint32_t>&& hs, gandiva::SchemaPtr sc)
51+
template <typename T>
52+
ExpressionInfo(int ai, size_t hash, T hs, gandiva::SchemaPtr sc)
5353
: argumentIndex(ai),
5454
processHash(hash),
5555
hashes(hs),
@@ -58,7 +58,7 @@ struct ExpressionInfo {
5858
}
5959
int argumentIndex;
6060
size_t processHash;
61-
std::set<uint32_t> hashes;
61+
std::span<const uint32_t> hashes;
6262
gandiva::SchemaPtr schema;
6363
gandiva::NodePtr tree = nullptr;
6464
gandiva::FilterPtr filter = nullptr;
@@ -681,7 +681,7 @@ using Operations = std::vector<ColumnOperationSpec>;
681681
Operations createOperations(Filter const& expression);
682682

683683
/// Function to check compatibility of a given arrow schema with operation sequence
684-
bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs);
684+
bool isTableCompatible(const std::span<const uint32_t>& hashes, Operations const& specs);
685685
/// Function to create gandiva expression tree from operation sequence
686686
gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
687687
gandiva::SchemaPtr const& Schema);

Framework/Core/src/AnalysisHelpers.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ std::shared_ptr<arrow::Table> spawnerHelper(std::shared_ptr<arrow::Table> const&
155155
return arrow::Table::Make(newSchema, arrays);
156156
}
157157

158-
void initializePartitionCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter)
158+
void initializePartitionCaches(std::span<const uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter)
159159
{
160160
if (tree == nullptr) {
161161
expressions::Operations ops = createOperations(filter);

Framework/Core/src/Expressions.cxx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,20 +768,19 @@ gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
768768
return tree;
769769
}
770770

771-
bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs)
771+
bool isTableCompatible(std::span<const uint32_t> const& hashes, Operations const& specs)
772772
{
773-
std::set<uint32_t> opHashes;
773+
std::vector<uint32_t> opHashes;
774774
for (auto const& spec : specs) {
775775
if (spec.left.datum.index() == 3) {
776-
opHashes.insert(spec.left.hash);
776+
opHashes.emplace_back(spec.left.hash);
777777
}
778778
if (spec.right.datum.index() == 3) {
779-
opHashes.insert(spec.right.hash);
779+
opHashes.emplace_back(spec.right.hash);
780780
}
781781
}
782782

783-
return std::includes(hashes.begin(), hashes.end(),
784-
opHashes.begin(), opHashes.end());
783+
return std::ranges::includes(hashes, opHashes);
785784
}
786785

787786
void updateExpressionInfos(expressions::Filter const& filter, std::vector<ExpressionInfo>& eInfos)

0 commit comments

Comments
 (0)