Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:08:35

0001 /// \file ROOT/RPageNullSink.hxx
0002 /// \ingroup NTuple
0003 /// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
0004 /// \date 2024-01-31
0005 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
0006 /// is welcome!
0007 
0008 /*************************************************************************
0009  * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers.               *
0010  * All rights reserved.                                                  *
0011  *                                                                       *
0012  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0013  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0014  *************************************************************************/
0015 
0016 #ifndef ROOT_RPageNullSink
0017 #define ROOT_RPageNullSink
0018 
0019 #include <ROOT/RColumn.hxx>
0020 #include <ROOT/RFieldBase.hxx>
0021 #include <ROOT/RNTupleModel.hxx>
0022 #include <ROOT/RPageStorage.hxx>
0023 
0024 namespace ROOT {
0025 namespace Experimental {
0026 namespace Internal {
0027 
0028 /**
0029 \class ROOT::Experimental::Internal::RPageNullSink
0030 \ingroup NTuple
0031 \brief Dummy sink that discards all pages
0032 
0033 The RPageNullSink class is for internal testing only and can be used to measure the software overhead of serializing
0034 elements into pages, without actually writing them onto disk or even serializing the RNTuple headers and footers.
0035 */
0036 class RPageNullSink : public ROOT::Internal::RPageSink {
0037    ROOT::DescriptorId_t fNColumns = 0;
0038    std::uint64_t fNBytesCurrentCluster = 0;
0039 
0040 public:
0041    RPageNullSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options) : RPageSink(ntupleName, options)
0042    {
0043    }
0044 
0045    ColumnHandle_t AddColumn(ROOT::DescriptorId_t, ROOT::Internal::RColumn &column) final
0046    {
0047       return {fNColumns++, &column};
0048    }
0049 
0050    const ROOT::RNTupleDescriptor &GetDescriptor() const final
0051    {
0052       static ROOT::RNTupleDescriptor descriptor;
0053       return descriptor;
0054    }
0055 
0056    ROOT::NTupleSize_t GetNEntries() const final { return 0; }
0057 
0058    void ConnectFields(const std::vector<ROOT::RFieldBase *> &fields, ROOT::NTupleSize_t firstEntry)
0059    {
0060       auto connectField = [&](ROOT::RFieldBase &f) {
0061          ROOT::Internal::CallConnectPageSinkOnField(f, *this, firstEntry);
0062       };
0063       for (auto *f : fields) {
0064          connectField(*f);
0065          for (auto &descendant : *f) {
0066             connectField(descendant);
0067          }
0068       }
0069    }
0070    void InitImpl(ROOT::RNTupleModel &model) final
0071    {
0072       auto &fieldZero = ROOT::Internal::GetFieldZeroOfModel(model);
0073       ConnectFields(fieldZero.GetMutableSubfields(), 0);
0074    }
0075    void UpdateSchema(const ROOT::Internal::RNTupleModelChangeset &changeset, ROOT::NTupleSize_t firstEntry) final
0076    {
0077       ConnectFields(changeset.fAddedFields, firstEntry);
0078    }
0079    void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &) final {}
0080 
0081    void CommitSuppressedColumn(ColumnHandle_t) final {}
0082    void CommitPage(ColumnHandle_t, const ROOT::Internal::RPage &page) final
0083    {
0084       fNBytesCurrentCluster += page.GetNBytes();
0085    }
0086    void CommitSealedPage(ROOT::DescriptorId_t, const RSealedPage &page) final
0087    {
0088       fNBytesCurrentCluster += page.GetBufferSize();
0089    }
0090    void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final
0091    {
0092       for (auto &range : ranges) {
0093          for (auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
0094             fNBytesCurrentCluster += sealedPageIt->GetBufferSize();
0095          }
0096       }
0097    }
0098 
0099    RStagedCluster StageCluster(ROOT::NTupleSize_t) final
0100    {
0101       RStagedCluster stagedCluster;
0102       stagedCluster.fNBytesWritten = fNBytesCurrentCluster;
0103       fNBytesCurrentCluster = 0;
0104       return stagedCluster;
0105    }
0106    void CommitStagedClusters(std::span<RStagedCluster>) final {}
0107    void CommitClusterGroup() final {}
0108    void CommitDatasetImpl() final {}
0109 };
0110 
0111 } // namespace Internal
0112 } // namespace Experimental
0113 } // namespace ROOT
0114 
0115 #endif