30#include <unordered_map>
62 std::string_view ntupleName, std::string_view location,
const RNTupleReadOptions &options)
64 return std::make_unique<RPageSourceFile>(ntupleName, location, options);
71 auto columnId = fDescriptor.FindColumnId(fieldId, column.
GetIndex());
73 fActiveColumns.emplace(columnId);
79 fActiveColumns.erase(columnHandle.
fId);
84 return fDescriptor.GetNEntries();
95 return columnHandle.
fId;
101 UnzipClusterImpl(cluster);
118 std::string_view ntupleName, std::string_view location,
const RNTupleWriteOptions &options)
120 return std::make_unique<RPageSinkFile>(ntupleName, location, options);
126 auto columnId = fLastColumnId++;
134 fDescriptorBuilder.SetNTuple(fNTupleName, model.
GetDescription(),
"undefined author",
137 std::unordered_map<const RFieldBase *, DescriptorId_t> fieldPtr2Id;
139 fDescriptorBuilder.AddField(
141 .FieldId(fLastFieldId)
145 fieldPtr2Id[&fieldZero] = fLastFieldId++;
147 fDescriptorBuilder.AddField(
153 fDescriptorBuilder.AddFieldLink(fieldPtr2Id[
f.GetParent()], fLastFieldId);
155 fieldPtr2Id[&
f] = fLastFieldId++;
158 auto nColumns = fLastColumnId;
165 fOpenColumnRanges.emplace_back(columnRange);
168 fOpenPageRanges.emplace_back(std::move(pageRange));
177 auto locator = CommitPageImpl(columnHandle, page);
179 auto columnId = columnHandle.
fId;
180 fOpenColumnRanges[columnId].fNElements += page.
GetNElements();
184 fOpenPageRanges[columnId].fPageInfos.emplace_back(pageInfo);
190 auto locator = CommitClusterImpl(nEntries);
193 fDescriptorBuilder.AddCluster(fLastClusterId,
RNTupleVersion(), fPrevClusterNEntries,
195 fDescriptorBuilder.SetClusterLocator(fLastClusterId, locator);
196 for (
auto &range : fOpenColumnRanges) {
197 fDescriptorBuilder.AddClusterColumnRange(fLastClusterId, range);
198 range.fFirstElementIndex += range.fNElements;
199 range.fNElements = 0;
201 for (
auto &range : fOpenPageRanges) {
203 std::swap(fullRange, range);
205 fDescriptorBuilder.AddClusterPageRange(fLastClusterId, std::move(fullRange));
208 fPrevClusterNEntries = nEntries;
An in-memory subset of the packed and compressed pages of a cluster.
const RColumnModel & GetModel() const
std::uint32_t GetIndex() const
RNTupleVersion GetVersion() const
NTupleSize_t GetNElements() const
static void Connect(DescriptorId_t fieldId, RPageStorage &pageStorage, RFieldBase &field)
A collection of Counter objects with a name, a unit, and a description.
RPageSink(std::string_view ntupleName, const RNTupleWriteOptions &options)
void CommitPage(ColumnHandle_t columnHandle, const RPage &page)
Write a page to the storage. The column must have been added before.
void CommitCluster(NTupleSize_t nEntries)
Finalize the current cluster and create a new one for the following data.
static std::unique_ptr< RPageSink > Create(std::string_view ntupleName, std::string_view location, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Guess the concrete derived page source from the file name (location)
ColumnHandle_t AddColumn(DescriptorId_t fieldId, const RColumn &column) final
Register a new column.
void DropColumn(ColumnHandle_t columnHandle) final
Unregisters a column.
NTupleSize_t GetNEntries()
ColumnHandle_t AddColumn(DescriptorId_t fieldId, const RColumn &column) final
Register a new column.
NTupleSize_t GetNElements(ColumnHandle_t columnHandle)
static std::unique_ptr< RPageSource > Create(std::string_view ntupleName, std::string_view location, const RNTupleReadOptions &options=RNTupleReadOptions())
Guess the concrete derived page source from the file name (location)
RPageSource(std::string_view ntupleName, const RNTupleReadOptions &fOptions)
void UnzipCluster(RCluster *cluster)
Parallel decompression and unpacking of the pages in the given cluster.
ColumnId_t GetColumnId(ColumnHandle_t columnHandle)
Common functionality of an ntuple storage for both reading and writing.
virtual RNTupleMetrics & GetMetrics()
Returns an empty metrics. Page storage implementations usually have their own metrics.
RPageStorage(std::string_view name)
A page is a slice of a column that is mapped into memory.
ClusterSize_t::ValueType GetNElements() const
RResult< RFieldDescriptor > MakeDescriptor() const
Attempt to make a field descriptor.
static RDanglingFieldDescriptor FromField(const Detail::RFieldBase &field)
Make a new RDanglingFieldDescriptor based off a live NTuple field.
RDanglingFieldDescriptor & FieldId(DescriptorId_t fieldId)
The RNTupleModel encapulates the schema of an ntuple.
std::string GetDescription() const
RNTupleUuid GetUuid() const
RNTupleVersion GetVersion() const
RFieldZero * GetFieldZero() const
Common user-tunable settings for reading ntuples.
For forward and backward compatibility, attach version information to the consitituents of the file f...
Common user-tunable settings for storing ntuples.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
constexpr DescriptorId_t kInvalidDescriptorId
The window of element indexes of a particular column in a particular cluster.
std::int64_t fCompressionSettings
The usual format for ROOT compression settings (see Compression.h).
NTupleSize_t fFirstElementIndex
A 64bit element index.
ClusterSize_t fNElements
A 32bit value for the number of column elements in the cluster.