Logo ROOT  
Reference Guide
RPageStorageRaw.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageStorageRaw.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2019-08-23
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-2019, 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_RPageStorageRaw
17#define ROOT7_RPageStorageRaw
18
19#include <ROOT/RPageStorage.hxx>
21#include <ROOT/RStringView.hxx>
22
23#include <array>
24#include <cstdint>
25#include <cstdio>
26#include <memory>
27
28namespace ROOT {
29
30namespace Internal {
31class RRawFile;
32}
33
34namespace Experimental {
35namespace Detail {
36
37class RPageAllocatorHeap;
38class RPagePool;
39
40// clang-format off
41/**
42\class ROOT::Experimental::Detail::RPageSinkRaw
43\ingroup NTuple
44\brief Storage provider that write ntuple pages into a raw binary file
45*/
46// clang-format on
47class RPageSinkRaw : public RPageSink {
48private:
49 static constexpr std::size_t kDefaultElementsPerPage = 10000;
50 /// Cannot process pages larger than 1MB
51 static constexpr std::size_t kMaxPageSize = 1024 * 1024;
52
54 std::unique_ptr<RPageAllocatorHeap> fPageAllocator;
55 std::unique_ptr<std::array<char, kMaxPageSize>> fZipBuffer;
56 FILE *fFile = nullptr;
57 size_t fFilePos = 0;
58 size_t fClusterStart = 0;
59
60 void Write(const void *buffer, std::size_t nbytes);
61
62protected:
63 void DoCreate(const RNTupleModel &model) final;
64 RClusterDescriptor::RLocator DoCommitPage(ColumnHandle_t columnHandle, const RPage &page) final;
66 void DoCommitDataset() final;
67
68public:
69 RPageSinkRaw(std::string_view ntupleName, std::string_view path, const RNTupleWriteOptions &options);
70 virtual ~RPageSinkRaw();
71
72 RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements = 0) final;
73 void ReleasePage(RPage &page) final;
74
75 RNTupleMetrics &GetMetrics() final { return fMetrics; }
76};
77
78
79// clang-format off
80/**
81\class ROOT::Experimental::Detail::RPageAllocatorFile
82\ingroup NTuple
83\brief Manages pages read from a raw file
84*/
85// clang-format on
87public:
88 static RPage NewPage(ColumnId_t columnId, void *mem, std::size_t elementSize, std::size_t nElements);
89 static void DeletePage(const RPage& page);
90};
91
92
93// clang-format off
94/**
95\class ROOT::Experimental::Detail::RPageSourceRaw
96\ingroup NTuple
97\brief Storage provider that reads ntuple pages from a raw file
98*/
99// clang-format on
101public:
102 /// Cannot process pages larger than 1MB
103 static constexpr std::size_t kMaxPageSize = 1024 * 1024;
104
105private:
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;
110
120
121 RPageSourceRaw(std::string_view ntupleName, const RNTupleReadOptions &options);
122 void Read(void *buffer, std::size_t nbytes, std::uint64_t offset);
124 const RClusterDescriptor &clusterDescriptor,
125 ClusterSize_t::ValueType clusterIndex);
126
127protected:
129
130public:
131 RPageSourceRaw(std::string_view ntupleName, std::string_view path, const RNTupleReadOptions &options);
132 std::unique_ptr<RPageSource> Clone() const final;
133 virtual ~RPageSourceRaw();
134
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;
138
139 RNTupleMetrics &GetMetrics() final { return fMetrics; }
140};
141
142} // namespace Detail
143} // namespace Experimental
144} // namespace ROOT
145
146#endif
A collection of Counter objects with a name, a unit, and a description.
A non thread-safe integral performance counter.
An either thread-safe or non thread safe counter for CPU ticks.
Manages pages read from a raw file.
static RPage NewPage(ColumnId_t columnId, void *mem, std::size_t elementSize, std::size_t nElements)
Storage provider that write ntuple pages into a raw binary file.
RClusterDescriptor::RLocator DoCommitCluster(NTupleSize_t nEntries) final
RNTupleMetrics & GetMetrics() final
Page storage implementations usually have their own metrics.
static constexpr std::size_t kMaxPageSize
Cannot process pages larger than 1MB.
RClusterDescriptor::RLocator DoCommitPage(ColumnHandle_t columnHandle, const RPage &page) final
RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements=0) final
Get a new, empty page for the given column that can be filled with up to nElements.
static constexpr std::size_t kDefaultElementsPerPage
void DoCreate(const RNTupleModel &model) final
void Write(const void *buffer, std::size_t nbytes)
std::unique_ptr< RPageAllocatorHeap > fPageAllocator
void ReleasePage(RPage &page) final
Every page store needs to be able to free pages it handed out.
std::unique_ptr< std::array< char, kMaxPageSize > > fZipBuffer
Abstract interface to write data into an ntuple.
Storage provider that reads ntuple pages from a raw file.
RNTupleTickCounter< RNTuplePlainCounter > * fCtrTimeCpuRead
RPageSourceRaw(std::string_view ntupleName, const RNTupleReadOptions &options)
void Read(void *buffer, std::size_t nbytes, std::uint64_t offset)
void ReleasePage(RPage &page) final
Every page store needs to be able to free pages it handed out.
std::unique_ptr< ROOT::Internal::RRawFile > fFile
RNTupleMetrics & GetMetrics() final
Page storage implementations usually have their own metrics.
RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) final
Allocates and fills a page that contains the index-th element.
RPage PopulatePageFromCluster(ColumnHandle_t columnHandle, const RClusterDescriptor &clusterDescriptor, ClusterSize_t::ValueType clusterIndex)
static constexpr std::size_t kMaxPageSize
Cannot process pages larger than 1MB.
RNTupleTickCounter< RNTuplePlainCounter > * fCtrTimeCpuUnzip
std::unique_ptr< std::array< unsigned char, kMaxPageSize > > fUnzipBuffer
std::unique_ptr< RPageSource > Clone() const final
Open the same storage multiple time, e.g. for reading in multiple threads.
std::unique_ptr< RPageAllocatorFile > fPageAllocator
Abstract interface to read data from an ntuple.
A page is a slice of a column that is mapped into memory.
Definition: RPage.hxx:41
Meta-data for a set of ntuple clusters.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Definition: RNTupleUtil.hxx:83
The on-storage meta-data of an ntuple.
The RNTupleModel encapulates the schema of an ntuple.
Common user-tunable settings for reading ntuples.
Common user-tunable settings for storing ntuples.
basic_string_view< char > string_view
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:43
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:75
VSD Structures.
Definition: StringConv.hxx:21
Generic information about the physical location of data.