File indexing completed on 2025-01-18 10:10:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROOT7_RPageNullSink
0017 #define ROOT7_RPageNullSink
0018
0019 #include <ROOT/RColumn.hxx>
0020 #include <ROOT/RField.hxx>
0021 #include <ROOT/RNTupleModel.hxx>
0022 #include <ROOT/RPageStorage.hxx>
0023
0024 namespace ROOT {
0025 namespace Experimental {
0026 namespace Internal {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class RPageNullSink : public RPageSink {
0037 RPageAllocatorHeap fPageAllocator{};
0038 DescriptorId_t fNColumns = 0;
0039 std::uint64_t fNBytesCurrentCluster = 0;
0040
0041 public:
0042 RPageNullSink(std::string_view ntupleName, const RNTupleWriteOptions &options) : RPageSink(ntupleName, options) {}
0043
0044 ColumnHandle_t AddColumn(DescriptorId_t, const RColumn &column) final { return {fNColumns++, &column}; }
0045
0046 RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements) final
0047 {
0048 auto elementSize = columnHandle.fColumn->GetElement()->GetSize();
0049 return fPageAllocator.NewPage(columnHandle.fPhysicalId, elementSize, nElements);
0050 }
0051 void ReleasePage(RPage &page) final { fPageAllocator.DeletePage(page); }
0052
0053 const RNTupleDescriptor &GetDescriptor() const final
0054 {
0055 static RNTupleDescriptor descriptor;
0056 return descriptor;
0057 }
0058
0059 void ConnectFields(const std::vector<RFieldBase *> &fields, NTupleSize_t firstEntry)
0060 {
0061 auto connectField = [&](RFieldBase &f) { CallConnectPageSinkOnField(f, *this, firstEntry); };
0062 for (auto *f : fields) {
0063 connectField(*f);
0064 for (auto &descendant : *f) {
0065 connectField(descendant);
0066 }
0067 }
0068 }
0069 void InitImpl(RNTupleModel &model) final { ConnectFields(model.GetFieldZero().GetSubFields(), 0); }
0070 void UpdateSchema(const RNTupleModelChangeset &changeset, NTupleSize_t firstEntry) final
0071 {
0072 ConnectFields(changeset.fAddedFields, firstEntry);
0073 }
0074
0075 void CommitPage(ColumnHandle_t, const RPage &page) final { fNBytesCurrentCluster += page.GetNBytes(); }
0076 void CommitSealedPage(DescriptorId_t, const RSealedPage &page) final { fNBytesCurrentCluster += page.fSize; }
0077 void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final
0078 {
0079 for (auto &range : ranges) {
0080 for (auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
0081 fNBytesCurrentCluster += sealedPageIt->fSize;
0082 }
0083 }
0084 }
0085
0086 std::uint64_t CommitCluster(NTupleSize_t) final
0087 {
0088 std::uint64_t bytes = fNBytesCurrentCluster;
0089 fNBytesCurrentCluster = 0;
0090 return bytes;
0091 }
0092 void CommitClusterGroup() final {}
0093 void CommitDataset() final {}
0094 };
0095
0096 }
0097 }
0098 }
0099
0100 #endif