Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,12 @@ class Table

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

static constexpr auto column_hashes = []<typename... C>(framework::pack<C...>) consteval {
auto hashes = []<typename... CC>() consteval { return std::array{CC::hash...}; }.template operator()<C...>();
std::ranges::sort(hashes);
return hashes;
}(columns_t{});

using persistent_columns_t = decltype([]<typename... C>(framework::pack<C...>&&) -> framework::selected_pack<soa::is_persistent_column_t, C...> {}(columns_t{}));
using column_types = decltype([]<typename... C>(framework::pack<C...>) -> framework::pack<typename C::type...> {}(persistent_columns_t{}));

Expand Down Expand Up @@ -1945,11 +1951,6 @@ class Table
using const_iterator = iterator;
using unfiltered_const_iterator = unfiltered_iterator;

static constexpr auto hashes()
{
return []<typename... C>(framework::pack<C...>) { return std::set{{C::hash...}}; }(columns_t{});
}

Table(o2::soa::ArrowTableRef tableRef)
: mArrowTableRef(tableRef),
mEnd{tableRef.range.size}
Expand Down
6 changes: 3 additions & 3 deletions Framework/Core/include/Framework/AnalysisHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ auto getTableFromFilter(soa::is_not_filtered_table auto const& table, soa::Selec
return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table.asArrowTableRef()}, std::forward<soa::SelectionVector>(selection));
}

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);
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);

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

void intializeCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema)
void intializeCaches(std::span<const uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema)
{
initializePartitionCaches(hashes, schema, filter, tree, gfilter);
}

void bindTable(T const& table)
{
intializeCaches(T::table_t::hashes(), table.asArrowTableRef()->schema());
intializeCaches(T::table_t::column_hashes, table.asArrowTableRef()->schema());
if (dataframeChanged) {
mFiltered = getTableFromFilter(table, soa::selectionToVector(framework::expressions::createSelection(table.asArrowTable(), gfilter)));
dataframeChanged = false;
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 @@ -126,7 +126,7 @@ struct AnalysisDataProcessorBuilder {
static void addExpression(int ai, uint32_t hash, std::vector<ExpressionInfo>& eInfos)
{
auto fields = soa::createFieldsFromColumns(typename std::decay_t<A>::persistent_columns_t{});
eInfos.emplace_back(ai, hash, std::decay_t<A>::hashes(), std::make_shared<arrow::Schema>(fields));
eInfos.emplace_back(ai, hash, std::span{std::decay_t<A>::column_hashes}, std::make_shared<arrow::Schema>(fields));
}

template <soa::is_iterator A>
Expand Down
8 changes: 4 additions & 4 deletions Framework/Core/include/Framework/Expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Projector;
#include <variant>
#include <string>
#include <memory>
#include <set>
#include <stack>
namespace gandiva
{
Expand All @@ -49,7 +48,8 @@ using FilterPtr = std::shared_ptr<gandiva::Filter>;

using atype = arrow::Type;
struct ExpressionInfo {
ExpressionInfo(int ai, size_t hash, std::set<uint32_t>&& hs, gandiva::SchemaPtr sc)
template <typename T>
ExpressionInfo(int ai, size_t hash, T hs, gandiva::SchemaPtr sc)
: argumentIndex(ai),
processHash(hash),
hashes(hs),
Expand All @@ -58,7 +58,7 @@ struct ExpressionInfo {
}
int argumentIndex;
size_t processHash;
std::set<uint32_t> hashes;
std::span<const uint32_t> hashes;
gandiva::SchemaPtr schema;
gandiva::NodePtr tree = nullptr;
gandiva::FilterPtr filter = nullptr;
Expand Down Expand Up @@ -681,7 +681,7 @@ using Operations = std::vector<ColumnOperationSpec>;
Operations createOperations(Filter const& expression);

/// Function to check compatibility of a given arrow schema with operation sequence
bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs);
bool isTableCompatible(const std::span<const uint32_t>& hashes, Operations const& specs);
/// Function to create gandiva expression tree from operation sequence
gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
gandiva::SchemaPtr const& Schema);
Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/src/AnalysisHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ std::shared_ptr<arrow::Table> spawnerHelper(std::shared_ptr<arrow::Table> const&
return arrow::Table::Make(newSchema, arrays);
}

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)
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)
{
if (tree == nullptr) {
expressions::Operations ops = createOperations(filter);
Expand Down
11 changes: 5 additions & 6 deletions Framework/Core/src/Expressions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -768,20 +768,19 @@ gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
return tree;
}

bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs)
bool isTableCompatible(std::span<const uint32_t> const& hashes, Operations const& specs)
{
std::set<uint32_t> opHashes;
std::vector<uint32_t> opHashes;
for (auto const& spec : specs) {
if (spec.left.datum.index() == 3) {
opHashes.insert(spec.left.hash);
opHashes.emplace_back(spec.left.hash);
}
if (spec.right.datum.index() == 3) {
opHashes.insert(spec.right.hash);
opHashes.emplace_back(spec.right.hash);
}
}

return std::includes(hashes.begin(), hashes.end(),
opHashes.begin(), opHashes.end());
return std::ranges::includes(hashes, opHashes);
}

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