Skip to content

Commit 6766ad6

Browse files
committed
continuing to adapt analysis task interface
1 parent 42dc416 commit 6766ad6

File tree

7 files changed

+304
-41
lines changed

7 files changed

+304
-41
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 108 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ struct Hash {
305305
static constexpr char const* const str{_Str_}; \
306306
};
307307

308+
#define O2ORIGIN(_Str_) \
309+
template <> \
310+
struct Hash<_Str_ ""_h> { \
311+
static constexpr header::DataOrigin origin{_Str_}; \
312+
static constexpr uint32_t hash = _Str_ ""_h; \
313+
static constexpr char const* const str{_Str_}; \
314+
};
315+
308316
static inline constexpr int version(const char* const str) {
309317
if (str[0] == '\0') {
310318
return -1;
@@ -323,14 +331,27 @@ static inline constexpr int version(const char* const str) {
323331
return res;
324332
}
325333

326-
static inline constexpr std::string_view description(const char* const str) {
334+
static inline constexpr std::string_view description_str(const char* const str) {
327335
size_t len = 0;
328336
while (len < 15 && str[len] != '/') {
329337
++len;
330338
}
331339
return std::string_view{str, len};
332340
}
333341

342+
static inline constexpr header::DataDescription description(const char* const str) {
343+
size_t len = 0;
344+
while (len < 15 && str[len] != '/') {
345+
++len;
346+
}
347+
char out[16];
348+
for (auto i = 0; i < 16; ++i) {
349+
out[i] = 0;
350+
}
351+
std::memcpy(out, str, len);
352+
return {out};
353+
}
354+
334355
template <typename T, template <uint32_t> class H>
335356
struct is_hash : std::false_type {
336357
};
@@ -1594,16 +1615,35 @@ inline constexpr bool is_specialization_origin_v = is_specialization_origin<T, R
15941615
template <typename T>
15951616
inline constexpr bool is_soa_iterator_v = soa::is_base_of_template_origin_v<RowViewCore, T> || soa::is_specialization_origin_v<T, RowViewCore>;
15961617

1618+
template <typename T>
1619+
concept soaIterator = is_soa_iterator_v<T>;
1620+
15971621
template <typename T>
15981622
inline constexpr bool is_ng_iterator_v = framework::is_base_of_template_v<TableIterator, T> || framework::is_specialization_v<T, TableIterator>;
15991623

1624+
template <typename T>
1625+
concept ngIterator = is_ng_iterator_v<T>;
1626+
16001627
template <typename T, typename B>
16011628
requires((o2::soa::is_soa_iterator_v<T> || o2::soa::is_soa_table_like_v<T>) && o2::soa::is_soa_table_like_v<B>)
16021629
consteval bool is_binding_compatible_v()
16031630
{
16041631
return are_bindings_compatible_v<T>(originals_pack_t<B>{});
16051632
}
16061633

1634+
template <typename T, soa::ngTable B>
1635+
requires((o2::soa::is_soa_iterator_v<T> || o2::soa::is_soa_table_like_v<T>))
1636+
consteval bool is_binding_compatible_v()
1637+
{
1638+
return false;
1639+
}
1640+
1641+
template <soa::ngTable T, soa::soaTable B>
1642+
consteval bool is_binding_compatible_v()
1643+
{
1644+
return false;
1645+
}
1646+
16071647
template <typename A>
16081648
concept WithOriginals = requires() {
16091649
A::originals.size();
@@ -1614,8 +1654,7 @@ concept WithSources = requires() {
16141654
o2::aod::MetadataTraitNG<T>::metadata::sources.size();
16151655
};
16161656

1617-
template <typename T, typename B>
1618-
requires WithOriginals<T> && WithOriginals<B>
1657+
template <WithOriginals T, WithOriginals B>
16191658
consteval bool is_binding_compatible_v()
16201659
{
16211660
return std::ranges::count_if(B::originals.begin(), B::originals.end(), [&](TableRef const& a) { return std::any_of(T::originals.begin(), T::originals.end(), [&](TableRef const& e) { return e.desc_hash == a.desc_hash; }); }) != 0;
@@ -1658,15 +1697,14 @@ static constexpr std::string getLabelFromType()
16581697
}
16591698
}
16601699

1661-
template <typename T>
1662-
requires WithOriginals<T>
1700+
template <soa::ngTable T>
1701+
requires soa::is_ng_table_like_v<T>
16631702
static constexpr std::string getLabelFromTypeNG()
16641703
{
16651704
return std::string{o2::aod::Hash<std::decay_t<T>::originals[0].label_hash>::str};
16661705
}
16671706

1668-
template <typename T>
1669-
requires framework::is_base_of_template_v<TableIterator, std::decay_t<T>>
1707+
template <soa::ngIterator T>
16701708
static constexpr std::string getLabelFromTypeNG()
16711709
{
16721710
return getLabelFromTypeNG<typename std::decay_t<T>::parent_t>();
@@ -1900,6 +1938,27 @@ class FilteredNG;
19001938
template <typename T>
19011939
inline constexpr bool is_soa_filtered_v = framework::is_base_of_template_v<soa::FilteredBase, T> || framework::is_base_of_template_v<soa::FilteredBaseNG, T>;
19021940

1941+
template <typename T>
1942+
concept hasFilteredPolicy = std::same_as<typename T::policy_t, soa::FilteredIndexPolicy>;
1943+
1944+
template <typename T>
1945+
concept soaFilteredIterator = soaIterator<T> && hasFilteredPolicy<T>;
1946+
1947+
template <typename T>
1948+
concept ngFilteredIterator = ngIterator<T> && hasFilteredPolicy<T>;
1949+
1950+
template <typename T>
1951+
concept soaFilteredTable = framework::is_base_of_template_v<soa::FilteredBase, T>;
1952+
1953+
template <typename T>
1954+
concept ngFilteredTable = framework::is_base_of_template_v<soa::FilteredBaseNG, T>;
1955+
1956+
template <typename T>
1957+
concept soaFiltered = soaFilteredTable<T> || soaFilteredIterator<T>;
1958+
1959+
template <typename T>
1960+
concept ngFiltered = ngFilteredTable<T> || ngFilteredIterator<T>;
1961+
19031962
/// Helper function to extract bound indices
19041963
template <typename... Is>
19051964
static consteval auto extractBindings(framework::pack<Is...>)
@@ -2320,7 +2379,7 @@ class TableNG
23202379
using const_iterator = iterator;
23212380
using unfiltered_const_iterator = unfiltered_iterator;
23222381

2323-
static consteval auto hashes()
2382+
static constexpr auto hashes()
23242383
{
23252384
return []<typename... C>(framework::pack<C...>) { return std::set{{o2::framework::TypeIdHelpers::uniqueId<C>()...}}; }(columns_t{});
23262385
}
@@ -3057,11 +3116,16 @@ std::tuple<typename Cs::type...> getRowData(arrow::Table* table, T rowIterator,
30573116
namespace o2::aod
30583117
{
30593118
DECLARE_SOA_ITERATOR_METADATA();
3060-
O2HASH("JOIN");
3119+
O2ORIGIN("AOD");
3120+
O2ORIGIN("AOD1");
3121+
O2ORIGIN("AOD2");
3122+
O2ORIGIN("DYN");
3123+
O2ORIGIN("IDX");
3124+
O2ORIGIN("JOIN");
30613125
O2HASH("JOIN/0");
3062-
O2HASH("CONC");
3126+
O2ORIGIN("CONC");
30633127
O2HASH("CONC/0");
3064-
O2HASH("TEST");
3128+
O2ORIGIN("TEST");
30653129
O2HASH("TEST/0");
30663130
}
30673131

@@ -3866,7 +3930,7 @@ consteval auto getIndexTargets()
38663930
O2HASH(_Desc_ "/" #_Version_); \
38673931
using _Name_##Metadata = TableMetadataNG<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>; \
38683932
template <typename O> \
3869-
using _Name_##From = TableNG<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3933+
using _Name_##From = o2::soa::TableNG<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
38703934
using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
38713935
template <> \
38723936
struct MetadataTraitNG<Hash<_Desc_ "/" #_Version_ ""_h>> { \
@@ -5551,6 +5615,19 @@ struct SmallGroupsBase : public Filtered<T> {
55515615
: Filtered<T>(std::move(tables), selection, offset) {}
55525616
};
55535617

5618+
template <typename T, bool APPLY>
5619+
struct SmallGroupsBaseNG : public FilteredNG<T> {
5620+
static constexpr bool applyFilters = APPLY;
5621+
SmallGroupsBaseNG(std::vector<std::shared_ptr<arrow::Table>>&& tables, gandiva::Selection const& selection, uint64_t offset = 0)
5622+
: Filtered<T>(std::move(tables), selection, offset) {}
5623+
5624+
SmallGroupsBaseNG(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
5625+
: Filtered<T>(std::move(tables), std::forward<SelectionVector>(selection), offset) {}
5626+
5627+
SmallGroupsBaseNG(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
5628+
: Filtered<T>(std::move(tables), selection, offset) {}
5629+
};
5630+
55545631
template <typename T>
55555632
using SmallGroups = SmallGroupsBase<T, true>;
55565633

@@ -5569,6 +5646,25 @@ struct is_smallgroups_t<SmallGroupsBase<T, F>> {
55695646

55705647
template <typename T>
55715648
constexpr bool is_smallgroups_v = is_smallgroups_t<T>::value;
5649+
5650+
template <typename T>
5651+
using SmallGroupsNG = SmallGroupsBaseNG<T, true>;
5652+
5653+
template <typename T>
5654+
using SmallGroupsNGUnfiltered = SmallGroupsBaseNG<T, false>;
5655+
5656+
template <typename T>
5657+
struct is_smallgroups_ng_t {
5658+
static constexpr bool value = false;
5659+
};
5660+
5661+
template <typename T, bool F>
5662+
struct is_smallgroups_ng_t<SmallGroupsBaseNG<T, F>> {
5663+
static constexpr bool value = true;
5664+
};
5665+
5666+
template <typename T>
5667+
constexpr bool is_smallgroups_ng_v = is_smallgroups_ng_t<T>::value;
55725668
} // namespace o2::soa
55735669

55745670
namespace o2::framework

Framework/Core/include/Framework/AnalysisDataModel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <cmath>
1717
#include <bitset>
1818
#include <numeric>
19-
#include <utility> // std::move
2019

2120
#include "Framework/DataTypes.h"
2221
#include "CommonConstants/MathConstants.h"

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ struct OutputForTableNG {
249249

250250
static OutputSpec const spec()
251251
{
252-
return OutputSpec{OutputLabel{o2::aod::Hash<T::ref.label_hash>::str}, o2::aod::Hash<T::ref.origin_hash>::str, o2::aod::description(o2::aod::Hash<T::ref.desc_hash>::str), T::ref::version};
252+
return OutputSpec{OutputLabel{o2::aod::Hash<T::ref.label_hash>::str}, o2::aod::Hash<T::ref.origin_hash>::origin, o2::aod::description(o2::aod::Hash<T::ref.desc_hash>::str), T::ref.version};
253253
}
254254

255255
static OutputRef ref()
256256
{
257-
return OutputRef{o2::aod::Hash<T::ref.label_hash>::str, T::ref::version};
257+
return OutputRef{o2::aod::Hash<T::ref.label_hash>::str, T::ref.version};
258258
}
259259
};
260260

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ template <typename TABLE>
309309
struct OutputManager<ProducesNG<TABLE>> {
310310
static bool appendOutput(std::vector<OutputSpec>& outputs, ProducesNG<TABLE>& /*what*/, uint32_t)
311311
{
312-
outputs.emplace_back(OutputForTable<TABLE>::spec());
312+
outputs.emplace_back(OutputForTableNG<TABLE>::spec());
313313
return true;
314314
}
315315
static bool prepare(ProcessingContext& context, ProducesNG<TABLE>& what)
316316
{
317-
what.resetCursor(std::move(context.outputs().make<TableBuilder>(OutputForTable<TABLE>::ref())));
317+
what.resetCursor(std::move(context.outputs().make<TableBuilder>(OutputForTableNG<TABLE>::ref())));
318318
return true;
319319
}
320320
static bool finalize(ProcessingContext&, ProducesNG<TABLE>& what)

0 commit comments

Comments
 (0)