Skip to content

Commit 9740d9a

Browse files
committed
make it compile
1 parent c0883a7 commit 9740d9a

12 files changed

Lines changed: 54 additions & 82 deletions

Framework/Core/include/Framework/ASoA.h

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void missingFilterDeclaration(int hash, int ai);
5858
void notBoundTable(const char* tableName);
5959
void* extractCCDBPayload(char* payload, size_t size, TClass const* cl, const char* what);
6060

61-
static constexpr char asciiToLower(char c);
61+
constexpr char asciiToLower(char c);
6262

6363
template <typename... C>
6464
auto createFieldsFromColumns(framework::pack<C...>)
@@ -1254,6 +1254,8 @@ struct ArrowHelpers {
12541254
static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables);
12551255
static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables, std::span<const char* const> labels);
12561256
static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables, std::span<const std::string> labels);
1257+
static o2::soa::ArrowTableRef joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels);
1258+
static o2::soa::ArrowTableRef joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string> labels);
12571259
static o2::soa::ArrowTableRef concatTables(std::vector<o2::soa::ArrowTableRef>&& tables);
12581260
static o2::soa::ArrowTableRef concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
12591261
};
@@ -1448,7 +1450,7 @@ struct PresliceBase : public Policy {
14481450
{
14491451
if constexpr (OPT) {
14501452
if (Policy::isMissing()) {
1451-
return nullptr;
1453+
return {nullptr, {0,0}};
14521454
}
14531455
}
14541456
return Policy::getSliceFor(value, input);
@@ -1522,7 +1524,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
15221524
}
15231525
}
15241526
auto out = container.getSliceFor(value, table->asArrowTableRef());
1525-
auto t = typename T::self_t({out}, offset);
1527+
auto t = typename T::self_t({out});
15261528
if (t.tableSize() != 0) {
15271529
table->copyIndexBindings(t);
15281530
t.bindInternalIndicesTo(table);
@@ -1608,7 +1610,7 @@ auto doSliceByCached(T const* table, framework::expressions::BindingNode const&
16081610
auto localCache = cache.ptr->getCacheFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
16091611
node.name});
16101612
auto [offset, count] = localCache.getSliceFor(value);
1611-
auto t = typename T::self_t({table->asArrowTableRef().slice(static_cast<uint64_t>(offset), count)});
1613+
auto t = typename T::self_t({table->asArrowTableRef().slice({static_cast<uint64_t>(offset), count})});
16121614
if (t.tableSize() != 0) {
16131615
table->copyIndexBindings(t);
16141616
}
@@ -3342,28 +3344,14 @@ struct Join : Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod:
33423344
{};
33433345
using base = Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...>;
33443346

3345-
Join(ArrowTableRef table)
3346-
: base{table}
3347+
Join(std::vector<ArrowTableRef>&& tables)
3348+
: base{ArrowHelpers::joinTables(std::move(tables))}
33473349
{
33483350
if (this->tableSize() != 0) {
33493351
bindInternalIndicesTo(this);
33503352
}
33513353
}
33523354

3353-
Join(std::shared_ptr<arrow::Table> table)
3354-
: Join{ArrowTableRef{table}}
3355-
{
3356-
}
3357-
3358-
Join(std::vector<ArrowTableRef>&& tables)
3359-
: Join{ArrowHelpers::joinTables(std::move(tables))}
3360-
{
3361-
}
3362-
3363-
Join(std::vector<std::shared_ptr<arrow::Table>>&& tables)
3364-
: Join{ArrowHelpers::joinTables(std::move(tables), std::span{base::originalLabels})}
3365-
{
3366-
}
33673355
using base::bindExternalIndices;
33683356
using base::bindInternalIndicesTo;
33693357
static constexpr const uint32_t binding_origin = base::binding_origin;
@@ -3433,12 +3421,12 @@ struct Join : Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod:
34333421

34343422
auto rawSlice(uint64_t start, uint64_t end) const
34353423
{
3436-
return self_t{{this->asArrowTable()->Slice(start, end - start + 1)}, start};
3424+
return self_t{{this->asArrowTableRef().slice({start, static_cast<int64_t>(end - start + 1)})}};
34373425
}
34383426

