Skip to content

Commit 4a1f6f8

Browse files
aalkinktf
authored andcommitted
DPL Analysis: out-of-line throws
1 parent 9ede2d5 commit 4a1f6f8

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-7
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,9 @@ class Table
21262126
template <uint32_t D, soa::is_column... C>
21272127
using InPlaceTable = Table<o2::aod::Hash<"TEST"_h>, o2::aod::Hash<D>, o2::aod::Hash<"TEST"_h>, C...>;
21282128

2129+
void getterNotFound(const char* targetColumnLabel);
2130+
void emptyColumnLabel();
2131+
21292132
namespace row_helpers
21302133
{
21312134
template <soa::is_persistent_column... Cs>
@@ -2232,7 +2235,7 @@ ColumnGetterFunction<R, T> getColumnGetterByLabel(o2::framework::pack<Cs...>, co
22322235
(void)((func = createGetterPtr<R, T, Cs>(targetColumnLabel), func) || ...);
22332236

22342237
if (!func) {
2235-
throw framework::runtime_error_f("Getter for \"%s\" not found", targetColumnLabel);
2238+
getterNotFound(targetColumnLabel.data());
22362239
}
22372240

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

22502253
if (targetColumnLabel.size() == 0) {
2251-
throw framework::runtime_error("columnLabel: must not be empty");
2254+
emptyColumnLabel();
22522255
}
22532256

22542257
return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);

Framework/Core/include/Framework/ASoAHelpers.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "Framework/ASoA.h"
1616
#include "Framework/BinningPolicy.h"
17-
#include "Framework/RuntimeError.h"
1817
#include <arrow/table.h>
1918

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

74+
void dataSizeVariesBetweenColumns();
75+
7576
template <template <typename... Cs> typename BP, typename T, typename... Cs>
7677
std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPolicy, int minCatSize, int outsider)
7778
{
@@ -98,7 +99,7 @@ std::vector<BinningIndex> groupTable(const T& table, const BP<Cs...>& binningPol
9899
auto chunksCount = arrowColumns[0]->num_chunks();
99100
for (int i = 1; i < persistentColumnsCount; i++) {
100101
if (arrowColumns[i]->num_chunks() != chunksCount) {
101-
throw o2::framework::runtime_error("Combinations: data size varies between selected columns");
102+
dataSizeVariesBetweenColumns();
102103
}
103104
}
104105

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

Framework/Core/include/Framework/IndexBuilderHelpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#ifndef O2_FRAMEWORK_INDEXBUILDERHELPERS_H_
1313
#define O2_FRAMEWORK_INDEXBUILDERHELPERS_H_
14-
#include "Framework/RuntimeError.h"
1514
#include "arrow/array.h"
1615
#include <arrow/chunked_array.h>
1716
#include <arrow/builder.h>
@@ -22,6 +21,8 @@
2221

2322
namespace o2::framework
2423
{
24+
void cannotBuildAnArray();
25+
2526
struct ChunkedArrayIterator {
2627
ChunkedArrayIterator(std::shared_ptr<arrow::ChunkedArray> source);
2728
virtual ~ChunkedArrayIterator() = default;
@@ -51,7 +52,7 @@ struct SelfIndexColumnBuilder {
5152
std::shared_ptr<arrow::Array> array;
5253
auto status = static_cast<arrow::Int32Builder*>(mBuilder.get())->Finish(&array);
5354
if (!status.ok()) {
54-
throw runtime_error("Cannot build an array");
55+
cannotBuildAnArray();
5556
}
5657

5758
return std::make_shared<arrow::ChunkedArray>(array);

Framework/Core/src/ASoA.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ void missingFilterDeclaration(int hash, int ai)
3030
throw o2::framework::runtime_error_f("Null selection for %d (arg %d), missing Filter declaration?", hash, ai);
3131
}
3232

33+
void getterNotFound(const char* targetColumnLabel)
34+
{
35+
throw o2::framework::runtime_error_f("Getter for \"%s\" not found", targetColumnLabel);
36+
}
37+
38+
void emptyColumnLabel()
39+
{
40+
throw framework::runtime_error("columnLabel: must not be empty");
41+
}
42+
3343
SelectionVector selectionToVector(gandiva::Selection const& sel)
3444
{
3545
SelectionVector rows;

Framework/Core/src/ASoAHelpers.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include "Framework/ASoA.h"
13+
#include "ArrowDebugHelpers.h"
14+
#include "Framework/RuntimeError.h"
15+
16+
namespace o2::soa
17+
{
18+
void dataSizeVariesBetweenColumns()
19+
{
20+
throw o2::framework::runtime_error("Combinations: data size varies between selected columns");
21+
}
22+
}

Framework/Core/src/IndexBuilderHelpers.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include "Framework/RuntimeError.h"
1213
#include "Framework/IndexBuilderHelpers.h"
1314
#include "Framework/CompilerBuiltins.h"
1415
#include <arrow/compute/api_aggregate.h>
@@ -19,6 +20,11 @@
1920

2021
namespace o2::framework
2122
{
23+
void cannotBuildAnArray()
24+
{
25+
throw runtime_error("Cannot build an array");
26+
}
27+
2228
ChunkedArrayIterator::ChunkedArrayIterator(std::shared_ptr<arrow::ChunkedArray> source)
2329
: mSource{source}
2430
{

0 commit comments

Comments
 (0)