Skip to content

Commit 2c44b9f

Browse files
committed
fixup! cleanup
1 parent 7d97a97 commit 2c44b9f

File tree

6 files changed

+30
-28
lines changed

6 files changed

+30
-28
lines changed

Framework/AnalysisSupport/src/AODReaderHelpers.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ struct Buildable {
7272
outputSchema,
7373
origin,
7474
description,
75-
version, nullptr};
75+
version,
76+
nullptr};
7677
}
7778

7879
};

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ struct IndexRecord {
6060
};
6161

6262
struct IndexBuilder {
63-
static std::vector<framework::IndexColumnBuilderNG> makeBuilders(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records);
64-
static void resetBuilders(std::vector<framework::IndexColumnBuilderNG>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables);
63+
static std::vector<framework::IndexColumnBuilder> makeBuilders(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records);
64+
static void resetBuilders(std::vector<framework::IndexColumnBuilder>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables);
6565

66-
// static std::shared_ptr<arrow::Table> materialize(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive);
67-
static std::shared_ptr<arrow::Table> materializeNG(std::vector<framework::IndexColumnBuilderNG>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive);
66+
static std::shared_ptr<arrow::Table> materialize(std::vector<framework::IndexColumnBuilder>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive);
6867
};
6968
} // namespace o2::soa
7069