34393427
auto emptySlice() const
34403428
{
3441-
return self_t{{this->asArrowTable()->Slice(0, 0)}, 0};
3429+
return self_t{{this->asArrowTableRef().slice({0, 0})}};
34423430
}
34433431

34443432
template <typename T>
@@ -3453,7 +3441,7 @@ struct Join : Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod:
34533441
template <typename... Ts>
34543442
constexpr auto join(Ts const&... t)
34553443
{
3456-
return Join<Ts...>(ArrowHelpers::joinTables({t.asArrowTable()...}, std::span{Join<Ts...>::base::originalLabels}));
3444+
return Join<Ts...>({ArrowHelpers::joinTables({t.asArrowTableRef()...}, std::span{Join<Ts...>::base::originalLabels})});
34573445
}
34583446

34593447
template <typename T>
@@ -3485,10 +3473,10 @@ struct Concat : Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::ao
34853473
{
34863474
}
34873475

3488-
// Concat(Ts const&... t)
3489-
// : Concat{ArrowHelpers::concatTables({t.asArrowTableRef()...})}
3490-
// {
3491-
// }
3476+
Concat(Ts const&... t)
3477+
: Concat{ArrowHelpers::concatTables({t.asArrowTableRef()...})}
3478+
{
3479+
}
34923480

34933481
using base::originals;
34943482

@@ -3514,7 +3502,7 @@ constexpr auto concat(Ts const&... t)
35143502
}
35153503

35163504
template <typename S>
3517-
concept is_a_selection = std::same_as<S, gandiva::Selection const&> || std::same_as<S, SelectionVector&&> || std::same_as<S, std::span<int64_t const> const&>;
3505+
concept is_a_selection = std::same_as<std::decay_t<S>, gandiva::Selection> || std::same_as<std::decay_t<S>, SelectionVector> || std::same_as<std::decay_t<S>, std::span<int64_t const>>;
35183506

35193507
template <soa::is_table T>
35203508
class FilteredBase : public T
@@ -3557,15 +3545,6 @@ class FilteredBase : public T
35573545
mFilteredBegin.bindInternalIndices(this);
35583546
}
35593547

3560-
FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, is_a_selection auto selection)
3561-
: FilteredBase([](std::vector<std::shared_ptr<arrow::Table>>&& ts) -> std::vector<ArrowTableRef>{
3562-
std::vector<ArrowTableRef> rs;
3563-
std::ranges::transform(ts, std::back_inserter(rs), [](auto const& t){ return ArrowTableRef{t}; });
3564-
return rs;
3565-
}(tables), selection)
3566-
{
3567-
}
3568-
35693548
iterator begin()
35703549
{
35713550
return iterator(mFilteredBegin);
@@ -3801,13 +3780,6 @@ class Filtered : public FilteredBase<T>
38013780
Filtered(std::vector<ArrowTableRef>&& tables, is_a_selection auto selection)
38023781
: FilteredBase<T>{std::move(tables), selection} {}
38033782

3804-
Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, is_a_selection auto selection)
3805-
: FilteredBase<T>{[](std::vector<std::shared_ptr<arrow::Table>>&& ts) -> std::vector<ArrowTableRef>{
3806-
std::vector<ArrowTableRef> rs;
3807-
std::ranges::transform(ts, std::back_inserter(rs), [](auto const& t){ return ArrowTableRef{t}; });
3808-
return rs;
3809-
}(tables), selection} {}
3810-
38113783
Filtered<T> operator+(is_a_selection auto selection)
38123784
{
38133785
Filtered<T> copy(*this);

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ auto spawner(framework::pack<C...>, std::vector<std::shared_ptr<arrow::Table>>&&
147147
if (fullTable->num_rows() == 0) {
148148
return makeEmptyTable(name, framework::pack<C...>{});
149149
}
150-
return spawnerHelper(fullTable, schema, sizeof...(C), projectors, name, projector);
150+
return spawnerHelper(fullTable.tablePtr, schema, sizeof...(C), projectors, name, projector);
151151
}
152152

153153
std::string serializeProjectors(std::vector<framework::expressions::Projector>& projectors);
@@ -951,7 +951,7 @@ auto getTableFromFilter(soa::is_filtered_table auto const& table, soa::Selection
951951

952952
auto getTableFromFilter(soa::is_not_filtered_table auto const& table, soa::SelectionVector&& selection)
953953
{
954-
return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table.asArrowTable()}, std::forward<soa::SelectionVector>(selection));
954+
return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table.asArrowTableRef()}, std::forward<soa::SelectionVector>(selection));
955955
}
956956

