Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RNTupleWriter Class Reference

An RNTuple that gets filled with entries (data) and writes them to storage.

An output ntuple can be filled with entries. The caller has to make sure that the data that gets filled into an ntuple is not modified for the time of the Fill() call. The fill call serializes the C++ object into the column format and writes data into the corresponding column page buffers. Writing of the buffers to storage is deferred and can be triggered by Flush() or by destructing the ntuple. On I/O errors, an exception is thrown.

Definition at line 358 of file RNTuple.hxx.

Public Member Functions

 RNTupleWriter (const RNTupleWriter &)=delete
 
 RNTupleWriter (std::unique_ptr< RNTupleModel > model, std::unique_ptr< Detail::RPageSink > sink)
 Throws an exception if the model or the sink is null.
 
 ~RNTupleWriter ()
 
void CommitCluster (bool commitClusterGroup=false)
 Ensure that the data from the so far seen Fill calls has been written to storage.
 
std::unique_ptr< REntryCreateEntry ()
 
std::unique_ptr< RNTupleModel::RUpdaterCreateModelUpdater ()
 Get a RNTupleModel::RUpdater that provides limited support for incremental updates to the underlying model, e.g.
 
void EnableMetrics ()
 
std::size_t Fill ()
 The simplest user interface if the default entry that comes with the ntuple model is used.
 
std::size_t Fill (REntry &entry)
 Multiple entries can have been instantiated from the ntuple model.
 
const Detail::RNTupleMetricsGetMetrics () const
 
const RNTupleModelGetModel () const
 
RNTupleWriteroperator= (const RNTupleWriter &)=delete
 

Static Public Member Functions

static std::unique_ptr< RNTupleWriterAppend (std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, TFile &file, const RNTupleWriteOptions &options=RNTupleWriteOptions())
 Throws an exception if the model is null.
 
static std::unique_ptr< RNTupleWriterRecreate (std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleWriteOptions &options=RNTupleWriteOptions())
 Throws an exception if the model is null.
 

Private Member Functions

void CommitClusterGroup ()
 

Private Attributes

NTupleSize_t fLastCommitted = 0
 
NTupleSize_t fLastCommittedClusterGroup = 0
 
std::size_t fMaxUnzippedClusterSize
 Limit for committing cluster no matter the other tunables.
 
Detail::RNTupleMetrics fMetrics
 
std::unique_ptr< RNTupleModelfModel
 Needs to be destructed before fSink.
 
std::uint64_t fNBytesCommitted = 0
 The total number of bytes written to storage (i.e., after compression)
 
std::uint64_t fNBytesFilled = 0
 The total number of bytes filled into all the so far committed clusters, i.e.
 
NTupleSize_t fNEntries = 0
 
std::unique_ptr< Detail::RPageSinkfSink
 
std::size_t fUnzippedClusterSize = 0
 Keeps track of the number of bytes written into the current cluster.
 
NTupleSize_t fUnzippedClusterSizeEst
 Estimator of uncompressed cluster size, taking into account the estimated compression ratio.
 
std::unique_ptr< Detail::RPageStorage::RTaskSchedulerfZipTasks
 The page sink's parallel page compression scheduler if IMT is on.
 

#include <ROOT/RNTuple.hxx>

Constructor & Destructor Documentation

◆ RNTupleWriter() [1/2]

ROOT::Experimental::RNTupleWriter::RNTupleWriter ( std::unique_ptr< RNTupleModel model,
std::unique_ptr< Detail::RPageSink sink 
)

Throws an exception if the model or the sink is null.

Definition at line 265 of file RNTuple.cxx.

◆ RNTupleWriter() [2/2]

ROOT::Experimental::RNTupleWriter::RNTupleWriter ( const RNTupleWriter )
delete

◆ ~RNTupleWriter()

ROOT::Experimental::RNTupleWriter::~RNTupleWriter ( )

Definition at line 292 of file RNTuple.cxx.

Member Function Documentation

◆ Append()

std::unique_ptr< ROOT::Experimental::RNTupleWriter > ROOT::Experimental::RNTupleWriter::Append ( std::unique_ptr< RNTupleModel model,
std::string_view  ntupleName,
TFile file,
const RNTupleWriteOptions options = RNTupleWriteOptions() 
)
static

Throws an exception if the model is null.

Definition at line 310 of file RNTuple.cxx.

◆ CommitCluster()

void ROOT::Experimental::RNTupleWriter::CommitCluster ( bool  commitClusterGroup = false)

Ensure that the data from the so far seen Fill calls has been written to storage.

Definition at line 329 of file RNTuple.cxx.

◆ CommitClusterGroup()

void ROOT::Experimental::RNTupleWriter::CommitClusterGroup ( )
private

Definition at line 321 of file RNTuple.cxx.

◆ CreateEntry()

std::unique_ptr< REntry > ROOT::Experimental::RNTupleWriter::CreateEntry ( )
inline

Definition at line 427 of file RNTuple.hxx.

◆ CreateModelUpdater()

std::unique_ptr< RNTupleModel::RUpdater > ROOT::Experimental::RNTupleWriter::CreateModelUpdater ( )
inline

Get a RNTupleModel::RUpdater that provides limited support for incremental updates to the underlying model, e.g.

addition of new fields.

Example: add a new field after the model has been used to construct a RNTupleWriter object

