Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-28 08:57:01

0001 /// \file ROOT/RPageAllocator.hxx
0002 /// \ingroup NTuple
0003 /// \author Jakob Blomer <jblomer@cern.ch>
0004 /// \date 2019-06-25
0005 
0006 /*************************************************************************
0007  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0008  * All rights reserved.                                                  *
0009  *                                                                       *
0010  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0011  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0012  *************************************************************************/
0013 
0014 #ifndef ROOT_RPageAllocator
0015 #define ROOT_RPageAllocator
0016 
0017 #include <ROOT/RNTupleUtil.hxx>
0018 #include <ROOT/RPage.hxx>
0019 
0020 #include <cstddef>
0021 #include <functional>
0022 
0023 namespace ROOT {
0024 namespace Internal {
0025 
0026 // clang-format off
0027 /**
0028 \class ROOT::Internal::RPageAllocator
0029 \ingroup NTuple
0030 \brief Abstract interface to allocate and release pages
0031 
0032 The page allocator acquires and releases memory for pages.  It does not load the page data, the returned pages
0033 are empty but guaranteed to have enough contiguous space for the given number of elements.
0034 The page allocator must be thread-safe.
0035 */
0036 // clang-format on
0037 class RPageAllocator {
0038    friend class RPage;
0039 
0040 protected:
0041    /// Releases the memory pointed to by page and resets the page's information. Note that the memory of the
0042    /// zero page must not be deleted. Called by the RPage destructor.
0043    virtual void DeletePage(RPage &page) = 0;
0044 
0045 public:
0046    virtual ~RPageAllocator() = default;
0047 
0048    /// Reserves memory large enough to hold nElements of the given size. The page is immediately tagged with
0049    /// a column id. Returns a default constructed page on out-of-memory condition.
0050    virtual RPage NewPage(std::size_t elementSize, std::size_t nElements) = 0;
0051 };
0052 
0053 // clang-format off
0054 /**
0055 \class ROOT::Internal::RPageAllocatorHeap
0056 \ingroup NTuple
0057 \brief Uses standard C++ memory allocation for the column data pages
0058 */
0059 // clang-format on
0060 class RPageAllocatorHeap : public RPageAllocator {
0061 protected:
0062    void DeletePage(RPage &page) final;
0063 
0064 public:
0065    RPage NewPage(std::size_t elementSize, std::size_t nElements) final;
0066 };
0067 
0068 } // namespace Internal
0069 } // namespace ROOT
0070 
0071 #endif