File indexing completed on 2025-01-18 10:10:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROOT7_RPageSourceFriends
0017 #define ROOT7_RPageSourceFriends
0018
0019 #include <ROOT/RNTupleMetrics.hxx>
0020 #include <ROOT/RPageStorage.hxx>
0021 #include <ROOT/RSpan.hxx>
0022 #include <string_view>
0023
0024 #include <memory>
0025 #include <vector>
0026 #include <unordered_map>
0027
0028 namespace ROOT {
0029 namespace Experimental {
0030 namespace Internal {
0031
0032
0033
0034
0035
0036
0037
0038
0039 class RPageSourceFriends final : public RPageSource {
0040 private:
0041 struct ROriginId {
0042 std::size_t fSourceIdx = 0;
0043 DescriptorId_t fId = kInvalidDescriptorId;
0044 };
0045
0046
0047
0048 struct RIdBiMap {
0049 std::unordered_map<DescriptorId_t, ROriginId> fVirtual2Origin;
0050 std::vector<std::unordered_map<DescriptorId_t, DescriptorId_t>> fOrigin2Virtual;
0051
0052 void Insert(ROriginId originId, DescriptorId_t virtualId)
0053 {
0054 fOrigin2Virtual.resize(originId.fSourceIdx + 1);
0055 fOrigin2Virtual[originId.fSourceIdx][originId.fId] = virtualId;
0056 fVirtual2Origin[virtualId] = originId;
0057 }
0058
0059 void Clear()
0060 {
0061 fVirtual2Origin.clear();
0062 fOrigin2Virtual.clear();
0063 }
0064
0065 DescriptorId_t GetVirtualId(const ROriginId &originId) const
0066 {
0067 return fOrigin2Virtual[originId.fSourceIdx].at(originId.fId);
0068 }
0069
0070 ROriginId GetOriginId(DescriptorId_t virtualId) const
0071 {
0072 return fVirtual2Origin.at(virtualId);
0073 }
0074 };
0075
0076 Detail::RNTupleMetrics fMetrics;
0077 std::vector<std::unique_ptr<RPageSource>> fSources;
0078 RIdBiMap fIdBiMap;
0079
0080 RNTupleDescriptorBuilder fBuilder;
0081 DescriptorId_t fNextId = 1;
0082
0083 void AddVirtualField(const RNTupleDescriptor &originDesc, std::size_t originIdx, const RFieldDescriptor &originField,
0084 DescriptorId_t virtualParent, const std::string &virtualName);
0085
0086 protected:
0087 RNTupleDescriptor AttachImpl() final;
0088
0089 public:
0090 RPageSourceFriends(std::string_view ntupleName, std::span<std::unique_ptr<RPageSource>> sources);
0091
0092 std::unique_ptr<RPageSource> Clone() const final;
0093 ~RPageSourceFriends() final;
0094
0095 ColumnHandle_t AddColumn(DescriptorId_t fieldId, const RColumn &column) final;
0096 void DropColumn(ColumnHandle_t columnHandle) final;
0097
0098 RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) final;
0099 RPage PopulatePage(ColumnHandle_t columnHandle, RClusterIndex clusterIndex) final;
0100 void ReleasePage(RPage &page) final;
0101
0102 void LoadSealedPage(DescriptorId_t physicalColumnId, RClusterIndex clusterIndex, RSealedPage &sealedPage) final;
0103
0104 std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey> clusterKeys) final;
0105
0106 Detail::RNTupleMetrics &GetMetrics() final { return fMetrics; }
0107 };
0108
0109 }
0110 }
0111 }
0112
0113 #endif