Skip to content

Commit 622bcca

Browse files
committed
DPL: drop obsolete TreeToTable code
Now using the arrow::Dataset API.
1 parent dd2d2aa commit 622bcca

File tree

7 files changed

+0
-707
lines changed

7 files changed

+0
-707
lines changed

Framework/Core/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ add_executable(o2-test-framework-core
250250
test/test_Variants.cxx
251251
test/test_WorkflowHelpers.cxx
252252
test/test_WorkflowSerialization.cxx
253-
test/test_TreeToTable.cxx
254253
test/test_DataOutputDirector.cxx
255254
test/unittest_SimpleOptionsRetriever.cxx
256255
test/unittest_DataSpecUtils.cxx
@@ -348,7 +347,6 @@ foreach(b
348347
EventMixing
349348
HistogramRegistry
350349
TableToTree
351-
TreeToTable
352350
ExternalFairMQDeviceProxies
353351
)
354352
o2_add_executable(benchmark-${b}

Framework/Core/include/Framework/DataAllocator.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@ class DataAllocator
233233
return tb;
234234
}
235235

236-
template <typename T, typename... Args>
237-
requires(requires { static_cast<struct TreeToTable>(std::declval<std::decay_t<T>>()); })
238-
decltype(auto) make(const Output& spec, Args... args)
239-
{
240-
auto t2t = std::move(LifetimeHolder<TreeToTable>(new std::decay_t<T>(args...)));
241-
adopt(spec, t2t);
242-
return t2t;
243-
}
244-
245236
template <typename T, typename... Args>
246237
requires(requires { static_cast<struct FragmentToBatch>(std::declval<std::decay_t<T>>()); })
247238
decltype(auto) make(const Output& spec, Args... args)
@@ -288,11 +279,6 @@ class DataAllocator
288279
void
289280
adopt(const Output& spec, LifetimeHolder<struct TableBuilder>&);
290281

291-
/// Adopt a Tree2Table in the framework and serialise / send
292-
/// it as an Arrow table to all consumers of @a spec once done
293-
void
294-
adopt(const Output& spec, LifetimeHolder<struct TreeToTable>&);
295-
296282
/// Adopt a Source2Batch in the framework and serialise / send
297283
/// it as an Arrow Dataset to all consumers of @a spec once done
298284
void

Framework/Core/include/Framework/TableTreeHelpers.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ namespace o2::framework
3636
// OR t2t.addBranch(column.get(), field.get()), ...;
3737
// . t2t.process();
3838
//
39-
// .............................................................................
40-
// -----------------------------------------------------------------------------
41-
// TreeToTable allows to fill the contents of a given TTree to an arrow::Table
42-
// ColumnIterator is used by TreeToTable
43-
//
44-
// To copy the contents of a tree tr to a table ta do:
45-
// . TreeToTable t2t(tr);
46-
// . t2t.addColumn(columnname1); t2t.addColumn(columnname2); ...
47-
// OR
48-
// t2t.addAllColumns();
49-
// . auto ta = t2t.process();
50-
//
51-
// .............................................................................
5239
struct ROOTTypeInfo {
5340
EDataType type;
5441
char suffix[3];
@@ -58,29 +45,6 @@ struct ROOTTypeInfo {
5845
auto arrowTypeFromROOT(EDataType type, int size);
5946
auto basicROOTTypeFromArrow(arrow::Type::type id);
6047

61-
class BranchToColumn
62-
{
63-
public:
64-
BranchToColumn(TBranch* branch, bool VLA, std::string name, EDataType type, int listSize, arrow::MemoryPool* pool);
65-
// BranchToColumn(TBranch* branch, TBranch* sizeBranch, std::string name, EDataType type, arrow::MemoryPool* pool);
66-
~BranchToColumn() = default;
67-
TBranch* branch();
68-
69-
std::pair<std::shared_ptr<arrow::ChunkedArray>, std::shared_ptr<arrow::Field>> read(TBuffer* buffer);
70-
71-
private:
72-
TBranch* mBranch = nullptr;
73-
bool mVLA = false;
74-
std::string mColumnName;
75-
EDataType mType;
76-
std::shared_ptr<arrow::DataType> mArrowType;
77-
arrow::ArrayBuilder* mValueBuilder = nullptr;
78-
std::unique_ptr<arrow::ArrayBuilder> mListBuilder = nullptr;
79-
int mListSize = 1;
80-
std::unique_ptr<arrow::ArrayBuilder> mBuilder = nullptr;
81-
arrow::MemoryPool* mPool = nullptr;
82-
};
83-
8448
class ColumnToBranch
8549
{
8650
public:
@@ -127,24 +91,6 @@ class TableToTree
12791
std::vector<std::unique_ptr<ColumnToBranch>> mColumnReaders;
12892
};
12993

130-
class TreeToTable
131-
{
132-
public:
133-
TreeToTable(arrow::MemoryPool* pool = arrow::default_memory_pool());
134-
void setLabel(const char* label);
135-
void addAllColumns(TTree* tree, std::vector<std::string>&& names = {});
136-
void fill(TTree*);
137-
std::shared_ptr<arrow::Table> finalize();
138-
139-
private:
140-
arrow::MemoryPool* mArrowMemoryPool;
141-
std::vector<std::unique_ptr<BranchToColumn>> mBranchReaders;
142-
std::string mTableLabel;
143-
std::shared_ptr<arrow::Table> mTable;
144-
145-
void addReader(TBranch* branch, std::string const& name, bool VLA);
146-
};
147-
14894
class FragmentToBatch
14995
{
15096
public:

Framework/Core/src/DataAllocator.cxx

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -241,38 +241,6 @@ void DataAllocator::adopt(const Output& spec, LifetimeHolder<TableBuilder>& tb)
241241
context.addBuffer(std::move(header), buffer, std::move(finalizer), routeIndex);
242242
}
243243

244-
void DataAllocator::adopt(const Output& spec, LifetimeHolder<TreeToTable>& t2t)
245-
{
246-
auto& timingInfo = mRegistry.get<TimingInfo>();
247-
RouteIndex routeIndex = matchDataHeader(spec, timingInfo.timeslice);
248-
249-
auto header = headerMessageFromOutput(spec, routeIndex, o2::header::gSerializationMethodArrow, 0);
250-
auto& context = mRegistry.get<ArrowContext>();
251-
252-
auto creator = [transport = context.proxy().getOutputTransport(routeIndex)](size_t s) -> std::unique_ptr<fair::mq::Message> {
253-
return transport->CreateMessage(s);
254-
};
255-
auto buffer = std::make_shared<FairMQResizableBuffer>(creator);
256-
257-
t2t.callback = [buffer = buffer, transport = context.proxy().getOutputTransport(routeIndex)](TreeToTable& tree) {
258-
// Serialization happens in here, so that we can
259-
// get rid of the intermediate tree 2 table object, saving memory.
260-
auto table = tree.finalize();
261-
doWriteTable(buffer, table.get());
262-
// deletion happens in the caller
263-
};
264-
265-
/// To finalise this we write the table to the buffer.
266-
/// FIXME: most likely not a great idea. We should probably write to the buffer
267-
/// directly in the TableBuilder, incrementally.
268-
auto finalizer = [](std::shared_ptr<FairMQResizableBuffer> b) -> void {
269-
// This is empty because we already serialised the object when
270-
// the LifetimeHolder goes out of scope.
271-
};
272-
273-
context.addBuffer(std::move(header), buffer, std::move(finalizer), routeIndex);
274-
}
275-
276244
void DataAllocator::adopt(const Output& spec, LifetimeHolder<FragmentToBatch>& f2b)
277245
{
278246
auto& timingInfo = mRegistry.get<TimingInfo>();

0 commit comments

Comments
 (0)