957957
void initializePartitionCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter);
@@ -1087,7 +1087,7 @@ auto Extend(T const& table)
10871087
static std::array<framework::expressions::Projector, sizeof...(Cs)> projectors{{std::move(Cs::Projector())...}};
10881088
static std::shared_ptr<gandiva::Projector> projector = nullptr;
10891089
static auto schema = std::make_shared<arrow::Schema>(o2::soa::createFieldsFromColumns(framework::pack<Cs...>{}));
1090-
return output_t{{o2::framework::spawner(framework::pack<Cs...>{}, {table.asArrowTable()}, "dynamicExtension", projectors.data(), projector, schema), table.asArrowTable()}, 0};
1090+
return output_t{{o2::framework::spawner(framework::pack<Cs...>{}, {table.asArrowTable()}, "dynamicExtension", projectors.data(), projector, schema), table.asArrowTable()}};
10911091
}
10921092

10931093
/// Template function to attach dynamic columns on-the-fly (e.g. inside

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ bool prepareOutput(ProcessingContext& context, T& spawns)
319319
}
320320
using D = o2::aod::Hash<metadata::extension_table_t::ref.desc_hash>;
321321

322-
spawns.extension = std::make_shared<typename T::extension_t>(o2::framework::spawner<D>(originalTable,
322+
spawns.extension = std::make_shared<typename T::extension_t>(o2::framework::spawner<D>(originalTable.tablePtr,
323323
o2::aod::label<metadata::extension_table_t::ref>(),
324324
spawns.projectors.data(),
325325
spawns.projector,
326326
spawns.schema));
327-
spawns.table = std::make_shared<typename T::spawnable_t::table_t>(soa::ArrowHelpers::joinTables({spawns.extension->asArrowTable(), originalTable}, std::span{T::spawnable_t::table_t::originalLabels}));
327+
spawns.table = std::make_shared<typename T::spawnable_t::table_t>(soa::ArrowHelpers::joinTables({spawns.extension->asArrowTableRef(), originalTable}, std::span{T::spawnable_t::table_t::originalLabels}));
328328
return true;
329329
}
330330

Framework/Core/include/Framework/AnalysisTask.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct AnalysisDataProcessorBuilder {
226226
template <std::ranges::input_range R>
227227
static auto extractTablesFromRecord(InputRecord& record, R matchers)
228228
{
229-
std::vector<std::shared_ptr<arrow::Table>> tables;
229+
std::vector<soa::ArrowTableRef> tables;
230230
std::ranges::transform(matchers, std::back_inserter(tables), [&record](auto const& m) {
231231
return record.get<TableConsumer>(m.second)->asArrowTable();
232232
});
@@ -248,8 +248,8 @@ struct AnalysisDataProcessorBuilder {
248248
template <soa::is_filtered T, std::ranges::input_range R>
249249
static auto extractFilteredFromRecord(InputRecord& record, R matchers, ExpressionInfo& info)
250250
{
251-
std::shared_ptr<arrow::Table> table = soa::ArrowHelpers::joinTables(extractTablesFromRecord(record, matchers));
252-
expressions::updateFilterInfo(info, table);
251+
auto table = soa::ArrowHelpers::joinTables(extractTablesFromRecord(record, matchers));
252+
expressions::updateFilterInfo(info, table.tablePtr);
253253
if constexpr (!o2::soa::is_smallgroups<std::decay_t<T>>) {
254254
if (info.selection == nullptr) {
255255
soa::missingFilterDeclaration(info.processHash, info.argumentIndex);

Framework/Core/include/Framework/GroupSlicer.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,7 @@ struct GroupSlicer {
218218
auto oc = sliceInfos[index].getSliceFor(pos);
219219
uint64_t offset = oc.first;
220220
auto count = oc.second;
221-
if (count == 0) {
222-
// Empty group: avoid slicing every column only to discard it. Cache one
223-
// empty (0-row) table per associated table and reuse it. This is the
224-
// common case for sparse grouping (e.g. collisions with no candidates).
225-
if (!emptyTables[index]) {
226-
emptyTables[index] = originalTable.asArrowTable()->Slice(0, 0);
227-
}
228-
return std::decay_t<A1>{{emptyTables[index]}, soa::SelectionVector{}};
229-
}
230-
auto groupedElementsTable = originalTable.asArrowTable()->Slice(offset, count);
221+
auto groupedElementsTable = originalTable.asArrowTableRef().slice({offset, count});
231222

232223
// for each grouping element we need to slice the selection vector
233224
auto start_iterator = std::lower_bound(starts[index], selections[index]->end(), offset);
@@ -239,7 +230,7 @@ struct GroupSlicer {
239230
return idx - static_cast<int64_t>(offset);
240231
});
241232

242-
std::decay_t<A1> typedTable{{groupedElementsTable}, std::move(slicedSelection), offset};
233+
std::decay_t<A1> typedTable{{groupedElementsTable}, std::move(slicedSelection)};
243234
typedTable.bindInternalIndicesTo(&originalTable);
244235
return typedTable;
245236
}
@@ -281,9 +272,6 @@ struct GroupSlicer {
281272
std::span<int64_t const> groupSelection;
282273
std::array<std::span<int64_t const> const*, sizeof...(A)> selections;
283274
std::array<std::span<int64_t const>::iterator, sizeof...(A)> starts;
284-
// Cached empty (0-row) table per associated table, lazily built and reused
285-
// for empty groups so we do not slice every column on each empty group.
286-
std::array<std::shared_ptr<arrow::Table>, sizeof...(A)> emptyTables{};
287275

288276
std::array<SliceInfoPtr, sizeof...(A)> sliceInfos;
289277
std::array<SliceInfoUnsortedPtr, sizeof...(A)> sliceInfosUnsorted;

Framework/Core/src/ASoA.cxx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ o2::soa::ArrowTableRef ArrowHelpers::joinTables(std::vector<o2::soa::ArrowTableR
159159
return joinTablesImpl(tables, labels);
160160
}
161161

162+
o2::soa::ArrowTableRef ArrowHelpers::joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels)
163+
{
164+
canNotJoin(tables, labels);
165+
return o2::soa::ArrowTableRef{joinTablesImpl(tables)};
166+
}
167+
168+
o2::soa::ArrowTableRef ArrowHelpers::joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string> labels)
169+
{
170+
canNotJoin(tables, labels);
171+
return o2::soa::ArrowTableRef{joinTablesImpl(tables)};
172+
}
173+
162174
o2::soa::ArrowTableRef ArrowHelpers::concatTables(std::vector<o2::soa::ArrowTableRef>&& tables)
163175
{
164176
if (tables.size() == 1) {
@@ -204,7 +216,7 @@ o2::soa::ArrowTableRef ArrowHelpers::concatTables(std::vector<std::shared_ptr<ar
204216
// ASCII-only lowercase. Column labels are plain identifiers, so we deliberately
205217
// avoid the locale-aware std::tolower: it goes through the C locale facet on
206218
// every character and dominated getIndexFromLabel in profiles.
207-
static constexpr char asciiToLower(char c)
219+
constexpr char asciiToLower(char c)
208220
{
209221
return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + 32) : c;
210222
}
@@ -351,7 +363,7 @@ void PreslicePolicyGeneral::updateSliceInfo(SliceInfoUnsortedPtr&& si)
351363
o2::soa::ArrowTableRef PreslicePolicySorted::getSliceFor(int value, o2::soa::ArrowTableRef const& input) const
352364
{
353365
auto [offset_, count] = this->sliceInfo.getSliceFor(value);
354-
return input.slice({offset_, count});
366+
return input.slice({static_cast<uint64_t>(offset_), count});
355367
}
356368

357369
std::span<const int64_t> PreslicePolicyGeneral::getSliceFor(int value) const

Framework/Core/src/AnalysisHelpers.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ std::shared_ptr<arrow::Table> Spawner::materialize(ProcessingContext& pc) const
207207
return arrow::Table::MakeEmpty(schema).ValueOrDie();
208208
}
209209

210-
return spawnerHelper(fullTable, schema, binding.c_str(), schema->num_fields(), projector);
210+
return spawnerHelper(fullTable.tablePtr, schema, binding.c_str(), schema->num_fields(), projector);
211211
}
212212

213213
std::shared_ptr<arrow::Table> Builder::materialize(ProcessingContext& pc)

Framework/Core/test/test_ASoA.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ TEST_CASE("TestJoinedTables")
286286
REQUIRE(Test::contains<TestY>());
287287
REQUIRE(!Test::contains<TestZ>());
288288

289-
Test tests{{tableX, tableY}, 0};
289+
Test tests{{tableX, tableY}};
290290

291291
REQUIRE(tests.contains<TestX>());
292292
REQUIRE(tests.contains<TestY>());
@@ -308,7 +308,7 @@ TEST_CASE("TestJoinedTables")
308308
REQUIRE(15 == test.x() + test.y() + test.z());
309309
}
310310
using TestMoreThanTwo = Join<TestX, TestY, TestZ>;
311-
TestMoreThanTwo tests4{{tableX, tableY, tableZ}, 0};
311+
TestMoreThanTwo tests4{{tableX, tableY, tableZ}};
312312
for (auto& test : tests4) {
313313
REQUIRE(15 == test.x() + test.y() + test.z());
314314
}
@@ -480,7 +480,7 @@ TEST_CASE("TestConcatTables")
480480
selectionJoin->SetIndex(1, 2);
481481
selectionJoin->SetIndex(2, 4);
482482
selectionJoin->SetNumSlots(3);
483-
JoinedTest testJoin{{tableA, tableC}, 0};
483+
JoinedTest testJoin{{tableA, tableC}};
484484
FilteredJoinTest filteredJoin{{testJoin.asArrowTable()}, selectionJoin};
485485

486486
i = 0;
@@ -718,7 +718,7 @@ TEST_CASE("TestEmptyTables")
718718
o2::aod::Infos i{iempty};
719719

720720
using PI = Join<o2::aod::Points, o2::aod::Infos>;
721-
PI pi{{pempty, iempty}, 0};
721+
PI pi{{pempty, iempty}};
722722
REQUIRE(pi.size() == 0);
723723
auto spawned = Extend<o2::aod::Points, o2::aod::test::ESum>(p);
724724
REQUIRE(spawned.size() == 0);
@@ -1084,7 +1084,7 @@ TEST_CASE("TestSelfIndexRecursion")
10841084
}
10851085

10861086
using FilteredPoints = o2::soa::Filtered<FullPoints>;
1087-
FilteredPoints ffp({t1, t2}, {1, 2, 3}, 0);
1087+
FilteredPoints ffp({t1, t2}, SelectionVector{1, 2, 3});
10881088
ffp.bindInternalIndicesTo(&ffp);
10891089

10901090
// Filter should not interfere with self-index and the binding should stay the same

Framework/Core/test/test_AnalysisDataModel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_CASE("TestJoinedTablesContains")
4949

5050
using Test = o2::soa::Join<XY, ZD>;
5151

52-
Test tests{{tXY, tZD}, 0};
52+
Test tests{{tXY, tZD}};
5353
REQUIRE(tests.asArrowTable()->num_columns() != 0);
5454
REQUIRE(tests.asArrowTable()->num_columns() ==
5555
tXY->num_columns() + tZD->num_columns());

Framework/Core/test/test_Concepts.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ TEST_CASE("IdentificationConcepts")
121121

122122
REQUIRE(is_join<o2::aod::Tracks>);
123123

124-
auto tl = []() -> SmallGroups<o2::aod::Collisions> { return {std::vector<std::shared_ptr<arrow::Table>>{}, SelectionVector{}, 0}; };
124+
auto tl = []() -> SmallGroups<o2::aod::Collisions> { return {{}, SelectionVector{}}; };
125125
REQUIRE(is_smallgroups<decltype(tl())>);
126126

127127
// AnalysisHelpers

0 commit comments

Comments
 (0)