Skip to content

Commit

Permalink
DPL Analysis: Analysis task rework (AliceO2Group#12915)
Browse files Browse the repository at this point in the history
  • Loading branch information
aalkin authored Mar 26, 2024
1 parent 86261fe commit 622390b
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 220 deletions.
25 changes: 20 additions & 5 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Binding {

void accessingInvalidIndexFor(const char* getter);
void dereferenceWithWrongType();
void missingFilterDeclaration(int hash, int ai);

template <typename... C>
auto createFieldsFromColumns(framework::pack<C...>)
Expand Down Expand Up @@ -1006,7 +1007,7 @@ struct is_binding_compatible : std::conditional_t<is_binding_compatible_v<T, typ
};

template <typename T>
static std::string getLabelFromType()
static constexpr std::string getLabelFromType()
{
if constexpr (soa::is_index_table_v<std::decay_t<T>>) {
using TT = typename std::decay_t<T>::first_t;
Expand Down Expand Up @@ -1039,19 +1040,19 @@ static std::string getLabelFromType()
}

template <typename... C>
static auto hasColumnForKey(framework::pack<C...>, std::string const& key)
static constexpr auto hasColumnForKey(framework::pack<C...>, std::string const& key)
{
return ((C::inherited_t::mLabel == key) || ...);
}

template <typename T>
static std::pair<bool, std::string> hasKey(std::string const& key)
static constexpr std::pair<bool, std::string> hasKey(std::string const& key)
{
return {hasColumnForKey(typename T::persistent_columns_t{}, key), getLabelFromType<T>()};
}

template <typename... C>
static auto haveKey(framework::pack<C...>, std::string const& key)
static constexpr auto haveKey(framework::pack<C...>, std::string const& key)
{
return std::vector{hasKey<C>(key)...};
}
Expand All @@ -1060,7 +1061,7 @@ void notFoundColumn(const char* label, const char* key);
void missingOptionalPreslice(const char* label, const char* key);

template <typename T, bool OPT = false>
static std::string getLabelFromTypeForKey(std::string const& key)
static constexpr std::string getLabelFromTypeForKey(std::string const& key)
{
if constexpr (soa::is_type_with_originals_v<std::decay_t<T>>) {
using Os = typename std::decay_t<T>::originals;
Expand Down Expand Up @@ -1189,6 +1190,20 @@ namespace o2::soa
template <typename T>
inline constexpr bool is_soa_iterator_v = framework::is_base_of_template_v<RowViewCore, T> || framework::is_specialization_v<T, RowViewCore>;

template <typename T>
inline constexpr bool is_soa_filtered_iterator_v()
{
if constexpr (!is_soa_iterator_v<T>) {
return false;
} else {
if constexpr (std::is_same_v<typename T::policy_t, soa::FilteredIndexPolicy>) {
return true;
} else {
return false;
}
}
}

template <typename T>
using is_soa_table_t = typename framework::is_specialization<T, soa::Table>;

Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/include/Framework/AnalysisHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Framework/DataAllocator.h"
#include "Framework/Traits.h"
#include "Framework/TableBuilder.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/ASoA.h"
#include "Framework/OutputSpec.h"
#include "Framework/OutputRef.h"
#include "Framework/InputSpec.h"
Expand Down
320 changes: 108 additions & 212 deletions Framework/Core/include/Framework/AnalysisTask.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Framework/Core/include/Framework/ArrowTableSlicingCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "Framework/ServiceHandle.h"
#include <arrow/array.h>
#include <string_view>
#include <gsl/span>

namespace o2::framework
Expand All @@ -37,6 +36,8 @@ struct SliceInfoUnsortedPtr {

using StringPair = std::pair<std::string, std::string>;

void updatePairList(std::vector<StringPair>& list, std::string const& binding, std::string const& key);

struct ArrowTableSlicingCacheDef {
constexpr static ServiceKind service_kind = ServiceKind::Global;
std::vector<StringPair> bindingsKeys;
Expand Down
2 changes: 2 additions & 0 deletions Framework/Core/include/Framework/Expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ std::shared_ptr<gandiva::Projector> createProjectors(framework::pack<C...>, std:

return createProjectorHelper(sizeof...(C), projectors.data(), schema, fields);
}

void updateFilterInfo(ExpressionInfo& info, std::shared_ptr<arrow::Table>& table);
} // namespace o2::framework::expressions

#endif // O2_FRAMEWORK_EXPRESSIONS_H_
4 changes: 4 additions & 0 deletions Framework/Core/src/ASoA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ void dereferenceWithWrongType()
{
throw o2::framework::runtime_error_f("Trying to dereference index with a wrong type in _as<>. Note that if you have several compatible index targets in your process() signature, the last one will be the one actually bound to the getter.");
}
void missingFilterDeclaration(int hash, int ai)
{
throw o2::framework::runtime_error_f("Null selection for %d (arg %d), missing Filter declaration?", hash, ai);
}

SelectionVector selectionToVector(gandiva::Selection const& sel)
{
Expand Down
7 changes: 7 additions & 0 deletions Framework/Core/src/ArrowTableSlicingCache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
namespace o2::framework
{

void updatePairList(std::vector<StringPair>& list, std::string const& binding, std::string const& key)
{
if (std::find_if(list.begin(), list.end(), [&binding, &key](auto const& entry) { return (entry.first == binding) && (entry.second == key); }) == list.end()) {
list.emplace_back(binding, key);
}
}

std::pair<int64_t, int64_t> SliceInfoPtr::getSliceFor(int value) const
{
int64_t offset = 0;
Expand Down
11 changes: 11 additions & 0 deletions Framework/Core/src/Expressions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,15 @@ void updateExpressionInfos(expressions::Filter const& filter, std::vector<Expres
}
}

void updateFilterInfo(ExpressionInfo& info, std::shared_ptr<arrow::Table>& table)
{
if (info.tree != nullptr && info.filter == nullptr) {
info.filter = framework::expressions::createFilter(table->schema(), framework::expressions::makeCondition(info.tree));
}
if (info.tree != nullptr && info.filter != nullptr && info.resetSelection == true) {
info.selection = framework::expressions::createSelection(table, info.filter);
info.resetSelection = false;
}
}

} // namespace o2::framework::expressions
1 change: 1 addition & 0 deletions Framework/Core/test/test_ASoA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Framework/ASoA.h"
#include "Framework/Expressions.h"
#include "Framework/AnalysisHelpers.h"
#include "CommonConstants/MathConstants.h"
#include "gandiva/tree_expr_builder.h"
#include "arrow/status.h"
#include "gandiva/filter.h"
Expand Down
1 change: 1 addition & 0 deletions Framework/TestWorkflows/src/o2AnalysisTaskExample.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/AnalysisDataModel.h"
#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"

Expand Down
2 changes: 1 addition & 1 deletion Framework/TestWorkflows/src/o2AnalysisWorkflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include <TH2F.h>
#include <cmath>

using namespace o2;
using namespace o2::framework;
Expand Down

0 comments on commit 622390b

Please sign in to comment.