#include <ROOT/RNTuple.hxx>
auto model = RNTupleModel::Create();
auto fldFloat = model->MakeField<float>("fldFloat");
auto writer = RNTupleWriter::Recreate(std::move(model), "myNTuple", "some/file.root");
auto updater = writer->CreateModelUpdater();
updater->BeginUpdate();
updater->AddField(std::make_unique<RField<float>>("pt"));
updater->CommitUpdate();
// ...
Classes with dictionaries that can be inspected by TClass.
Definition RField.hxx:1224
The RNTupleModel encapulates the schema of an ntuple.
static std::unique_ptr< RNTupleModel > Create()
An RNTuple that gets filled with entries (data) and writes them to storage.
Definition RNTuple.hxx:358
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Throws an exception if the model is null.
Definition RNTuple.cxx:303

Definition at line 453 of file RNTuple.hxx.

◆ EnableMetrics()

void ROOT::Experimental::RNTupleWriter::EnableMetrics ( )
inline

Definition at line 429 of file RNTuple.hxx.

◆ Fill() [1/2]

std::size_t ROOT::Experimental::RNTupleWriter::Fill ( )
inline

The simplest user interface if the default entry that comes with the ntuple model is used.

Returns
The number of uncompressed bytes written.

Definition at line 406 of file RNTuple.hxx.

◆ Fill() [2/2]

std::size_t ROOT::Experimental::RNTupleWriter::Fill ( REntry entry)
inline

Multiple entries can have been instantiated from the ntuple model.

This method will perform a light check whether the entry comes from the ntuple's own model.

Returns
The number of uncompressed bytes written.

Definition at line 410 of file RNTuple.hxx.

◆ GetMetrics()

const Detail::RNTupleMetrics & ROOT::Experimental::RNTupleWriter::GetMetrics ( ) const
inline

Definition at line 430 of file RNTuple.hxx.

◆ GetModel()

const RNTupleModel * ROOT::Experimental::RNTupleWriter::GetModel ( ) const
inline

Definition at line 432 of file RNTuple.hxx.

◆ operator=()

RNTupleWriter & ROOT::Experimental::RNTupleWriter::operator= ( const RNTupleWriter )
delete

◆ Recreate()

std::unique_ptr< ROOT::Experimental::RNTupleWriter > ROOT::Experimental::RNTupleWriter::Recreate ( std::unique_ptr< RNTupleModel model,
std::string_view  ntupleName,
std::string_view  storage,
const RNTupleWriteOptions options = RNTupleWriteOptions() 
)
static

Throws an exception if the model is null.

Definition at line 303 of file RNTuple.cxx.

Member Data Documentation

◆ fLastCommitted

NTupleSize_t ROOT::Experimental::RNTupleWriter::fLastCommitted = 0
private

Definition at line 369 of file RNTuple.hxx.

◆ fLastCommittedClusterGroup

NTupleSize_t ROOT::Experimental::RNTupleWriter::fLastCommittedClusterGroup = 0
private

Definition at line 370 of file RNTuple.hxx.

◆ fMaxUnzippedClusterSize

std::size_t ROOT::Experimental::RNTupleWriter::fMaxUnzippedClusterSize
private

Limit for committing cluster no matter the other tunables.

Definition at line 380 of file RNTuple.hxx.

◆ fMetrics

Detail::RNTupleMetrics ROOT::Experimental::RNTupleWriter::fMetrics
private

Definition at line 368 of file RNTuple.hxx.

◆ fModel

std::unique_ptr<RNTupleModel> ROOT::Experimental::RNTupleWriter::fModel
private

Needs to be destructed before fSink.

Definition at line 367 of file RNTuple.hxx.

◆ fNBytesCommitted

std::uint64_t ROOT::Experimental::RNTupleWriter::fNBytesCommitted = 0
private

The total number of bytes written to storage (i.e., after compression)

Definition at line 375 of file RNTuple.hxx.

◆ fNBytesFilled

std::uint64_t ROOT::Experimental::RNTupleWriter::fNBytesFilled = 0
private

The total number of bytes filled into all the so far committed clusters, i.e.

the uncompressed size of the written clusters

Definition at line 378 of file RNTuple.hxx.

◆ fNEntries

NTupleSize_t ROOT::Experimental::RNTupleWriter::fNEntries = 0
private

Definition at line 371 of file RNTuple.hxx.

◆ fSink

std::unique_ptr<Detail::RPageSink> ROOT::Experimental::RNTupleWriter::fSink
private

Definition at line 365 of file RNTuple.hxx.

◆ fUnzippedClusterSize

std::size_t ROOT::Experimental::RNTupleWriter::fUnzippedClusterSize = 0
private

Keeps track of the number of bytes written into the current cluster.

Definition at line 373 of file RNTuple.hxx.

◆ fUnzippedClusterSizeEst

NTupleSize_t ROOT::Experimental::RNTupleWriter::fUnzippedClusterSizeEst
private

Estimator of uncompressed cluster size, taking into account the estimated compression ratio.

Definition at line 382 of file RNTuple.hxx.

◆ fZipTasks

std::unique_ptr<Detail::RPageStorage::RTaskScheduler> ROOT::Experimental::RNTupleWriter::fZipTasks
private

The page sink's parallel page compression scheduler if IMT is on.

Needs to be destructed after the page sink is destructed and so declared before.

Definition at line 364 of file RNTuple.hxx.

Libraries for ROOT::Experimental::RNTupleWriter:

The documentation for this class was generated from the following files: