65 std::unique_ptr<ROOT::Internal::RColumnElementBase>
fElement;
80 auto newMaxElements =
fWritePage.GetMaxElements() * 2;
81 if (newMaxElements *
fElement->GetSize() >
fPageSink->GetWriteOptions().GetMaxUnzippedPageSize()) {
82 newMaxElements =
fPageSink->GetWriteOptions().GetMaxUnzippedPageSize() /
fElement->GetSize();
85 if (newMaxElements ==
fWritePage.GetMaxElements()) {
90 if (expandedPage.IsNull()) {
95 expandedPage.GrowUnchecked(
fWritePage.GetNElements());
104 template <
typename CppT>
105 static std::unique_ptr<RColumn>
108 auto column = std::unique_ptr<RColumn>(
new RColumn(
type, columnIdx, representationIdx));
133 std::memcpy(dst, from,
fElement->GetSize());
137 void AppendV(
const void *from, std::size_t count)
139 auto src =
reinterpret_cast<const unsigned char *
>(from);
143 if (nElementsRemaining == 0) {
148 assert(nElementsRemaining > 0);
149 auto nBatch = std::min(count, nElementsRemaining);
152 std::memcpy(dst, src, nBatch *
fElement->GetSize());
153 src += nBatch *
fElement->GetSize();
164 const auto elemSize =
fElement->GetSize();
165 void *from =
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) +
166 (globalIndex -
fReadPageRef.Get().GetGlobalRangeFirst()) * elemSize;
167 std::memcpy(to, from, elemSize);
175 const auto elemSize =
fElement->GetSize();
176 void *from =
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) +
178 std::memcpy(to, from, elemSize);
183 const auto elemSize =
fElement->GetSize();
184 auto tail =
static_cast<unsigned char *
>(to);
192 const void *from =
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) + idxInPage * elemSize;
195 std::memcpy(tail, from, elemSize * nBatch);
197 tail += nBatch * elemSize;
199 globalIndex += nBatch;
205 const auto elemSize =
fElement->GetSize();
206 auto tail =
static_cast<unsigned char *
>(to);
214 const void *from =
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) + idxInPage * elemSize;
217 std::memcpy(tail, from, elemSize * nBatch);
219 tail += nBatch * elemSize;
225 template <
typename CppT>
232 template <
typename CppT>
239 template <
typename CppT>
246 nItems =
fReadPageRef.Get().GetGlobalRangeLast() - globalIndex + 1;
247 return reinterpret_cast<CppT *
>(
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) +
248 (globalIndex -
fReadPageRef.Get().GetGlobalRangeFirst()) *
sizeof(CppT));
251 template <
typename CppT>
259 return reinterpret_cast<CppT *
>(
static_cast<unsigned char *
>(
fReadPageRef.Get().GetBuffer()) +
278 globalIndex -
fReadPageRef.Get().GetClusterInfo().GetIndexOffset());
296 auto selfOffset =
fReadPageRef.Get().GetClusterInfo().GetIndexOffset();
302 *collectionSize = idxEnd - idxStart;
312 *collectionSize = idxEnd - idxStart;
321 *tag = varSwitch->GetTag();
343 return static_cast<std::uint16_t
>(
fElement->GetBitsOnStorage());
#define R__unlikely(expr)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
RColumn(ROOT::ENTupleColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
A column element encapsulates the translation between basic C++ types and their column representation...
static std::unique_ptr< RColumnElementBase > Generate(ROOT::ENTupleColumnType type)
If CppT == void, use the default C++ type for the given column type.
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
void GetSwitchInfo(ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *varIndex, std::uint32_t *tag)
Get the currently active cluster id.
void GetCollectionInfo(RNTupleLocalIndex localIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *collectionSize)
void Read(RNTupleLocalIndex localIndex, void *to)
static std::unique_ptr< RColumn > Create(ROOT::ENTupleColumnType type, std::uint32_t columnIdx, std::uint16_t representationIdx)
RColumn(ROOT::ENTupleColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
ROOT::Internal::RPageSource * GetPageSource() const
ROOT::NTupleSize_t GetGlobalIndex(RNTupleLocalIndex clusterIndex)
void HandleWritePageIfFull()
Used when trying to append to a full write page.
std::optional< std::pair< double, double > > GetValueRange() const
void MergeTeams(RColumn &other)
RColumn & operator=(const RColumn &)=delete
ROOT::Internal::RPageStorage::ColumnHandle_t GetHandleSink() const
void ReadV(RNTupleLocalIndex localIndex, ROOT::NTupleSize_t count, void *to)
std::vector< RColumn * > fTeam
The column team is a set of columns that serve the same column index for different representation IDs...
std::uint16_t GetRepresentationIndex() const
bool ReadPageContains(ROOT::NTupleSize_t globalIndex) const
std::size_t fLastGoodTeamIdx
Points into fTeam to the column that successfully returned the last page.
CppT * Map(const ROOT::NTupleSize_t globalIndex)
CppT * MapV(RNTupleLocalIndex localIndex, ROOT::NTupleSize_t &nItems)
RNTupleLocalIndex GetClusterIndex(ROOT::NTupleSize_t globalIndex)
RColumn(const RColumn &)=delete
std::uint16_t fRepresentationIndex
Fields can have multiple column representations, distinguished by representation index.
void ConnectPageSource(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource &pageSource)
Connect the column to a page source.
ROOT::Internal::RPageSource * fPageSource
ROOT::Internal::RColumnElementBase * GetElement() const
ROOT::Internal::RPageStorage::ColumnHandle_t GetHandleSource() const
void SetBitsOnStorage(std::size_t bits)
void Read(const ROOT::NTupleSize_t globalIndex, void *to)
CppT * Map(RNTupleLocalIndex localIndex)
ROOT::ENTupleColumnType GetType() const
ROOT::NTupleSize_t GetFirstElementIndex() const
bool ReadPageContains(RNTupleLocalIndex localIndex) const
void GetCollectionInfo(const ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *collectionSize)
For offset columns only, look at the two adjacent values that define a collection's coordinates.
void AppendV(const void *from, std::size_t count)
void ReadV(ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t count, void *to)
std::size_t GetWritePageCapacity() const
ROOT::NTupleSize_t GetNElements() const
void SetValueRange(double min, double max)
ROOT::DescriptorId_t GetOnDiskId() const
ROOT::Internal::RPageRef fReadPageRef
The currently mapped page for reading.
ROOT::Internal::RPage fWritePage
The page into which new elements are being written.
CppT * MapV(const ROOT::NTupleSize_t globalIndex, ROOT::NTupleSize_t &nItems)
ROOT::Internal::RPageSink * fPageSink
ROOT::DescriptorId_t fOnDiskId
The column id in the column descriptor, once connected to a sink or source.
std::uint32_t fIndex
Columns belonging to the same field are distinguished by their order.
bool TryMapPage(ROOT::NTupleSize_t globalIndex)
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSink
ROOT::NTupleSize_t fFirstElementIndex
Global index of the first element in this column; usually == 0, unless it is a deferred column.
ROOT::NTupleSize_t fNElements
The number of elements written resp. available in the column.
void MapPage(ROOT::NTupleSize_t globalIndex)
void ConnectPageSink(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSink &pageSink, ROOT::NTupleSize_t firstElementIndex=0U)
Connect the column to a page sink.
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSource
std::uint16_t GetBitsOnStorage() const
std::uint32_t GetIndex() const
void Append(const void *from)
std::unique_ptr< ROOT::Internal::RColumnElementBase > fElement
Used to pack and unpack pages on writing/reading.
ROOT::Internal::RPageSink * GetPageSink() const
void MapPage(RNTupleLocalIndex localIndex)
ROOT::ENTupleColumnType fType
ROOT::NTupleSize_t fInitialNElements
The initial number of elements in a page.
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
RColumnHandle ColumnHandle_t
The column handle identifies a column with the current open page storage.
A page is a slice of a column that is mapped into memory.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
ROOT::NTupleSize_t GetIndexInCluster() const
ROOT::DescriptorId_t GetClusterId() const
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId