Converts a TTree into an RNTuple.
Example usage:
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
Current limitations of the importer:
Definition at line 96 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 |
Static Private Attributes | |
static constexpr int | kDefaultCompressionSettings = 505 |
By default, compress RNTuple with zstd, level 5. | |
#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 85 of file RNTupleImporter.cxx.
|
static |
Directly uses the provided tree and opens the output file for writing (update).
Definition at line 111 of file RNTupleImporter.cxx.
|
inline |
Definition at line 259 of file RNTupleImporter.hxx.
void ROOT::Experimental::RNTupleImporter::Import | ( | ) |
Import works in two steps:
Definition at line 369 of file RNTupleImporter.cxx.
|
private |
Definition at line 135 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 164 of file RNTupleImporter.cxx.
|
private |
Definition at line 147 of file RNTupleImporter.cxx.
|
private |
Definition at line 154 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 266 of file RNTupleImporter.hxx.
|
inline |
Whether or not information and progress is printed to stdout.
Definition at line 269 of file RNTupleImporter.hxx.
|
inline |
Definition at line 262 of file RNTupleImporter.hxx.
|
inline |
Definition at line 261 of file RNTupleImporter.hxx.
|
inline |
Definition at line 260 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 219 of file RNTupleImporter.hxx.
|
private |
Definition at line 214 of file RNTupleImporter.hxx.
|
private |
Definition at line 212 of file RNTupleImporter.hxx.
|
private |
Definition at line 229 of file RNTupleImporter.hxx.
|
private |
Definition at line 230 of file RNTupleImporter.hxx.
|
private |
Definition at line 231 of file RNTupleImporter.hxx.
|
private |
The list of transformations to be performed for every entry.
Definition at line 235 of file RNTupleImporter.hxx.
|
private |
No standard output, conversely if set to false, schema information and progress is printed.
Definition at line 225 of file RNTupleImporter.hxx.
|
private |
Maps the count leaf to the information about the corresponding untyped collection.
Definition at line 233 of file RNTupleImporter.hxx.
|
private |
The maximum number of entries to import. When this value is -1 (default), import all entries.
Definition at line 222 of file RNTupleImporter.hxx.
|
private |
Definition at line 228 of file RNTupleImporter.hxx.
|
private |
Definition at line 213 of file RNTupleImporter.hxx.
|
private |
Definition at line 226 of file RNTupleImporter.hxx.
|
private |
Definition at line 209 of file RNTupleImporter.hxx.
|
private |
Definition at line 210 of file RNTupleImporter.hxx.
|
private |
Definition at line 215 of file RNTupleImporter.hxx.
|
staticconstexprprivate |
By default, compress RNTuple with zstd, level 5.
Definition at line 112 of file RNTupleImporter.hxx.