Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RPageNullSink.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageNullSink.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
4/// \date 2024-01-31
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RPageNullSink
17#define ROOT7_RPageNullSink
18
19#include <ROOT/RColumn.hxx>
20#include <ROOT/RField.hxx>
21#include <ROOT/RNTupleModel.hxx>
22#include <ROOT/RPageStorage.hxx>
23
24namespace ROOT {
25namespace Experimental {
26namespace Internal {
27
28/**
29\class ROOT::Experimental::Internal::RPageNullSink
30\ingroup NTuple
31\brief Dummy sink that discards all pages
32
33The RPageNullSink class is for internal testing only and can be used to measure the software overhead of serializing
34elements into pages, without actually writing them onto disk or even serializing the RNTuple headers and footers.
35*/
36class RPageNullSink : public RPageSink {
39 std::uint64_t fNBytesCurrentCluster = 0;
40
41public:
42 RPageNullSink(std::string_view ntupleName, const RNTupleWriteOptions &options) : RPageSink(ntupleName, options) {}
43
44 ColumnHandle_t AddColumn(DescriptorId_t, const RColumn &column) final { return {fNColumns++, &column}; }
45
46 RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements) final
47 {
48 auto elementSize = columnHandle.fColumn->GetElement()->GetSize();
49 return fPageAllocator.NewPage(columnHandle.fPhysicalId, elementSize, nElements);
50 }
51 void ReleasePage(RPage &page) final { fPageAllocator.DeletePage(page); }
52
53 const RNTupleDescriptor &GetDescriptor() const final
54 {
55 static RNTupleDescriptor descriptor;
56 return descriptor;
57 }
58
59 void ConnectFields(const std::vector<RFieldBase *> &fields, NTupleSize_t firstEntry)
60 {
61 auto connectField = [&](RFieldBase &f) { CallConnectPageSinkOnField(f, *this, firstEntry); };
62 for (auto *f : fields) {
63 connectField(*f);
64 for (auto &descendant : *f) {
65 connectField(descendant);
66 }
67 }
68 }
69 void InitImpl(RNTupleModel &model) final { ConnectFields(model.GetFieldZero().GetSubFields(), 0); }
70 void UpdateSchema(const RNTupleModelChangeset &changeset, NTupleSize_t firstEntry) final
71 {
72 ConnectFields(changeset.fAddedFields, firstEntry);
73 }
74
75 void CommitPage(ColumnHandle_t, const RPage &page) final { fNBytesCurrentCluster += page.GetNBytes(); }
76 void CommitSealedPage(DescriptorId_t, const RSealedPage &page) final { fNBytesCurrentCluster += page.fSize; }
77 void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final
78 {
79 for (auto &range : ranges) {
80 for (auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
81 fNBytesCurrentCluster += sealedPageIt->fSize;
82 }
83 }
84 }
85
86 std::uint64_t CommitCluster(NTupleSize_t) final
87 {
88 std::uint64_t bytes = fNBytesCurrentCluster;
90 return bytes;
91 }
92 void CommitClusterGroup() final {}
93 void CommitDataset() final {}
94};
95
96} // namespace Internal
97} // namespace Experimental
98} // namespace ROOT
99
100#endif
#define f(i)
Definition RSha256.hxx:104
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Uses standard C++ memory allocation for the column data pages.
static RPage NewPage(ColumnId_t columnId, std::size_t elementSize, std::size_t nElements)
Reserves memory large enough to hold nElements of the given size.
static void DeletePage(const RPage &page)
Releases the memory pointed to by page and resets the page's information.
Dummy sink that discards all pages.
void ConnectFields(const std::vector< RFieldBase * > &fields, NTupleSize_t firstEntry)
void CommitDataset() final
Finalize the current cluster and the entrire data set.
void CommitSealedPage(DescriptorId_t, const RSealedPage &page) final
Write a preprocessed page to storage. The column must have been added before.
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...
RPageNullSink(std::string_view ntupleName, const RNTupleWriteOptions &options)
void InitImpl(RNTupleModel &model) final
void CommitPage(ColumnHandle_t, const RPage &page) final
Write a page to the storage. The column must have been added before.
std::uint64_t CommitCluster(NTupleSize_t) final
Finalize the current cluster and create a new one for the following data.
void UpdateSchema(const RNTupleModelChangeset &changeset, NTupleSize_t firstEntry) final
Incorporate incremental changes to the model into the ntuple descriptor.
void ReleasePage(RPage &page) final
Every page store needs to be able to free pages it handed out.
RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements) final
Get a new, empty page for the given column that can be filled with up to nElements.
const RNTupleDescriptor & GetDescriptor() const final
Return the RNTupleDescriptor being constructed.
ColumnHandle_t AddColumn(DescriptorId_t, const RColumn &column) final
Register a new column.
Abstract interface to write data into an ntuple.
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:41
A field translates read and write calls from/to underlying columns to/from tree values.
Definition RField.hxx:95
The on-storage meta-data of an ntuple.
The RNTupleModel encapulates the schema of an ntuple.
Common user-tunable settings for storing ntuples.
void CallConnectPageSinkOnField(RFieldBase &, RPageSink &, NTupleSize_t firstEntry=0)
Definition RField.cxx:359
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The incremental changes to a RNTupleModel
A sealed page contains the bytes of a page as written to storage (packed & compressed).