46 static constexpr std::uint64_t gUpdateFrequencyBytes = 50 * 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());
89std::unique_ptr<ROOT::Experimental::RNTupleImporter>
106 importer->fSourceTree->SetImplicitMT(
false);
115std::unique_ptr<ROOT::Experimental::RNTupleImporter>
131 importer->fSourceTree->SetImplicitMT(
false);
154 std::cout <<
"Importing '" <<
f.fField->GetFieldName() <<
"' [" <<
f.fField->GetTypeName() <<
']' << std::endl;
177 const auto firstLeaf =
static_cast<TLeaf *
>(
b->GetListOfLeaves()->First());
184 return R__FAIL(
"unsupported: classes in leaf list, branch " + std::string(
b->GetName()));
186 return R__FAIL(
"unsupported: count leaf arrays in leaf list, branch " + std::string(
b->GetName()));
203 c.fCountVal = std::make_unique<Int_t>();
212 std::vector<std::unique_ptr<RFieldBase>>
recordItems;
215 return R__FAIL(
"unsupported: TObject branches, branch: " + std::string(
b->GetName()));
256 f.fValue = std::make_unique<RFieldBase::RValue>(
field->CreateValue());
257 f.fFieldBuffer =
f.fValue->GetPtr<
void>().get();
276 f.fValue = std::make_unique<RFieldBase::RValue>(
field->CreateValue());
277 f.fFieldBuffer =
f.fValue->GetPtr<
void>().get();
278 f.fIsInUntypedCollection =
true;
299 ib.fBranchName =
b->GetName();
304 return R__FAIL(
"unable to load class " + std::string(
b->GetClassName()) +
" for branch " +
305 std::string(
b->GetName()));
307 auto ptrBuf =
reinterpret_cast<void **
>(
ib.fBranchBuffer.get());
316 isClass ? *
reinterpret_cast<void **
>(
ib.fBranchBuffer.get()) :
ib.fBranchBuffer.get();
328 c.fCollectionModel->Freeze();
329 c.fCollectionEntry =
c.fCollectionModel->CreateBareEntry();
330 for (
auto idx :
c.fImportFieldIndexes) {
333 c.fCollectionEntry->BindRawPtr(
name, buffer);
336 c.fCollectionWriter =
fModel->MakeCollection(
c.fFieldName, std::move(
c.fCollectionModel));
338 for (
auto idx :
c.fImportFieldIndexes) {
347 return c.fFieldName +
"." +
name;
360 if (
f.fIsInUntypedCollection)
362 fEntry->BindRawPtr(
f.fField->GetFieldName(),
f.fFieldBuffer);
365 fEntry->BindRawPtr<
void>(
c.fFieldName,
c.fCollectionWriter->GetOffsetPtr());
381 std::unique_ptr<Internal::RPageSink>
sink =
383 sink->GetMetrics().Enable();
387 sink = std::make_unique<Internal::RPageSinkBuf>(std::move(
sink));
406 for (
Int_t l = 0;
l < *
c.fCountVal; ++
l) {
407 for (
auto &t :
c.fTransformations) {
412 c.fCollectionWriter->Fill(*
c.fCollectionEntry);
414 for (
auto &t :
c.fTransformations)
#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.
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 result
Base class for all ROOT issued exceptions.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &canonicalType, const std::string &typeAlias, bool fContinueOnError=false)
Factory method to resurrect a field from the stored on-disk type information.
Used to report every ~50MB (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< TFile > fDestFile
RNTupleWriteOptions fWriteOptions
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::vector< RImportBranch > fImportBranches
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
RResult< void > PrepareSchema()
Sets up the connection from TTree branches to RNTuple fields, including initialization of the memory ...
ROOT::Experimental::RResult< void > InitDestination(std::string_view destFileName)
void Import()
Import works in two steps:
std::unique_ptr< REntry > fEntry
std::string fDestFileName
bool fIsQuiet
No standard output, conversely if set to false, schema information and progress is printed.
std::vector< RImportField > fImportFields
std::unique_ptr< RNTupleModel > fModel
std::vector< std::unique_ptr< RImportTransformation > > fImportTransformations
The list of transformations to be performed for every entry.
static std::unique_ptr< RNTupleModel > CreateBare()
A bare model has no default entry.
bool GetUseBufferedWrite() const
The type-erased field for a RVec<Type>
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
const_iterator begin() const
const_iterator end() const
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< RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink)
RFieldBase * fField
The field is kept during schema preparation and transferred to the fModel before the writing starts.
bool fIsClass
Field imported from a branch with stramer info (e.g., STL, user-defined class)
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.
std::unique_ptr< RNTupleModel > fCollectionModel
The model for the collection itself.