Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RPageSourceFriends.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageSourceFriends.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2020-08-10
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-2020, 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_RPageSourceFriends
17#define ROOT7_RPageSourceFriends
18
20#include <ROOT/RPageStorage.hxx>
21#include <ROOT/RSpan.hxx>
22#include <string_view>
23
24#include <memory>
25#include <vector>
26#include <unordered_map>
27
28namespace ROOT {
29namespace Experimental {
30namespace Internal {
31
32// clang-format off
33/**
34\class ROOT::Experimental::Internal::RPageSourceFriends
35\ingroup NTuple
36\brief Virtual storage that combines several other sources horizontally
37*/
38// clang-format on
39class RPageSourceFriends final : public RPageSource {
40private:
41 struct ROriginId {
42 std::size_t fSourceIdx = 0;
44 };
45
46 /// A bi-directional map of descriptor IDs that translates from physical to virtual column, field, and
47 /// cluster IDs and vice versa.
48 struct RIdBiMap {
49 std::unordered_map<DescriptorId_t, ROriginId> fVirtual2Origin;
50 std::vector<std::unordered_map<DescriptorId_t, DescriptorId_t>> fOrigin2Virtual;
51
52 void Insert(ROriginId originId, DescriptorId_t virtualId)
53 {
54 fOrigin2Virtual.resize(originId.fSourceIdx + 1);
55 fOrigin2Virtual[originId.fSourceIdx][originId.fId] = virtualId;
56 fVirtual2Origin[virtualId] = originId;
57 }
58
59 void Clear()
60 {
61 fVirtual2Origin.clear();
62 fOrigin2Virtual.clear();
63 }
64
65 DescriptorId_t GetVirtualId(const ROriginId &originId) const
66 {
67 return fOrigin2Virtual[originId.fSourceIdx].at(originId.fId);
68 }
69
71 {
72 return fVirtual2Origin.at(virtualId);
73 }
74 };
75
77 std::vector<std::unique_ptr<RPageSource>> fSources;
79
81 DescriptorId_t fNextId = 1; ///< 0 is reserved for the friend zero field
82
83 void AddVirtualField(const RNTupleDescriptor &originDesc, std::size_t originIdx, const RFieldDescriptor &originField,
84 DescriptorId_t virtualParent, const std::string &virtualName);
85
86protected:
88
89public:
90 RPageSourceFriends(std::string_view ntupleName, std::span<std::unique_ptr<RPageSource>> sources);
91
92 std::unique_ptr<RPageSource> Clone() const final;
94
95 ColumnHandle_t AddColumn(DescriptorId_t fieldId, const RColumn &column) final;
96 void DropColumn(ColumnHandle_t columnHandle) final;
97
98 RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) final;
99 RPage PopulatePage(ColumnHandle_t columnHandle, RClusterIndex clusterIndex) final;
100 void ReleasePage(RPage &page) final;
101
102 void LoadSealedPage(DescriptorId_t physicalColumnId, RClusterIndex clusterIndex, RSealedPage &sealedPage) final;
103
104 std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey> clusterKeys) final;
105
106 Detail::RNTupleMetrics &GetMetrics() final { return fMetrics; }
107}; // class RPageSourceFriends
108
109} // namespace Internal
110} // namespace Experimental
111} // namespace ROOT
112
113#endif
A collection of Counter objects with a name, a unit, and a description.
An in-memory subset of the packed and compressed pages of a cluster.
Definition RCluster.hxx:152
A helper class for piece-wise construction of an RNTupleDescriptor.
Virtual storage that combines several other sources horizontally.
std::vector< std::unique_ptr< RCluster > > LoadClusters(std::span< RCluster::RKey > clusterKeys) final
Populates all the pages of the given cluster ids and columns; it is possible that some columns do not...
void LoadSealedPage(DescriptorId_t physicalColumnId, RClusterIndex clusterIndex, RSealedPage &sealedPage) final
Read the packed and compressed bytes of a page into the memory buffer provided by selaedPage.
ColumnHandle_t AddColumn(DescriptorId_t fieldId, const RColumn &column) final
Register a new column.
std::vector< std::unique_ptr< RPageSource > > fSources
RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) final
Allocates and fills a page that contains the index-th element.
void ReleasePage(RPage &page) final
Every page store needs to be able to free pages it handed out.
std::unique_ptr< RPageSource > Clone() const final
Open the same storage multiple time, e.g. for reading in multiple threads.
void DropColumn(ColumnHandle_t columnHandle) final
Unregisters a column.
Detail::RNTupleMetrics & GetMetrics() final
Returns the default metrics object.
void AddVirtualField(const RNTupleDescriptor &originDesc, std::size_t originIdx, const RFieldDescriptor &originField, DescriptorId_t virtualParent, const std::string &virtualName)
DescriptorId_t fNextId
0 is reserved for the friend zero field
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
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Meta-data stored for every field of an ntuple.
The on-storage meta-data of an ntuple.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
A bi-directional map of descriptor IDs that translates from physical to virtual column,...
DescriptorId_t GetVirtualId(const ROriginId &originId) const
ROriginId GetOriginId(DescriptorId_t virtualId) const
std::vector< std::unordered_map< DescriptorId_t, DescriptorId_t > > fOrigin2Virtual
void Insert(ROriginId originId, DescriptorId_t virtualId)
std::unordered_map< DescriptorId_t, ROriginId > fVirtual2Origin
A sealed page contains the bytes of a page as written to storage (packed & compressed).