46 static constexpr std::uint64_t gUpdateFrequencyBytes = 100 * 1000 * 1000;
47 std::uint64_t fNbytesNext = gUpdateFrequencyBytes;
57 fNbytesNext += gUpdateFrequencyBytes;
75 *
reinterpret_cast<std::string *
>(
field.fFieldBuffer) =
reinterpret_cast<const char *
>(
branch.fBranchBuffer.get());
79std::unique_ptr<ROOT::Experimental::RNTupleImporter>
96 importer->fSourceTree->SetImplicitMT(
false);
105std::unique_ptr<ROOT::Experimental::RNTupleImporter>
121 importer->fSourceTree->SetImplicitMT(
false);
144 std::cout <<
"Importing '" <<
f.fField->GetFieldName() <<
"' [" <<
f.fField->GetTypeName() <<
"]\n";
147 std::cout <<
"Importing (projected) '" <<
f->GetFieldName() <<
"' [" <<
f->GetTypeName() <<
"]\n";
170 const auto firstLeaf =
static_cast<TLeaf *
>(
b->GetListOfLeaves()->First());
177 return R__FAIL(
"unsupported: classes in leaf list, branch " + std::string(
b->GetName()));
179 return R__FAIL(
"unsupported: count leaf arrays in leaf list, branch " + std::string(
b->GetName()));
195 c.fCountVal = std::make_unique<Int_t>();
204 std::vector<std::unique_ptr<ROOT::RFieldBase>>
recordItems;
210 return R__FAIL(
"unsupported: TObject branches, branch: " + std::string(
b->GetName()));
250 f.fValue = std::make_unique<ROOT::RFieldBase::RValue>(
field->CreateValue());
251 f.fFieldBuffer =
f.fValue->GetPtr<
void>().get();
273 R__ASSERT(
b->GetListOfLeaves()->GetEntries() == 1);
289 ib.fBranchName =
b->GetName();
294 return R__FAIL(
"unable to load class " + std::string(
b->GetClassName()) +
" for branch " +
295 std::string(
b->GetName()));
297 auto ptrBuf =
reinterpret_cast<void **
>(
ib.fBranchBuffer.get());
306 isClass ? *
reinterpret_cast<void **
>(
ib.fBranchBuffer.get()) :
ib.fBranchBuffer.get();
320 auto recordField = std::make_unique<ROOT::RRecordField>(
"_0", std::move(
c.fLeafFields));
326 for (
const auto leaf :
c.fRecordField->GetConstSubfields()) {
327 const auto name =
leaf->GetFieldName();
334 return c.fFieldName +
"._0." +
name;
351 for (
auto &
field :
fModel->GetMutableFieldZero()) {
360 fEntry->BindRawPtr(
f.fField->GetFieldName(),
f.fFieldBuffer);
363 fEntry->BindRawPtr<
void>(
c.fFieldName, &
c.fFieldBuffer);
379 std::unique_ptr<ROOT::Internal::RPageSink>
sink =
381 sink->GetMetrics().Enable();
385 sink = std::make_unique<ROOT::Internal::RPageSinkBuf>(std::move(
sink));
407 const auto nLeafs =
c.fRecordField->GetConstSubfields().size();
408 for (std::size_t
l = 0;
l <
nLeafs; ++
l) {
409 const auto offset =
c.fRecordField->GetOffsets()[
l];
410 const auto sizeOfLeaf =
c.fRecordField->GetConstSubfields()[
l]->GetValueSize();
412 for (
Int_t j = 0;
j < *
c.fCountVal; ++
j) {
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
winID h TVirtualViewer3D TVirtualGLPainter p
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 offset
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 result
Used to report every ~100 MB (compressed), and at the end about the status of the import.
bool fConvertDotsInBranchNames
Whether or not dot characters in branch names should be converted to underscores.
std::unique_ptr< ROOT::REntry > fEntry
std::unique_ptr< TFile > fDestFile
std::int64_t fMaxEntries
The maximum number of entries to import. When this value is -1 (default), import all entries.
std::map< std::string, RImportLeafCountCollection > fLeafCountCollections
Maps the count leaf to the information about the corresponding untyped collection.
RNTupleImporter()=default
std::unique_ptr< ROOT::RNTupleModel > fModel
std::vector< RImportBranch > fImportBranches
ROOT::RResult< void > InitDestination(std::string_view destFileName)
static std::unique_ptr< RNTupleImporter > Create(std::string_view sourceFileName, std::string_view treeName, std::string_view destFileName)
Opens the input file for reading and the output file for writing (update).
std::unique_ptr< RProgressCallback > fProgressCallback
void Import()
Import works in two steps:
ROOT::RNTupleWriteOptions fWriteOptions
std::string fDestFileName
bool fIsQuiet
No standard output, conversely if set to false, schema information and progress is printed.
std::vector< RImportField > fImportFields
FieldModifier_t fFieldModifier
std::vector< std::unique_ptr< RImportTransformation > > fImportTransformations
The list of transformations to be performed for every entry.
ROOT::RResult< void > PrepareSchema()
Sets up the connection from TTree branches to RNTuple fields, including initialization of the memory ...
ROOT::RFieldZero & GetFieldZero()
Base class for all ROOT issued exceptions.
std::vector< const RFieldBase * > GetConstSubfields() const
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
static std::unique_ptr< RNTupleModel > CreateBare()
Creates a "bare model", i.e. an RNTupleModel with no default entry.
bool GetUseBufferedWrite() const
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
static std::unique_ptr< RVectorField > CreateUntyped(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
TClass * IsA() const override
virtual const char * GetName() const
Returns name of object.
A TTree represents a columnar dataset.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
virtual Long64_t GetEntries() const
virtual TObjArray * GetListOfBranches()
std::unique_ptr< RNTupleWriter > CreateRNTupleWriter(std::unique_ptr< ROOT::RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink)
RProjectedFields & GetProjectedFieldsOfModel(RNTupleModel &model)
ROOT::RFieldBase * fField
The field is kept during schema preparation and transferred to the fModel before the writing starts.
When the schema is set up and the import started, it needs to be reset before the next Import() call ...
Leaf count arrays require special treatment.
Int_t fMaxLength
Stores count leaf GetMaximum() to create large enough buffers for the array leafs.