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 CommitCluster() or by destructing the writer. On I/O errors, an exception is thrown.

Definition at line 59 of file RNTupleWriter.hxx.

Public Member Functions

 RNTupleWriter (const RNTupleWriter &)=delete
 
 ~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.
 
NTupleSize_t GetLastCommitted () const
 Return the entry number that was last committed in a cluster.
 
NTupleSize_t GetLastCommittedClusterGroup () const
 Return the entry number that was last committed in a cluster group.
 
const Detail::RNTupleMetricsGetMetrics () const
 
const RNTupleModelGetModel () const
 
NTupleSize_t GetNEntries () const
 Return the number of entries filled so far.
 
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::initializer_list< std::pair< std::string_view, std::string_view > > fields, std::string_view ntupleName, std::string_view storage, const RNTupleWriteOptions &options=RNTupleWriteOptions())
 
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

 RNTupleWriter (std::unique_ptr< RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink)
 
void CommitClusterGroup ()
 
Internal::RPageSinkGetSink ()
 
RNTupleModelGetUpdatableModel ()
 

Static Private Member Functions

static std::unique_ptr< RNTupleWriterCreate (std::unique_ptr< RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink, const RNTupleWriteOptions &options)
 Create a writer, potentially wrapping the sink in a RPageSinkBuf.
 

Private Attributes

RNTupleFillContext fFillContext
 
NTupleSize_t fLastCommittedClusterGroup = 0
 
Detail::RNTupleMetrics fMetrics
 
std::unique_ptr< Internal::RPageStorage::RTaskSchedulerfZipTasks
 The page sink's parallel page compression scheduler if IMT is on.
 

Friends

std::unique_ptr< RNTupleWriterInternal::CreateRNTupleWriter (std::unique_ptr< RNTupleModel >, std::unique_ptr< Internal::RPageSink >)
 

#include <ROOT/RNTupleWriter.hxx>

Constructor & Destructor Documentation

◆ RNTupleWriter() [1/2]

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

Definition at line 32 of file RNTupleWriter.cxx.

◆ RNTupleWriter() [2/2]

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

◆ ~RNTupleWriter()

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

Definition at line 47 of file RNTupleWriter.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 92 of file RNTupleWriter.cxx.

◆ CommitCluster()

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

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

Definition at line 110 of file RNTupleWriter.hxx.

◆ CommitClusterGroup()

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

Definition at line 99 of file RNTupleWriter.cxx.

◆ Create()

std::unique_ptr< ROOT::Experimental::RNTupleWriter > ROOT::Experimental::RNTupleWriter::Create ( std::unique_ptr< RNTupleModel model,
std::unique_ptr< Internal::RPageSink sink,
const RNTupleWriteOptions options 
)
staticprivate

Create a writer, potentially wrapping the sink in a RPageSinkBuf.

Definition at line 58 of file RNTupleWriter.cxx.

◆ CreateEntry()

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

Definition at line 117 of file RNTupleWriter.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:1469
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.
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 at line 150 of file RNTupleWriter.hxx.

◆ EnableMetrics()

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

Definition at line 126 of file RNTupleWriter.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 104 of file RNTupleWriter.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 108 of file RNTupleWriter.hxx.

◆ GetLastCommitted()

NTupleSize_t ROOT::Experimental::RNTupleWriter::GetLastCommitted ( ) const
inline

Return the entry number that was last committed in a cluster.

Definition at line 120 of file RNTupleWriter.hxx.

◆ GetLastCommittedClusterGroup()

NTupleSize_t ROOT::Experimental::RNTupleWriter::GetLastCommittedClusterGroup ( ) const
inline

Return the entry number that was last committed in a cluster group.

Definition at line 122 of file RNTupleWriter.hxx.

◆ GetMetrics()

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

Definition at line 127 of file RNTupleWriter.hxx.

◆ GetModel()

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

Definition at line 129 of file RNTupleWriter.hxx.

◆ GetNEntries()

NTupleSize_t ROOT::Experimental::RNTupleWriter::GetNEntries ( ) const
inline

Return the number of entries filled so far.

Definition at line 124 of file RNTupleWriter.hxx.

◆ GetSink()

Internal::RPageSink & ROOT::Experimental::RNTupleWriter::GetSink ( )
inlineprivate

Definition at line 76 of file RNTupleWriter.hxx.

◆ GetUpdatableModel()

RNTupleModel & ROOT::Experimental::RNTupleWriter::GetUpdatableModel ( )
inlineprivate

Definition at line 75 of file RNTupleWriter.hxx.

◆ operator=()

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

◆ Recreate() [1/2]

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

Definition at line 76 of file RNTupleWriter.cxx.

◆ Recreate() [2/2]

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 68 of file RNTupleWriter.cxx.

Friends And Related Symbol Documentation

◆ Internal::CreateRNTupleWriter

std::unique_ptr< RNTupleWriter > Internal::CreateRNTupleWriter ( std::unique_ptr< RNTupleModel ,
std::unique_ptr< Internal::RPageSink  
)
friend

Member Data Documentation

◆ fFillContext

RNTupleFillContext ROOT::Experimental::RNTupleWriter::fFillContext
private

Definition at line 68 of file RNTupleWriter.hxx.

◆ fLastCommittedClusterGroup

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

Definition at line 71 of file RNTupleWriter.hxx.

◆ fMetrics

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

Definition at line 69 of file RNTupleWriter.hxx.

◆ fZipTasks

std::unique_ptr<Internal::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 (in the fill context) is destructed and so declared before.

Definition at line 67 of file RNTupleWriter.hxx.

Libraries for ROOT::Experimental::RNTupleWriter:

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