Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RPageNullSink.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageNullSink.hxx
2/// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
3/// \date 2024-01-31
4/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5/// is welcome!
6
7/*************************************************************************
8 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15#ifndef ROOT_RPageNullSink
16#define ROOT_RPageNullSink
17
18#include <ROOT/RColumn.hxx>
19#include <ROOT/RFieldBase.hxx>
20#include <ROOT/RNTupleModel.hxx>
21#include <ROOT/RPageStorage.hxx>
22
23namespace ROOT {
24namespace Experimental {
25namespace Internal {
26
27/**
28\class ROOT::Experimental::Internal::RPageNullSink
29\ingroup NTuple
30\brief Dummy sink that discards all pages
31
32The RPageNullSink class is for internal testing only and can be used to measure the software overhead of serializing
33elements into pages, without actually writing them onto disk or even serializing the RNTuple headers and footers.
34*/
37 std::uint64_t fNBytesCurrentCluster = 0;
38
39public:
40 RPageNullSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options) : RPageSink(ntupleName, options)
41 {
42 }
43
45 {
46 return {fNColumns++, &column};
47 }
48
50 {
51 static ROOT::RNTupleDescriptor descriptor;
52 return descriptor;
53 }
54
55 ROOT::NTupleSize_t GetNEntries() const final { return 0; }
56
57 void ConnectFields(const std::vector<ROOT::RFieldBase *> &fields, ROOT::NTupleSize_t firstEntry)
58 {
59 auto connectField = [&](ROOT::RFieldBase &f) {
61 };
62 for (auto *f : fields) {
63 connectField(*f);
64 for (auto &descendant : *f) {
65 connectField(descendant);
66 }
67 }
68 }
69 void InitImpl(ROOT::RNTupleModel &model) final
70 {
71 auto &fieldZero = ROOT::Internal::GetFieldZeroOfModel(model);
72 ConnectFields(fieldZero.GetMutableSubfields(), 0);
73 }
75 {
76 ConnectFields(changeset.fAddedFields, firstEntry);
77 }
79
82 {
83 fNBytesCurrentCluster += page.GetNBytes();
84 }
86 {
87 fNBytesCurrentCluster += page.GetBufferSize();
88 }
89 void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final
90 {
91 for (auto &range : ranges) {
92 for (auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
93 fNBytesCurrentCluster += sealedPageIt->GetBufferSize();
94 }
95 }
96 }
97
99 {
100 RStagedCluster stagedCluster;
103 return stagedCluster;
104 }
105 void CommitStagedClusters(std::span<RStagedCluster>) final {}
106 void CommitClusterGroup() final {}
108 void CommitAttributeSet(std::string_view, const ROOT::Internal::RNTupleLink &) final {}
109
110 std::unique_ptr<RPageSink> CloneAsHidden(std::string_view, const RNTupleWriteOptions &) const final
111 {
112 throw ROOT::RException(R__FAIL("cannot clone null sink"));
113 }
114};
115
116} // namespace Internal
117} // namespace Experimental
118} // namespace ROOT
119
120#endif
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:299
#define f(i)
Definition RSha256.hxx:104
void CommitSuppressedColumn(ColumnHandle_t) final
Commits a suppressed column for the current cluster.
void UpdateSchema(const ROOT::Internal::RNTupleModelChangeset &changeset, ROOT::NTupleSize_t firstEntry) final
Incorporate incremental changes to the model into the ntuple descriptor.
ROOT::Internal::RNTupleLink CommitDatasetImpl() final
ROOT::NTupleSize_t GetNEntries() const final
void CommitAttributeSet(std::string_view, const ROOT::Internal::RNTupleLink &) final
Adds the given anchor information (name + locator) into the main RNTuple's descriptor as an attribute...
void CommitClusterGroup() final
Write out the page locations (page list envelope) for all the committed clusters since the last call ...
void CommitSealedPageV(std::span< RSealedPageGroup > ranges) final
Write a vector of preprocessed pages to storage. The corresponding columns must have been added befor...
void InitImpl(ROOT::RNTupleModel &model) final
std::unique_ptr< RPageSink > CloneAsHidden(std::string_view, const RNTupleWriteOptions &) const final
Creates a new sink with the same underlying storage as this but writing to a different RNTuple named ...
void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &) final
Adds an extra type information record to schema.
const ROOT::RNTupleDescriptor & GetDescriptor() const final
Return the RNTupleDescriptor being constructed.
RStagedCluster StageCluster(ROOT::NTupleSize_t) final
Stage the current cluster and create a new one for the following data.
void CommitStagedClusters(std::span< RStagedCluster >) final
Commit staged clusters, logically appending them to the ntuple descriptor.
void CommitSealedPage(ROOT::DescriptorId_t, const RSealedPage &page) final
Write a preprocessed page to storage. The column must have been added before.
void CommitPage(ColumnHandle_t, const ROOT::Internal::RPage &page) final
Write a page to the storage. The column must have been added before.
RPageNullSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
ColumnHandle_t AddColumn(ROOT::DescriptorId_t, ROOT::Internal::RColumn &column) final
Register a new column.
void ConnectFields(const std::vector< ROOT::RFieldBase * > &fields, ROOT::NTupleSize_t firstEntry)
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
Definition RColumn.hxx:37
Abstract interface to write data into an ntuple.
RPageSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
RColumnHandle ColumnHandle_t
The column handle identifies a column with the current open page storage.
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:43
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
Field specific extra type information from the header / extenstion header.
A field translates read and write calls from/to underlying columns to/from tree values.
The on-storage metadata of an RNTuple.
The RNTupleModel encapulates the schema of an RNTuple.
Common user-tunable settings for storing RNTuples.
Namespace for ROOT features in testing.
Definition TROOT.h:100
ROOT::RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
void CallConnectPageSinkOnField(RFieldBase &, ROOT::Internal::RPageSink &, ROOT::NTupleSize_t firstEntry=0)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
The incremental changes to a RNTupleModel.
Cluster that was staged, but not yet logically appended to the RNTuple.
A sealed page contains the bytes of a page as written to storage (packed & compressed).