Skip to content

Commit

Permalink
DPL Analysis: out-of-line throws
Browse files Browse the repository at this point in the history
  • Loading branch information
aalkin committed Jan 6, 2025
1 parent 1d6f86c commit a82dc1c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,9 @@ class Table
template <uint32_t D, soa::is_column... C>
using InPlaceTable = Table<o2::aod::Hash<"TEST"_h>, o2::aod::Hash<D>, o2::aod::Hash<"TEST"_h>, C...>;

void getterNotFound(const char* targetColumnLabel);
void emptyColumnLabel();

namespace row_helpers
{
template <soa::is_persistent_column... Cs>
Expand Down Expand Up @@ -2232,7 +2235,7 @@ ColumnGetterFunction<R, T> getColumnGetterByLabel(o2::framework::pack<Cs...>, co
(void)((func = createGetterPtr<R, T, Cs>(targetColumnLabel), func) || ...);

if (!func) {
throw framework::runtime_error_f("Getter for \"%s\" not found", targetColumnLabel);
getterNotFound(targetColumnLabel.data());
}

return func;
Expand All @@ -2248,7 +2251,7 @@ ColumnGetterFunction<R, typename T::iterator> getColumnGetterByLabel(const std::
using TypesWithCommonGetter = o2::framework::selected_pack_multicondition<with_common_getter_t, framework::pack<R>, typename T::columns_t>;

if (targetColumnLabel.size() == 0) {
throw framework::runtime_error("columnLabel: must not be empty");
emptyColumnLabel();
}

return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
Expand Down
7 changes: 4 additions & 3 deletions Framework/Core/include/Framework/ASoAHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "Framework/ASoA.h"
#include "Framework/BinningPolicy.h"
#include "Framework/RuntimeError.h"
#include <arrow/table.h>

#include <iterator>
Expand Down Expand Up @@ -72,6 +71,8 @@ inline bool diffCategory(BinningIndex const& a, BinningIndex const& b)
return a.bin >= b.bin;
}

void dataSizeVariesBetweenColumns();

template <template <typename... Cs> typename BP, typename T, typename... Cs>
std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPolicy, int minCatSize, int outsider)
{
Expand All @@ -98,7 +99,7 @@ std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPol
auto chunksCount = arrowColumns[0]->num_chunks();
for (int i = 1; i < persistentColumnsCount; i++) {
if (arrowColumns[i]->num_chunks() != chunksCount) {
throw o2::framework::runtime_error("Combinations: data size varies between selected columns");
dataSizeVariesBetweenColumns();
}
}

Expand All @@ -107,7 +108,7 @@ std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPol
auto chunkLength = std::get<0>(chunks)->length();
for_<persistentColumnsCount - 1>([&chunks, &chunkLength](auto i) {
if (std::get<i.value + 1>(chunks)->length() != chunkLength) {
throw o2::framework::runtime_error("Combinations: data size varies between selected columns");
dataSizeVariesBetweenColumns();
}
});

Expand Down
5 changes: 3 additions & 2 deletions Framework/Core/include/Framework/IndexBuilderHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#ifndef O2_FRAMEWORK_INDEXBUILDERHELPERS_H_
#define O2_FRAMEWORK_INDEXBUILDERHELPERS_H_
#include "Framework/RuntimeError.h"
#include "arrow/array.h"
#include <arrow/chunked_array.h>
#include <arrow/builder.h>
Expand All @@ -22,6 +21,8 @@

namespace o2::framework
{
void cannotBuildAnArray();

struct ChunkedArrayIterator {
ChunkedArrayIterator(std::shared_ptr<arrow::ChunkedArray> source);
virtual ~ChunkedArrayIterator() = default;
Expand Down Expand Up @@ -51,7 +52,7 @@ struct SelfIndexColumnBuilder {
std::shared_ptr<arrow::Array> array;
auto status = static_cast<arrow::Int32Builder*>(mBuilder.get())->Finish(&array);
if (!status.ok()) {
throw runtime_error("Cannot build an array");
cannotBuildAnArray();
}

return std::make_shared<arrow::ChunkedArray>(array);
Expand Down
10 changes: 10 additions & 0 deletions Framework/Core/src/ASoA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ void missingFilterDeclaration(int hash, int ai)
throw o2::framework::runtime_error_f("Null selection for %d (arg %d), missing Filter declaration?", hash, ai);
}

void getterNotFound(const char* targetColumnLabel)
{
throw o2::framework::runtime_error_f("Getter for \"%s\" not found", targetColumnLabel);
}

void emptyColumnLabel()
{
throw framework::runtime_error("columnLabel: must not be empty");
}

SelectionVector selectionToVector(gandiva::Selection const& sel)
{
SelectionVector rows;
Expand Down
22 changes: 22 additions & 0 deletions Framework/Core/src/ASoAHelpers.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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/ASoA.h"
#include "ArrowDebugHelpers.h"
#include "Framework/RuntimeError.h"

namespace o2::soa
{
void dataSizeVariesBetweenColumns()
{
throw o2::framework::runtime_error("Combinations: data size varies between selected columns");
}
}
6 changes: 6 additions & 0 deletions Framework/Core/src/IndexBuilderHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include "Framework/RuntimeError.h"
#include "Framework/IndexBuilderHelpers.h"
#include "Framework/CompilerBuiltins.h"
#include <arrow/compute/api_aggregate.h>
Expand All @@ -19,6 +20,11 @@

namespace o2::framework
{
void cannotBuildAnArray()
{
throw runtime_error("Cannot build an array");
}

ChunkedArrayIterator::ChunkedArrayIterator(std::shared_ptr<arrow::ChunkedArray> source)
: mSource{source}
{
Expand Down

0 comments on commit a82dc1c

Please sign in to comment.