Skip to content

Commit 9db24cf

Browse files
committed
Handle missing Preslice bindings uniformly
Drop the duplicated binding check isMissing() on the binding key for all Preslice kinds rename missingOptionalPreslice to missingPreslice
1 parent 117eb3c commit 9db24cf

3 files changed

Lines changed: 27 additions & 43 deletions

File tree

‎Framework/Core/include/Framework/ASoA.h‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::st
13511351
}
13521352

13531353
void notFoundColumn(const char* label, const char* key);
1354-
void missingOptionalPreslice(const char* label, const char* key);
1354+
void missingPreslice(const char* label, const char* key);
13551355

13561356
template <with_originals T, bool OPT = false>
13571357
static constexpr std::string getLabelFromTypeForKey(std::string_view key)
@@ -1421,7 +1421,6 @@ namespace o2::framework
14211421
/// tracks origin in bindingKey matcher to handle the correct arguments
14221422
struct PreslicePolicyBase {
14231423
static constexpr void isPreslicePolicy() {};
1424-
const std::string binding;
14251424
Entry bindingKey;
14261425

14271426
bool isMissing() const;
@@ -1448,29 +1447,28 @@ struct PresliceBase : public Policy {
14481447
constexpr static bool optional = OPT;
14491448
using target_t = T;
14501449
using policy_t = Policy;
1451-
const std::string binding;
14521450

14531451
PresliceBase(expressions::BindingNode index_)
1454-
: Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name})}, Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), o2::soa::getMatcherFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1452+
: Policy{Entry(
1453+
o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}),
1454+
o2::soa::getMatcherFromTypeForKey<T, OPT>(std::string{index_.name}),
1455+
std::string{index_.name}
1456+
)}
14551457
{
14561458
}
14571459