@@ -165,7 +164,7 @@ struct Builder {
165164
header::DataDescription description;
166165
header::DataHeader::SubSpecificationType version;
167166

168-
std::shared_ptr<std::vector<framework::IndexColumnBuilderNG>> builders = nullptr;
167+
std::shared_ptr<std::vector<framework::IndexColumnBuilder>> builders = nullptr;
169168

170169
std::shared_ptr<arrow::Table> materialize(ProcessingContext& pc);
171170
};
@@ -722,7 +721,7 @@ struct Builds : decltype(transformBase<T>()) {
722721

723722
std::vector<soa::IndexRecord> map = soa::getIndexMapping<metadata>();
724723

725-
std::vector<framework::IndexColumnBuilderNG> builders;
724+
std::vector<framework::IndexColumnBuilder> builders;
726725

727726
T* operator->()
728727
{
@@ -746,7 +745,7 @@ struct Builds : decltype(transformBase<T>()) {
746745

747746
auto build(std::vector<std::shared_ptr<arrow::Table>>&& tables)
748747
{
749-
this->table = std::make_shared<T>(soa::IndexBuilder::materializeNG(builders, std::forward<std::vector<std::shared_ptr<arrow::Table>>>(tables), map, outputSchema, metadata::exclusive));
748+
this->table = std::make_shared<T>(soa::IndexBuilder::materialize(builders, std::forward<std::vector<std::shared_ptr<arrow::Table>>>(tables), map, outputSchema, metadata::exclusive));
750749
return (this->table != nullptr);
751750
}
752751
};

Framework/Core/include/Framework/IndexBuilderHelpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ struct ArrayBuilder : public ChunkedArrayIterator {
107107
arrow::Status preFind();
108108
};
109109

110-
struct IndexColumnBuilderNG {
110+
struct IndexColumnBuilder {
111111
std::variant<std::monostate, SelfBuilder, SingleBuilder, SliceBuilder, ArrayBuilder> builder;
112112
size_t mResultSize = 0;
113113
int mColumnPos = -1;
114-
IndexColumnBuilderNG(soa::IndexKind kind, int pos, arrow::MemoryPool* pool, std::shared_ptr<arrow::ChunkedArray> source = nullptr);
114+
IndexColumnBuilder(soa::IndexKind kind, int pos, arrow::MemoryPool* pool, std::shared_ptr<arrow::ChunkedArray> source = nullptr);
115115
void reset(std::shared_ptr<arrow::ChunkedArray> source = nullptr);
116116

117117
bool find(int idx);

Framework/Core/src/AnalysisHelpers.cxx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#include "IndexJSONHelpers.h"
1515

1616
namespace o2::soa {
17-
std::vector<framework::IndexColumnBuilderNG> IndexBuilder::makeBuilders(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records)
17+
std::vector<framework::IndexColumnBuilder> IndexBuilder::makeBuilders(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records)
1818
{
19-
std::vector<framework::IndexColumnBuilderNG> builders;
19+
std::vector<framework::IndexColumnBuilder> builders;
20+
builders.reserve(records.size());
2021
auto pool = arrow::default_memory_pool();
2122
builders.emplace_back(IndexKind::IdxSelf, records[0].pos, pool);
2223
if (records[0].pos >= 0) {
@@ -30,7 +31,7 @@ std::vector<framework::IndexColumnBuilderNG> IndexBuilder::makeBuilders(std::vec
3031
return builders;
3132
}
3233

33-
void IndexBuilder::resetBuilders(std::vector<framework::IndexColumnBuilderNG>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables)
34+
void IndexBuilder::resetBuilders(std::vector<framework::IndexColumnBuilder>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables)
3435
{
3536
for (auto i = 0U; i < builders.size(); ++i) {
3637
builders[i].reset(builders[i].mColumnPos >= 0 ? tables[i]->column(builders[i].mColumnPos) : nullptr);
@@ -41,7 +42,7 @@ void IndexBuilder::resetBuilders(std::vector<framework::IndexColumnBuilderNG>& b
4142
}
4243
}
4344

44-
std::shared_ptr<arrow::Table> IndexBuilder::materializeNG(std::vector<framework::IndexColumnBuilderNG>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive)
45+
std::shared_ptr<arrow::Table> IndexBuilder::materialize(std::vector<framework::IndexColumnBuilder>& builders, std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive)
4546
{
4647
auto size = tables[0]->num_rows();
4748
if (builders.empty()) {
@@ -77,7 +78,7 @@ std::shared_ptr<arrow::Table> IndexBuilder::materializeNG(std::vector<framework:
7778
}
7879
}
7980

80-
std::vector<std::shared_ptr<arrow::ChunkedArray>> arrays; // same
81+
std::vector<std::shared_ptr<arrow::ChunkedArray>> arrays;
8182
arrays.reserve(builders.size());
8283
for (auto& builder : builders) {
8384
arrays.push_back(builder.result());
@@ -206,11 +207,12 @@ std::shared_ptr<arrow::Table> Spawner::materialize(ProcessingContext& pc) const
206207
std::shared_ptr<arrow::Table> Builder::materialize(ProcessingContext& pc)
207208
{
208209
if (builders == nullptr) {
209-
builders = std::make_shared<std::vector<framework::IndexColumnBuilderNG>>();
210+
builders = std::make_shared<std::vector<framework::IndexColumnBuilder>>();
211+
builders->reserve(records.size());
210212
}
211213
std::shared_ptr<arrow::Table> result;
212214
auto tables = extractSources(pc, labels);
213-
result = o2::soa::IndexBuilder::materializeNG(*builders.get(), std::move(tables), records, outputSchema, exclusive);
215+
result = o2::soa::IndexBuilder::materialize(*builders.get(), std::move(tables), records, outputSchema, exclusive);
214216
return result;
215217
}
216218
} // namespace o2::framework

Framework/Core/src/ExpressionJSONHelpers.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ struct SchemaReader : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, Sch
681681

682682
bool StartArray()
683683
{
684-
debug << "Starting array" << std::endl;
684+
debug << "StartArray()" << std::endl;
685685
if (states.top() == State::IN_START && currentKey.compare("fields") == 0) {
686686
states.push(State::IN_LIST);
687687
return true;
@@ -692,7 +692,7 @@ struct SchemaReader : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, Sch
692692

693693
bool EndArray(SizeType)
694694
{
695-
debug << "Ending array" << std::endl;
695+
debug << "EndArray()" << std::endl;
696696
if (states.top() == State::IN_LIST) {
697697
// finalize schema
698698
schema = std::make_shared<arrow::Schema>(fields);

Framework/Core/src/IndexBuilderHelpers.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace o2::framework
2323
{
2424
void cannotBuildAnArray()
2525
{
26-
throw framework::runtime_error("Cannot build an array");
26+
throw framework::runtime_error("Cannot finish an array");
2727
}
2828

2929
void cannotCreateIndexBuilder()
@@ -138,7 +138,7 @@ std::shared_ptr<arrow::ChunkedArray> SingleBuilder::result() const
138138
std::shared_ptr<arrow::Array> array;
139139
auto status = static_cast<arrow::Int32Builder*>(mBuilder.get())->Finish(&array);
140140
if (!status.ok()) {
141-
throw runtime_error("Cannot build an array");
141+
cannotBuildAnArray();
142142
}
143143
return std::make_shared<arrow::ChunkedArray>(array);
144144
}
@@ -211,7 +211,7 @@ std::shared_ptr<arrow::ChunkedArray> SliceBuilder::result() const
211211
std::shared_ptr<arrow::Array> array;
212212
auto status = static_cast<arrow::FixedSizeListBuilder*>(mListBuilder.get())->Finish(&array);
213213
if (!status.ok()) {
214-
throw runtime_error("Cannot build an array");
214+
cannotBuildAnArray();
215215
}
216216
return std::make_shared<arrow::ChunkedArray>(array);
217217
}
@@ -274,7 +274,7 @@ std::shared_ptr<arrow::ChunkedArray> ArrayBuilder::result() const
274274
std::shared_ptr<arrow::Array> array;
275275
auto status = static_cast<arrow::ListBuilder*>(mListBuilder.get())->Finish(&array);
276276
if (!status.ok()) {
277-
throw runtime_error("Cannot build an array");
277+
cannotBuildAnArray();
278278
}
279279
return std::make_shared<arrow::ChunkedArray>(array);
280280
}
@@ -301,7 +301,7 @@ arrow::Status ArrayBuilder::preFind()
301301
return arrow::Status::OK();
302302
}
303303

304-
IndexColumnBuilderNG::IndexColumnBuilderNG(soa::IndexKind kind, int pos, arrow::MemoryPool* pool, std::shared_ptr<arrow::ChunkedArray> source)
304+
IndexColumnBuilder::IndexColumnBuilder(soa::IndexKind kind, int pos, arrow::MemoryPool* pool, std::shared_ptr<arrow::ChunkedArray> source)
305305
: mColumnPos{pos}
306306
{
307307
switch (kind) {
@@ -322,7 +322,7 @@ IndexColumnBuilderNG::IndexColumnBuilderNG(soa::IndexKind kind, int pos, arrow::
322322
}
323323
}
324324

325-
void IndexColumnBuilderNG::reset(std::shared_ptr<arrow::ChunkedArray> source)
325+
void IndexColumnBuilder::reset(std::shared_ptr<arrow::ChunkedArray> source)
326326
{
327327
std::visit(
328328
overloaded{
@@ -331,7 +331,7 @@ void IndexColumnBuilderNG::reset(std::shared_ptr<arrow::ChunkedArray> source)
331331
builder);
332332
}
333333

334-
bool IndexColumnBuilderNG::find(int idx)
334+
bool IndexColumnBuilder::find(int idx)
335335
{
336336
return std::visit(
337337
overloaded{
@@ -341,7 +341,7 @@ bool IndexColumnBuilderNG::find(int idx)
341341
builder);
342342
}
343343

344-
void IndexColumnBuilderNG::fill(int idx)
344+
void IndexColumnBuilder::fill(int idx)
345345
{
346346
std::visit(
347347
overloaded{
@@ -350,7 +350,7 @@ void IndexColumnBuilderNG::fill(int idx)
350350
builder);
351351
}
352352

353-
std::shared_ptr<arrow::ChunkedArray> IndexColumnBuilderNG::result() const
353+
std::shared_ptr<arrow::ChunkedArray> IndexColumnBuilder::result() const
354354
{
355355
return std::visit(
356356
overloaded{

0 commit comments

Comments
 (0)