Skip to content

Commit 7d97a97

Browse files
committed
cleanup
1 parent 7ddffeb commit 7d97a97

File tree

5 files changed

+9
-388
lines changed

5 files changed

+9
-388
lines changed

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,6 @@ struct Spawns : decltype(transformBase<T>()) {
595595
using expression_pack_t = typename metadata::expression_pack_t;
596596
static constexpr size_t N = framework::pack_size(expression_pack_t{});
597597

598-
static consteval auto pack()
599-
{
600-
return expression_pack_t{};
601-
}
602-
603598
typename T::table_t* operator->()
604599
{
605600
return table.get();
@@ -651,11 +646,6 @@ struct Defines : decltype(transformBase<T>()) {
651646
using placeholders_pack_t = typename metadata::placeholders_pack_t;
652647
static constexpr size_t N = framework::pack_size(placeholders_pack_t{});
653648

654-
constexpr auto pack()
655-
{
656-
return placeholders_pack_t{};
657-
}
658-
659649
typename T::table_t* operator->()
660650
{
661651
return table.get();
@@ -674,7 +664,11 @@ struct Defines : decltype(transformBase<T>()) {
674664

675665
std::array<o2::framework::expressions::Projector, N> projectors;
676666
std::shared_ptr<gandiva::Projector> projector = nullptr;
677-
std::shared_ptr<arrow::Schema> schema = std::make_shared<arrow::Schema>(o2::soa::createFieldsFromColumns(placeholders_pack_t{}));
667+
std::shared_ptr<arrow::Schema> schema = []() {
668+
auto s = std::make_shared<arrow::Schema>(o2::soa::createFieldsFromColumns(placeholders_pack_t{}));
669+
s->WithMetadata(std::make_shared<arrow::KeyValueMetadata>(std::vector{std::string{"label"}}, std::vector{std::string{o2::aod::label<T::ref>()}}));
670+
return s;
671+
}();
678672
std::shared_ptr<arrow::Schema> inputSchema = nullptr;
679673

680674
bool needRecompilation = false;

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,8 @@ bool prepareOutput(ProcessingContext& context, T& defines)
304304
{
305305
using metadata = o2::aod::MetadataTrait<o2::aod::Hash<T::spawnable_t::ref.desc_hash>>::metadata;
306306
auto originalTable = soa::ArrowHelpers::joinTables(extractOriginals<metadata::sources.size(), metadata::sources>(context), std::span{metadata::base_table_t::originalLabels});
307-
if (originalTable->schema()->fields().empty() == true) {
308-
using base_table_t = typename T::base_table_t::table_t;
309-
originalTable = makeEmptyTable<base_table_t>(o2::aod::label<metadata::extension_table_t::ref>());
307+
if (originalTable->num_rows() == 0) {
308+
originalTable = makeEmptyTable<metadata::base_table_t::ref>();
310309
}
311310
if (defines.inputSchema == nullptr) {
312311
defines.inputSchema = originalTable->schema();
@@ -337,9 +336,8 @@ bool prepareDelayedOutput(ProcessingContext& context, T& defines)
337336
}
338337
using metadata = o2::aod::MetadataTrait<o2::aod::Hash<T::spawnable_t::ref.desc_hash>>::metadata;
339338
auto originalTable = soa::ArrowHelpers::joinTables(extractOriginals<metadata::sources.size(), metadata::sources>(context), std::span{metadata::base_table_t::originalLabels});
340-
if (originalTable->schema()->fields().empty() == true) {
341-
using base_table_t = typename T::base_table_t::table_t;
342-
originalTable = makeEmptyTable<base_table_t>(o2::aod::label<metadata::extension_table_t::ref>());
339+
if (originalTable->num_rows() == 0) {
340+
originalTable = makeEmptyTable<metadata::base_table_t::ref>();
343341
}
344342
if (defines.inputSchema == nullptr) {
345343
defines.inputSchema = originalTable->schema();

Framework/Core/include/Framework/IndexBuilderHelpers.h

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -118,106 +118,6 @@ struct IndexColumnBuilderNG {
118118
void fill(int idx);
119119
std::shared_ptr<arrow::ChunkedArray> result() const;
120120
};
121-
122-
// struct SelfIndexColumnBuilder {
123-
// SelfIndexColumnBuilder(const char* name, arrow::MemoryPool* pool);
124-
// virtual ~SelfIndexColumnBuilder() = default;
125-
126-
// inline std::shared_ptr<arrow::ChunkedArray> result() const
127-
// {
128-
// std::shared_ptr<arrow::Array> array;
129-
// auto status = static_cast<arrow::Int32Builder*>(mBuilder.get())->Finish(&array);
130-
// if (!status.ok()) {
131-
// cannotBuildAnArray();
132-
// }
133-
134-
// return std::make_shared<arrow::ChunkedArray>(array);
135-
// }
136-
137-
// inline bool find(int)
138-
// {
139-
// return true;
140-
// }
141-
142-
// inline void fill(int idx)
143-
// {
144-
// (void)static_cast<arrow::Int32Builder*>(mBuilder.get())->Append(idx);
145-
// }
146-
147-
// std::string mColumnName;
148-
// std::unique_ptr<arrow::ArrayBuilder> mBuilder = nullptr;
149-
// };
150-
151-
// class IndexColumnBuilder : public SelfIndexColumnBuilder, public ChunkedArrayIterator
152-
// {
153-
// public:
154-
// IndexColumnBuilder(std::shared_ptr<arrow::ChunkedArray> source, const char* name, int listSize, arrow::MemoryPool* pool);
155-
// ~IndexColumnBuilder() override = default;
156-
157-
// inline std::shared_ptr<arrow::ChunkedArray> result() const
158-
// {
159-
// if (mListSize == -1) {
160-
// return resultMulti();
161-
// } else if (mListSize == 2) {
162-
// return resultSlice();
163-
// } else {
164-
// return resultSingle();
165-
// }
166-
// }
167-
168-
// inline bool find(int idx)
169-
// {
170-
// if (mListSize == -1) {
171-
// return findMulti(idx);
172-
// } else if (mListSize == 2) {
173-
// return findSlice(idx);
174-
// } else {
175-
// return findSingle(idx);
176-
// }
177-
// }
178-
179-
// inline void fill(int idx)
180-
// {
181-
// ++mResultSize;
182-
// if (mListSize == -1) {
183-
// fillMulti(idx);
184-
// } else if (mListSize == 2) {
185-
// fillSlice(idx);
186-
// } else {
187-
// fillSingle(idx);
188-
// }
189-
// }
190-
191-
// private:
192-
// arrow::Status preSlice();
193-
// arrow::Status preFind();
194-
195-
// bool findSingle(int idx);
196-
// bool findSlice(int idx);
197-
// bool findMulti(int idx);
198-
199-
// void fillSingle(int idx);
200-
// void fillSlice(int idx);
201-
// void fillMulti(int idx);
202-
203-
// std::shared_ptr<arrow::ChunkedArray> resultSingle() const;
204-
// std::shared_ptr<arrow::ChunkedArray> resultSlice() const;
205-
// std::shared_ptr<arrow::ChunkedArray> resultMulti() const;
206-
207-
// int mListSize = 1;
208-
// arrow::ArrayBuilder* mValueBuilder = nullptr;
209-
// std::unique_ptr<arrow::ArrayBuilder> mListBuilder = nullptr;
210-
211-
// size_t mSourceSize = 0;
212-
// size_t mResultSize = 0;
213-
214-
// std::shared_ptr<arrow::NumericArray<arrow::Int32Type>> mValuesArrow = nullptr;
215-
// std::shared_ptr<arrow::NumericArray<arrow::Int64Type>> mCounts = nullptr;
216-
// std::vector<int> mValues;
217-
// std::vector<std::vector<int>> mIndices;
218-
// int mFillOffset = 0;
219-
// int mValuePos = 0;
220-
// };
221121
} // namespace o2::framework
222122

223123
#endif // O2_FRAMEWORK_INDEXBUILDERHELPERS_H_

Framework/Core/src/AnalysisHelpers.cxx

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -85,94 +85,6 @@ std::shared_ptr<arrow::Table> IndexBuilder::materializeNG(std::vector<framework:
8585

8686
return arrow::Table::Make(schema, arrays);
8787
}
88-
89-
// std::shared_ptr<arrow::Table> IndexBuilder::materialize(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::vector<soa::IndexRecord> const& records, std::shared_ptr<arrow::Schema> const& schema, bool exclusive)
90-
// {
91-
// auto pool = arrow::default_memory_pool();
92-
// std::vector<std::shared_ptr<framework::SelfIndexColumnBuilder>> builders; // this needs to become a state to avoid reallocations
93-
// // can builders be reset and re-used?
94-
// framework::SelfIndexColumnBuilder self{records[0].columnLabel.c_str(), pool};
95-
// std::unique_ptr<framework::ChunkedArrayIterator> keyIndex = nullptr;
96-
// if (records[0].kind != soa::IndexKind::IdxSelf) {
97-
// keyIndex = std::make_unique<framework::ChunkedArrayIterator>(tables[0]->column(records[0].pos));
98-
// }
99-
100-
// for (auto i = 1U; i < records.size(); ++i) {
101-
// if (records[i].kind == soa::IndexKind::IdxSelf) {
102-
// builders.emplace_back(std::make_shared<framework::SelfIndexColumnBuilder>(records[i].columnLabel.c_str(), pool));
103-
// } else {
104-
// builders.emplace_back(
105-
// std::make_shared<framework::IndexColumnBuilder>(
106-
// tables[i]->column(records[i].pos),
107-
// records[i].columnLabel.c_str(),
108-
// [](IndexKind kind) {
109-
// switch (kind) {
110-
// case IndexKind::IdxSingle:
111-
// return 1;
112-
// case IndexKind::IdxSlice:
113-
// return 2;
114-
// case IndexKind::IdxArray:
115-
// return -1;
116-
// default:
117-
// return -2;
118-
// }
119-
// }(records[i].kind),
120-
// pool));
121-
// }
122-
// }
123-
124-
// std::vector<bool> finds;
125-
// finds.resize(builders.size());
126-
// for (int64_t counter = 0; counter < tables[0]->num_rows(); ++counter) {
127-
// int64_t idx = -1;
128-
// if (keyIndex == nullptr) {
129-
// idx = counter;
130-
// } else {
131-
// idx = keyIndex->valueAt(counter);
132-
// }
133-
// for (auto i = 0U; i < builders.size(); ++i) {
134-
// if (records[i+1].kind == soa::IndexKind::IdxSelf) {
135-
// finds[i] = builders[i]->find(idx);
136-
// } else {
137-
// finds[i] = std::static_pointer_cast<framework::IndexColumnBuilder>(builders[i])->find(idx);
138-
// }
139-
// }
140-
// if (exclusive) {
141-
// if (std::none_of(finds.begin(), finds.end(), [](bool const x) { return x == false; })) {
142-
// for (auto i = 0U; i < builders.size(); ++i) {
143-
// if (records[i+1].kind == soa::IndexKind::IdxSelf) {
144-
// builders[i]->fill(idx);
145-
// } else {
146-
// std::static_pointer_cast<framework::IndexColumnBuilder>(builders[i])->fill(idx);
147-
// }
148-
// }
149-
// self.fill(counter);
150-
// }
151-
// } else {
152-
// for (auto i = 0U; i < builders.size(); ++i) {
153-
// if (records[i+1].kind == soa::IndexKind::IdxSelf) {
154-
// builders[i]->fill(idx);
155-
// } else {
156-
// std::static_pointer_cast<framework::IndexColumnBuilder>(builders[i])->fill(idx);
157-
// }
158-
// }
159-
// self.fill(counter);
160-
// }
161-
// }
162-
163-
// std::vector<std::shared_ptr<arrow::ChunkedArray>> arrays; // same
164-
// arrays.reserve(records.size());
165-
// arrays.push_back(self.result());
166-
// for (auto i = 0U; i < builders.size(); ++i) {
167-
// if (records[i+1].kind == soa::IndexKind::IdxSelf) {
168-
// arrays.push_back(builders[i]->result());
169-
// } else {
170-
// arrays.push_back(std::static_pointer_cast<framework::IndexColumnBuilder>(builders[i])->result());
171-
// }
172-
// }
173-
174-
// return arrow::Table::Make(schema, arrays);
175-
// }
17688
} // namespace o2::soa
17789

17890
namespace o2::framework

0 commit comments

Comments
 (0)