14581460
o2::soa::ArrowTableRef getSliceFor(int value, o2::soa::ArrowTableRef const& input) const
14591461
{
1460-
if constexpr (OPT) {
1461-
if (Policy::isMissing()) {
1462-
return {nullptr, {0, 0}};
1463-
}
1462+
if (Policy::isMissing()) {
1463+
return {nullptr, {0, 0}};
14641464
}
14651465
return Policy::getSliceFor(value, input);
14661466
}
14671467

14681468
std::span<const int64_t> getSliceFor(int value) const
14691469
{
1470-
if constexpr (OPT) {
1471-
if (Policy::isMissing()) {
1472-
return {};
1473-
}
1470+
if (Policy::isMissing()) {
1471+
return {};
14741472
}
14751473
return Policy::getSliceFor(value);
14761474
}
@@ -1526,10 +1524,8 @@ template <typename T, typename C, typename Policy, bool OPT>
15261524
requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
15271525
auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const& container, int value)
15281526
{
1529-
if constexpr (OPT) {
1530-
if (container.isMissing()) {
1531-
missingOptionalPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
1532-
}
1527+
if (container.isMissing()) {
1528+
missingPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
15331529
}
15341530
auto out = container.getSliceFor(value, table->asArrowTableRef());
15351531
auto t = typename T::self_t({out});
@@ -1568,10 +1564,8 @@ template <typename T, typename C, typename Policy, bool OPT>
15681564
requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
15691565
auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const& container, int value)
15701566
{
1571-
if constexpr (OPT) {
1572-
if (container.isMissing()) {
1573-
missingOptionalPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
1574-
}
1567+
if (container.isMissing()) {
1568+
missingPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
15751569
}
15761570
auto selection = container.getSliceFor(value);
15771571
return doSliceByHelper(table, selection);
@@ -1601,10 +1595,8 @@ template <soa::is_filtered_table T, typename C, bool OPT>
16011595
requires(o2::soa::is_binding_compatible_v<C, T>())
16021596
auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase<C, framework::PreslicePolicySorted, OPT> const& container, int value)
16031597
{
1604-
if constexpr (OPT) {
1605-
if (container.isMissing()) {
1606-
missingOptionalPreslice(getLabelFromType<T>().data(), container.bindingKey.key.c_str());
1607-
}
1598+
if (container.isMissing()) {
1599+
missingPreslice(getLabelFromType<T>().data(), container.bindingKey.key.c_str());
16081600
}
16091601
auto slice = container.getSliceFor(value, table->asArrowTableRef());
16101602
return prepareFilteredSlice(table, slice);

‎Framework/Core/include/Framework/AnalysisManagers.h‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,8 @@ template <is_preslice T>
638638
requires std::same_as<typename T::policy_t, framework::PreslicePolicySorted>
639639
bool registerCache(T& preslice, Cache& bsks, Cache&)
640640
{
641-
if constexpr (T::optional) {
642-
if (preslice.binding == "[MISSING]") {
643-
return true;
644-
}
641+
if (preslice.isMissing()) {
642+
return true;
645643
}
646644
auto locate = std::find(bsks.begin(), bsks.end(), preslice.getBindingKey());
647645
if (locate == bsks.end()) {
@@ -656,10 +654,8 @@ template <is_preslice T>
656654
requires std::same_as<typename T::policy_t, framework::PreslicePolicyGeneral>
657655
bool registerCache(T& preslice, Cache&, Cache& bsksU)
658656
{
659-
if constexpr (T::optional) {
660-
if (preslice.binding == "[MISSING]") {
661-
return true;
662-
}
657+
if (preslice.isMissing()) {
658+
return true;
663659
}
664660
auto locate = std::find(bsksU.begin(), bsksU.end(), preslice.getBindingKey());
665661
if (locate == bsksU.end()) {
@@ -688,10 +684,8 @@ template <is_preslice T>
688684
static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache)
689685
requires std::same_as<typename T::policy_t, framework::PreslicePolicySorted>
690686
{
691-
if constexpr (T::optional) {
692-
if (preslice.binding == "[MISSING]") {
693-
return true;
694-
}
687+
if (preslice.isMissing()) {
688+
return true;
695689
}
696690
preslice.updateSliceInfo(cache.getCacheFor(preslice.getBindingKey()));
697691
return true;
@@ -701,10 +695,8 @@ template <is_preslice T>
701695
static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache)
702696
requires std::same_as<typename T::policy_t, framework::PreslicePolicyGeneral>
703697
{
704-
if constexpr (T::optional) {
705-
if (preslice.binding == "[MISSING]") {
706-
return true;
707-
}
698+
if (preslice.isMissing()) {
699+
return true;
708700
}
709701
preslice.updateSliceInfo(cache.getCacheUnsortedFor(preslice.getBindingKey()));
710702
return true;

‎Framework/Core/src/ASoA.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ void notFoundColumn(const char* label, const char* key)
235235
throw o2::framework::runtime_error_f(R"(Preslice not valid: table "%s" (or join based on it) does not have column "%s")", label, key);
236236
}
237237

238-
void missingOptionalPreslice(const char* label, const char* key)
238+
void missingPreslice(const char* label, const char* key)
239239
{
240-
throw o2::framework::runtime_error_f(R"(Optional Preslice with missing binding used: table "%s" (or join based on it) does not have column "%s")", label, key);
240+
throw o2::framework::runtime_error_f(R"(Preslice with missing binding used: table "%s" (or join based on it) does not have column "%s")", label, key);
241241
}
242242

243243
void* extractCCDBPayload(char* payload, size_t size, TClass const* cl, const char* what)
@@ -327,7 +327,7 @@ std::string strToUpper(std::string&& str)
327327

328328
bool PreslicePolicyBase::isMissing() const
329329
{
330-
return binding == "[MISSING]";
330+
return bindingKey.binding == "[MISSING]";
331331
}
332332

333333
Entry const& PreslicePolicyBase::getBindingKey() const

0 commit comments

Comments
 (0)