28 throw std::runtime_error(
"RBatchSink::FillBatch: batch has " + std::to_string(batch.
GetCols()) +
29 " columns, expected " + std::to_string(
fRowWidth));
32 for (std::size_t row = 0; row < batch.
GetRows(); row++)
37 std::vector<RColumnLayout> layout)
40 fTree =
new TTree(std::string(dataset_name).c_str(), std::string(dataset_name).c_str());
47 std::size_t vecIdx = 0;
48 for (
const auto &col :
fLayout) {
65 std::size_t vecIdx = 0;
66 for (
const auto &col :
fLayout) {
68 std::copy_n(row + col.fOffset, col.fWidth,
fVectorBuffers[vecIdx++].begin());
80 std::vector<RColumnLayout> layout)
86 for (
const auto &col :
fLayout) {
88 auto field = model->MakeField<std::vector<float>>(col.fName);
89 field->resize(col.fWidth);
93 auto field = model->MakeField<
float>(col.fName);
106 for (std::size_t i = 0; i <
fLayout.size(); i++)
117 std::vector<RColumnLayout> layout, std::string_view
format)
120 return std::make_unique<RTTreeBatchSink>(dataset_name,
filename, std::move(layout));
122 return std::make_unique<RNTupleBatchSink>(dataset_name,
filename, std::move(layout));
124 throw std::runtime_error(
"CreateBatchSink: unrecognised output format \"" + std::string(
format) +
125 "\", expected \"ttree\" or \"rntuple\"");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Writes RFlat2DMatrix batches to disk letting RDataLoaderEngine::Save() stay agnostic to the output fo...
std::vector< RColumnLayout > fLayout
void FillBatch(const RFlat2DMatrix &batch)
Write every row of batch.
virtual void FillRow(const float *row)=0
Copy one row of fRowWidth floats into the writer's buffers and write the entry.
std::vector< std::shared_ptr< std::vector< float > > > fVectorFields
void FillRow(const float *row) override
Copy one row of fRowWidth floats into the writer's buffers and write the entry.
void Commit() override
Flush everything to disk once after the last batch.
std::unique_ptr< ROOT::RNTupleWriter > fWriter
~RNTupleBatchSink() override
RNTupleBatchSink(std::string_view dataset_name, std::string_view filename, std::vector< RColumnLayout > layout)
std::vector< float * > fDestinations
std::vector< std::shared_ptr< float > > fScalarFields
void Commit() override
Flush everything to disk once after the last batch.
RTTreeBatchSink(std::string_view dataset_name, std::string_view filename, std::vector< RColumnLayout > layout)
std::vector< float > fRow
~RTTreeBatchSink() override
std::unique_ptr< TFile > fFile
void FillRow(const float *row) override
Copy one row of fRowWidth floats into the writer's buffers and write the entry.
std::vector< std::vector< float > > fVectorBuffers
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter backed by storage, overwriting it if one with the same URI exists.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
std::unique_ptr< RBatchSink > CreateBatchSink(std::string_view dataset_name, std::string_view filename, std::vector< RColumnLayout > layout, std::string_view format)
Create the sink matching format.
Where one of the loader's columns lives inside a batch-tensor row and how it's shaped.
Wrapper around ROOT::RVec<float> representing a 2D matrix.
std::size_t GetRows() const
std::size_t GetCols() const