11#ifndef O2_FRAMEWORK_TABLETREEHELPERS_H_
12#define O2_FRAMEWORK_TABLETREEHELPERS_H_
14#include <arrow/record_batch.h>
16#include "TTreeReader.h"
17#include "TTreeReaderValue.h"
18#include "TTreeReaderArray.h"
20#include <arrow/dataset/file_base.h>
67 std::pair<std::shared_ptr<arrow::ChunkedArray>, std::shared_ptr<arrow::Field>>
read(TBuffer*
buffer);
70 TBranch* mBranch =
nullptr;
72 std::string mColumnName;
74 std::shared_ptr<arrow::DataType> mArrowType;
75 arrow::ArrayBuilder* mValueBuilder =
nullptr;
76 std::unique_ptr<arrow::ArrayBuilder> mListBuilder =
nullptr;
78 std::unique_ptr<arrow::ArrayBuilder> mBuilder =
nullptr;
79 arrow::MemoryPool* mPool =
nullptr;
85 ColumnToBranch(TTree*
tree, std::shared_ptr<arrow::ChunkedArray>
const& column, std::shared_ptr<arrow::Field>
const& field);
88 void at(
const int64_t*
pos);
89 [[nodiscard]]
int fieldSize()
const {
return mFieldSize; }
91 [[nodiscard]]
char const*
branchName()
const {
return mBranchName.c_str(); }
97 std::string mBranchName;
98 TBranch* mBranch =
nullptr;
99 TBranch* mSizeBranch =
nullptr;
100 arrow::ChunkedArray* mColumn =
nullptr;
101 int64_t mFirstIndex = 0;
102 int mCurrentChunk = 0;
105 arrow::Type::type mFieldType;
106 std::vector<uint8_t> cache;
107 std::shared_ptr<arrow::Array> mCurrentArray =
nullptr;
108 int64_t mChunkLength = 0;
115 TableToTree(std::shared_ptr<arrow::Table>
const& table, TFile*
file,
const char* treename);
117 std::shared_ptr<TTree>
process();
118 void addBranch(std::shared_ptr<arrow::ChunkedArray>
const& column, std::shared_ptr<arrow::Field>
const& field);
122 arrow::Table* mTable;
124 std::shared_ptr<TTree> mTree;
125 std::vector<std::unique_ptr<ColumnToBranch>> mColumnReaders;
131 TreeToTable(arrow::MemoryPool* pool = arrow::default_memory_pool());
135 std::shared_ptr<arrow::Table>
finalize();
138 arrow::MemoryPool* mArrowMemoryPool;
139 std::vector<std::unique_ptr<BranchToColumn>> mBranchReaders;
140 std::string mTableLabel;
141 std::shared_ptr<arrow::Table> mTable;
143 void addReader(TBranch* branch, std::string
const&
name,
bool VLA);
149 FragmentToBatch(arrow::MemoryPool* pool = arrow::default_memory_pool());
151 void fill(std::shared_ptr<arrow::dataset::FileFragment>, std::shared_ptr<arrow::Schema> dataSetSchema, std::shared_ptr<arrow::dataset::FileFormat>);
152 std::shared_ptr<arrow::RecordBatch>
finalize();
155 arrow::MemoryPool* mArrowMemoryPool =
nullptr;
156 std::string mTableLabel;
157 std::shared_ptr<arrow::RecordBatch> mRecordBatch;
std::pair< std::shared_ptr< arrow::ChunkedArray >, std::shared_ptr< arrow::Field > > read(TBuffer *buffer)
~BranchToColumn()=default
ColumnToBranch(ColumnToBranch &&other)=delete
int columnEntries() const
ColumnToBranch(ColumnToBranch const &other)=delete
void at(const int64_t *pos)
char const * branchName() const
void fill(std::shared_ptr< arrow::dataset::FileFragment >, std::shared_ptr< arrow::Schema > dataSetSchema, std::shared_ptr< arrow::dataset::FileFormat >)
std::shared_ptr< arrow::RecordBatch > finalize()
void setLabel(const char *label)
void addBranch(std::shared_ptr< arrow::ChunkedArray > const &column, std::shared_ptr< arrow::Field > const &field)
std::shared_ptr< TTree > process()
void addAllColumns(TTree *tree, std::vector< std::string > &&names={})
void setLabel(const char *label)
std::shared_ptr< arrow::Table > finalize()
GLuint const GLchar * name
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei const GLchar * label
Defining PrimaryVertex explicitly as messageable.
auto basicROOTTypeFromArrow(arrow::Type::type id)
auto arrowTypeFromROOT(EDataType type, int size)
VectorOfTObjectPtrs other
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))