28#include <unordered_map>
56 return std::make_unique<RPageSourceFile>(ntupleName, location, options);
63 auto columnId = fDescriptor.FindColumnId(fieldId, column.
GetIndex());
70 return fDescriptor.GetNEntries();
75 return fDescriptor.GetNElements(columnHandle.
fId);
81 return columnHandle.
fId;
100 return std::make_unique<RPageSinkFile>(ntupleName, location, options);
106 auto columnId = fLastColumnId++;
114 fDescriptorBuilder.SetNTuple(fNTupleName, model.
GetDescription(),
"undefined author",
117 std::unordered_map<const RFieldBase *, DescriptorId_t> fieldPtr2Id;
119 fDescriptorBuilder.AddField(fLastFieldId, rootField.GetFieldVersion(), rootField.GetTypeVersion(),
120 rootField.GetName(), rootField.GetType(), rootField.GetNRepetitions(), rootField.GetStructure());
121 fieldPtr2Id[&rootField] = fLastFieldId++;
123 fDescriptorBuilder.AddField(fLastFieldId,
f.GetFieldVersion(),
f.GetTypeVersion(),
f.GetName(),
f.GetType(),
124 f.GetNRepetitions(),
f.GetStructure());
125 fDescriptorBuilder.AddFieldLink(fieldPtr2Id[
f.GetParent()], fLastFieldId);
128 fieldPtr2Id[&
f] = fLastFieldId++;
131 auto nColumns = fLastColumnId;
138 fOpenColumnRanges.emplace_back(columnRange);
141 fOpenPageRanges.emplace_back(std::move(pageRange));
150 auto locator = CommitPageImpl(columnHandle, page);
152 auto columnId = columnHandle.
fId;
153 fOpenColumnRanges[columnId].fNElements += page.
GetNElements();
157 fOpenPageRanges[columnId].fPageInfos.emplace_back(pageInfo);
163 auto locator = CommitClusterImpl(nEntries);
166 fDescriptorBuilder.AddCluster(fLastClusterId,
RNTupleVersion(), fPrevClusterNEntries,
168 fDescriptorBuilder.SetClusterLocator(fLastClusterId, locator);
169 for (
auto &range : fOpenColumnRanges) {
170 fDescriptorBuilder.AddClusterColumnRange(fLastClusterId, range);
171 range.fFirstElementIndex += range.fNElements;
172 range.fNElements = 0;
174 for (
auto &range : fOpenPageRanges) {
178 fDescriptorBuilder.AddClusterPageRange(fLastClusterId, std::move(fullRange));
181 fPrevClusterNEntries = nEntries;
const RColumnModel & GetModel() const
std::uint32_t GetIndex() const
RNTupleVersion GetVersion() const
static void Connect(DescriptorId_t fieldId, RPageStorage &pageStorage, RFieldBase &field)
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.
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)
ColumnId_t GetColumnId(ColumnHandle_t columnHandle)
Common functionality of an ntuple storage for both reading and writing.
RPageStorage(std::string_view name)
A page is a slice of a column that is mapped into memory.
ClusterSize_t::ValueType GetNElements() const
The RNTupleModel encapulates the schema of an ntuple.
std::string GetDescription() const
RFieldRoot * GetRootField() const
RNTupleUuid GetUuid() const
RNTupleVersion GetVersion() 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.
basic_string_view< char > string_view
void swap(RDirectoryEntry &e1, RDirectoryEntry &e2) noexcept
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.