Converts a TTree into an RNTuple.
Example usage (see the ntpl008_import.C tutorial for a full example):
The output file is created if it does not exist, otherwise the ntuple is added to the existing file. Note that input file and output file can be identical if the ntuple is stored under a different name than the tree (use SetNTupleName()
).
By default, the RNTuple is compressed with zstd, independent of the input compression. The compression settings (and other output parameters) can be changed by SetWriteOptions()
. For example, to compress the imported RNTuple using lz4 (with compression level 4) instead:
Most RNTuple fields have a type identical to the corresponding TTree input branch. Exceptions are
std::string
fieldsstd::array<...>
fields_collection0
, _collection1
, etc.). In order to keep field names and branch names aligned, RNTuple projects the members of these collections and its collection counter to the input branch names. For instance, the following input leafs: will be converted to the following RNTuple schema: Current limitations of the importer:
Definition at line 103 of file RNTupleImporter.hxx.
Classes | |
struct | RCStringTransformation |
Transform a NULL terminated C string branch into an std::string field. More... | |
struct | RImportBranch |
struct | RImportField |
struct | RImportGuard |
When the schema is set up and the import started, it needs to be reset before the next Import() call can start. More... | |
struct | RImportLeafCountCollection |
Leaf count arrays require special treatment. More... | |
struct | RImportTransformation |
Base class to perform data transformations from TTree branches to RNTuple fields if necessary. More... | |
struct | RLeafArrayTransformation |
When writing the elements of a leaf count array, moves the data from the input array one-by-one to the memory locations of the fields of the corresponding untyped collection. More... | |
class | RProgressCallback |
Used to report every ~50MB (compressed), and at the end about the status of the import. More... | |
Public Member Functions | |
RNTupleImporter (const RNTupleImporter &other)=delete | |
RNTupleImporter (RNTupleImporter &&other)=delete | |
~RNTupleImporter ()=default | |
RNTupleWriteOptions | GetWriteOptions () const |
void | Import () |
Import works in two steps: | |
RNTupleImporter & | operator= (const RNTupleImporter &other)=delete |
RNTupleImporter & | operator= (RNTupleImporter &&other)=delete |
void | SetConvertDotsInBranchNames (bool value) |
Whereas branch names may contain dots, RNTuple field names may not. | |
void | SetIsQuiet (bool value) |
Whether or not information and progress is printed to stdout. | |
void | SetMaxEntries (std::uint64_t maxEntries) |
void | SetNTupleName (const std::string &name) |
void | SetWriteOptions (RNTupleWriteOptions options) |
Static Public Member Functions | |
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). | |
static std::unique_ptr< RNTupleImporter > | Create (TTree *sourceTree, std::string_view destFileName) |
Directly uses the provided tree and opens the output file for writing (update). | |
Private Member Functions | |
RNTupleImporter ()=default | |
ROOT::Experimental::RResult< void > | InitDestination (std::string_view destFileName) |
RResult< void > | PrepareSchema () |
Sets up the connection from TTree branches to RNTuple fields, including initialization of the memory buffers used for reading and writing. | |
void | ReportSchema () |
void | ResetSchema () |
Private Attributes | |
bool | fConvertDotsInBranchNames = false |
Whether or not dot characters in branch names should be converted to underscores. | |
std::unique_ptr< TFile > | fDestFile |
std::string | fDestFileName |
std::unique_ptr< REntry > | fEntry |
std::vector< RImportBranch > | fImportBranches |
std::vector< RImportField > | fImportFields |
std::vector< std::unique_ptr< RImportTransformation > > | fImportTransformations |
The list of transformations to be performed for every entry. | |
bool | fIsQuiet = false |
No standard output, conversely if set to false, schema information and progress is printed. | |
std::map< std::string, RImportLeafCountCollection > | fLeafCountCollections |
Maps the count leaf to the information about the corresponding untyped collection. | |
std::int64_t | fMaxEntries = -1 |
The maximum number of entries to import. When this value is -1 (default), import all entries. | |
std::unique_ptr< RNTupleModel > | fModel |
std::string | fNTupleName |
std::unique_ptr< RProgressCallback > | fProgressCallback |
std::unique_ptr< TFile > | fSourceFile |
TTree * | fSourceTree |
RNTupleWriteOptions | fWriteOptions |
#include <ROOT/RNTupleImporter.hxx>
|
privatedefault |
|
delete |
|
delete |
|
default |
|
static |
Opens the input file for reading and the output file for writing (update).
Definition at line 90 of file RNTupleImporter.cxx.
|
static |
Directly uses the provided tree and opens the output file for writing (update).
Definition at line 116 of file RNTupleImporter.cxx.
|
inline |
Definition at line 263 of file RNTupleImporter.hxx.
void ROOT::Experimental::RNTupleImporter::Import | ( | ) |
Import works in two steps:
Definition at line 374 of file RNTupleImporter.cxx.
|
private |
Definition at line 140 of file RNTupleImporter.cxx.
|
delete |
|
delete |
|
private |
Sets up the connection from TTree branches to RNTuple fields, including initialization of the memory buffers used for reading and writing.
Definition at line 168 of file RNTupleImporter.cxx.
|
private |
Definition at line 151 of file RNTupleImporter.cxx.
|
private |
Definition at line 158 of file RNTupleImporter.cxx.
|
inline |
Whereas branch names may contain dots, RNTuple field names may not.
By setting this option, dot characters are automatically converted into underscores to prevent the importer from throwing an exception.
Definition at line 270 of file RNTupleImporter.hxx.
|
inline |
Whether or not information and progress is printed to stdout.
Definition at line 273 of file RNTupleImporter.hxx.
|
inline |
Definition at line 266 of file RNTupleImporter.hxx.
|
inline |
Definition at line 265 of file RNTupleImporter.hxx.
|
inline |
Definition at line 264 of file RNTupleImporter.hxx.
|
private |
Whether or not dot characters in branch names should be converted to underscores.
If this option is not set and a branch with a '.' is encountered, the importer will throw an exception.
Definition at line 223 of file RNTupleImporter.hxx.
|
private |
Definition at line 218 of file RNTupleImporter.hxx.
|
private |
Definition at line 216 of file RNTupleImporter.hxx.
|
private |
Definition at line 233 of file RNTupleImporter.hxx.
|
private |
Definition at line 234 of file RNTupleImporter.hxx.
|
private |
Definition at line 235 of file RNTupleImporter.hxx.
|
private |
The list of transformations to be performed for every entry.
Definition at line 239 of file RNTupleImporter.hxx.
|
private |
No standard output, conversely if set to false, schema information and progress is printed.
Definition at line 229 of file RNTupleImporter.hxx.
|
private |
Maps the count leaf to the information about the corresponding untyped collection.
Definition at line 237 of file RNTupleImporter.hxx.
|
private |
The maximum number of entries to import. When this value is -1 (default), import all entries.
Definition at line 226 of file RNTupleImporter.hxx.
|
private |
Definition at line 232 of file RNTupleImporter.hxx.
|
private |
Definition at line 217 of file RNTupleImporter.hxx.
|
private |
Definition at line 230 of file RNTupleImporter.hxx.
|
private |
Definition at line 213 of file RNTupleImporter.hxx.
|
private |
Definition at line 214 of file RNTupleImporter.hxx.
|
private |
Definition at line 219 of file RNTupleImporter.hxx.