16 #ifndef ROOT7_RPageStorageRaw
17 #define ROOT7_RPageStorageRaw
34 namespace Experimental {
37 class RPageAllocatorHeap;
47 class RPageSinkRaw :
public RPageSink {
49 static constexpr std::size_t kDefaultElementsPerPage = 10000;
51 static constexpr std::size_t kMaxPageSize = 1024 * 1024;
53 RNTupleMetrics fMetrics;
54 std::unique_ptr<RPageAllocatorHeap> fPageAllocator;
55 std::unique_ptr<std::array<char, kMaxPageSize>> fZipBuffer;
56 FILE *fFile =
nullptr;
58 size_t fClusterStart = 0;
60 void Write(
const void *buffer, std::size_t nbytes);
63 void DoCreate(
const RNTupleModel &model)
final;
64 RClusterDescriptor::RLocator DoCommitPage(ColumnHandle_t columnHandle,
const RPage &page)
final;
65 RClusterDescriptor::RLocator DoCommitCluster(NTupleSize_t nEntries)
final;
66 void DoCommitDataset() final;
69 RPageSinkRaw(std::string_view ntupleName, std::string_view path, const RNTupleWriteOptions &options);
70 virtual ~RPageSinkRaw();
72 RPage ReservePage(ColumnHandle_t columnHandle, std::
size_t nElements = 0) final;
73 void ReleasePage(RPage &page) final;
75 RNTupleMetrics &GetMetrics() final {
return fMetrics; }
86 class RPageAllocatorFile {
88 static RPage NewPage(ColumnId_t columnId,
void *mem, std::size_t elementSize, std::size_t nElements);
89 static void DeletePage(
const RPage& page);
100 class RPageSourceRaw :
public RPageSource {
103 static constexpr std::size_t kMaxPageSize = 1024 * 1024;
106 std::unique_ptr<RPageAllocatorFile> fPageAllocator;
107 std::shared_ptr<RPagePool> fPagePool;
108 std::unique_ptr<std::array<unsigned char, kMaxPageSize>> fUnzipBuffer;
109 std::unique_ptr<ROOT::Internal::RRawFile> fFile;
111 RNTupleMetrics fMetrics;
112 RNTuplePlainCounter *fCtrNRead =
nullptr;
113 RNTuplePlainCounter *fCtrSzRead =
nullptr;
114 RNTuplePlainCounter *fCtrSzUnzip =
nullptr;
115 RNTuplePlainCounter *fCtrNPages =
nullptr;
116 RNTuplePlainCounter *fCtrTimeWallRead =
nullptr;
117 RNTuplePlainCounter *fCtrTimeWallUnzip =
nullptr;
118 RNTupleTickCounter<RNTuplePlainCounter> *fCtrTimeCpuRead =
nullptr;
119 RNTupleTickCounter<RNTuplePlainCounter> *fCtrTimeCpuUnzip =
nullptr;
121 RPageSourceRaw(std::string_view ntupleName,
const RNTupleReadOptions &options);
122 void Read(
void *buffer, std::size_t nbytes, std::uint64_t offset);
123 RPage PopulatePageFromCluster(ColumnHandle_t columnHandle,
124 const RClusterDescriptor &clusterDescriptor,
125 ClusterSize_t::ValueType clusterIndex);
128 RNTupleDescriptor DoAttach() final;
131 RPageSourceRaw(std::string_view ntupleName, std::string_view path, const RNTupleReadOptions &options);
132 std::unique_ptr<RPageSource> Clone() const final;
133 virtual ~RPageSourceRaw();
135 RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) final;
136 RPage PopulatePage(ColumnHandle_t columnHandle, const RClusterIndex &clusterIndex) final;
137 void ReleasePage(RPage &page) final;
139 RNTupleMetrics &GetMetrics() final {
return fMetrics; }