Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RPageStorageS3.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageStorageS3.hxx
2/// \author Jas Mehta <jasmehta805@gmail.com>
3/// \date 2026-06-01
4
5/*************************************************************************
6 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_RPageStorageS3
14#define ROOT_RPageStorageS3
15
16#include <ROOT/RCurlConnection.hxx>
17#include <ROOT/RError.hxx>
18#include <ROOT/RNTuple.hxx>
19#include <ROOT/RPageStorage.hxx>
20
21#include <cstdint>
22#include <memory>
23#include <string>
24#include <string_view>
25
26namespace ROOT {
27namespace Experimental {
28namespace Internal {
29
30// clang-format off
31/**
32\class ROOT::Experimental::Internal::RNTupleAnchorS3
33\ingroup NTuple
34\brief Entry point for an RNTuple stored in S3-compatible object storage.
35
36The anchor is serialized as a JSON object and stored at the base URL of the ntuple.
37It contains the information needed to locate and read the header and footer envelopes.
38The anchor is always the last object written during CommitDatasetImpl, ensuring atomicity:
39if the anchor exists, the entire ntuple is complete.
40*/
41// clang-format on
43 /// Allows evolving the anchor JSON schema in future versions
44 std::uint32_t fVersionAnchor = 0;
45 /// Version of the RNTuple binary format supported by the writer
50 /// Pattern for resolving object IDs to full S3 URLs. ${baseurl} is replaced with the anchor URL,
51 /// ${objid} with the numeric object ID. Defaults to the scheme this writer uses; the reader
52 /// overrides it from the stored anchor.
53 std::string fUrlTemplate = "${baseurl}/${objid}";
54 /// Pattern for resolving clone (attribute-set) names to base URLs.
55 /// ${baseurl} is replaced with the anchor URL, ${name} with the clone name.
56 std::string fCloneTemplate = "${baseurl}/_clone/${name}";
57 /// Object ID and byte offset of the compressed header within the S3 object
58 std::uint64_t fHeaderObjId = 0;
59 std::uint64_t fHeaderOffset = 0;
60 /// Compressed and uncompressed sizes of the header envelope
61 std::uint64_t fNBytesHeader = 0;
62 std::uint64_t fLenHeader = 0;
63 /// Object ID and byte offset of the compressed footer within the S3 object
64 std::uint64_t fFooterObjId = 0;
65 std::uint64_t fFooterOffset = 0;
66 /// Compressed and uncompressed sizes of the footer envelope
67 std::uint64_t fNBytesFooter = 0;
68 std::uint64_t fLenFooter = 0;
69
70 bool operator==(const RNTupleAnchorS3 &other) const;
71
72 /// Serialize the anchor to a JSON string suitable for storage at the base URL
73 std::string ToJSON() const;
74 /// Deserialize the anchor from a JSON string. Returns an error on malformed or incompatible input.
75 static RResult<RNTupleAnchorS3> CreateFromJSON(const std::string &json);
76};
77
78/// \brief Translate an ntpl+s3 URI into its plain HTTP(S) equivalent.
79///
80/// Accepts `ntpl+s3+http://host/bucket/path` and `ntpl+s3+https://host/bucket/path`, returning the
81/// URL with the scheme replaced by http or https respectively. Returns an error result for any other
82/// scheme or a malformed URI (rather than throwing), so callers on untrusted input can handle it.
83RResult<std::string> ParseS3Url(std::string_view uri);
84
85// clang-format off
86/**
87\class ROOT::Experimental::Internal::RPageSinkS3
88\ingroup NTuple
89\brief Storage provider that writes ntuple pages into S3-compatible object storage.
90
91Currently implements Mode B (one sealed page per S3 object, kTypeObject64 locators).
92Mode A (multiple packed pages per object, kTypeMulti locators) will be added separately.
93
94\warning The S3 backend is experimental and under active development.
95*/
96// clang-format on
98private:
99 /// HTTP base URL for this ntuple (derived from the s3 scheme URI); never has a trailing slash
100 std::string fBaseUrl;
101 /// One HTTP connection reused for every upload, so curl keeps it alive across objects on the same
102 /// host instead of re-handshaking per object.
103 ROOT::Internal::RCurlConnection fConnection;
104 /// Object ID counter; incremented for each object written.
105 std::uint64_t fObjectId{0};
106 /// Tracks the number of bytes committed to the current cluster (reset in StageClusterImpl)
107 std::uint64_t fNBytesCurrentCluster{0};
108 /// Anchor metadata populated during the write path and uploaded last in CommitDatasetImpl
110
111 /// Resolve a numeric object ID to its full HTTP URL
112 std::string MakeObjectUrl(std::uint64_t objId) const;
113 /// Upload raw bytes to the given S3 URL via an HTTP PUT request
114 void PutObject(const std::string &url, const unsigned char *data, std::size_t size);
115
116 /// Tag to select the internal constructor that takes an already-resolved base URL.
117 struct RFromBaseUrl {};
118 /// Internal constructor used by CloneAsHidden: the public constructor derives the base URL by parsing
119 /// an s3 scheme URI, whereas a clone already has a resolved base URL to write under.
120 RPageSinkS3(std::string_view ntupleName, std::string_view baseUrl, const ROOT::RNTupleWriteOptions &options,
122
123protected:
125 void InitImpl(unsigned char *serializedHeader, std::uint32_t length) final;
128 std::uint64_t StageClusterImpl() final;
131 ROOT::Internal::RNTupleLink CommitDatasetImpl(unsigned char *serializedFooter, std::uint32_t length) final;
132
133public:
134 RPageSinkS3(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleWriteOptions &options);
136
137 std::unique_ptr<ROOT::Internal::RPageSink>
139}; // class RPageSinkS3
140
141} // namespace Internal
142} // namespace Experimental
143} // namespace ROOT
144
145#endif
nlohmann::json json
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
char name[80]
Definition TGX11.cxx:148
Storage provider that writes ntuple pages into S3-compatible object storage.
ROOT::Internal::RCurlConnection fConnection
One HTTP connection reused for every upload, so curl keeps it alive across objects on the same host i...
void InitImpl(unsigned char *serializedHeader, std::uint32_t length) final
std::uint64_t StageClusterImpl() final
Returns the number of bytes written to storage (excluding metadata)
RNTupleLocator CommitClusterGroupImpl(unsigned char *serializedPageList, std::uint32_t length) final
Returns the locator of the page list envelope of the given buffer that contains the serialized page l...
std::unique_ptr< ROOT::Internal::RPageSink > CloneAsHidden(std::string_view name, const ROOT::RNTupleWriteOptions &opts) const final
Creates a new sink with the same underlying storage as this but writing to a different RNTuple named ...
RNTupleAnchorS3 fAnchor
Anchor metadata populated during the write path and uploaded last in CommitDatasetImpl.
std::string MakeObjectUrl(std::uint64_t objId) const
Resolve a numeric object ID to its full HTTP URL.
std::string fBaseUrl
HTTP base URL for this ntuple (derived from the s3 scheme URI); never has a trailing slash.
RNTupleLocator CommitSealedPageImpl(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage) final
std::uint64_t fNBytesCurrentCluster
Tracks the number of bytes committed to the current cluster (reset in StageClusterImpl)
RPageSinkS3(std::string_view ntupleName, std::string_view baseUrl, const ROOT::RNTupleWriteOptions &options, RFromBaseUrl)
Internal constructor used by CloneAsHidden: the public constructor derives the base URL by parsing an...
std::uint64_t fObjectId
Object ID counter; incremented for each object written.
void PutObject(const std::string &url, const unsigned char *data, std::size_t size)
Upload raw bytes to the given S3 URL via an HTTP PUT request.
Base class for a sink with a physical storage backend.
virtual void InitImpl(unsigned char *serializedHeader, std::uint32_t length)=0
Abstract interface to write data into an ntuple.
Generic information about the physical location of data.
Common user-tunable settings for storing RNTuples.
static constexpr std::uint16_t kVersionPatch
Definition RNTuple.hxx:81
static constexpr std::uint16_t kVersionMajor
Definition RNTuple.hxx:79
static constexpr std::uint16_t kVersionEpoch
Definition RNTuple.hxx:78
static constexpr std::uint16_t kVersionMinor
Definition RNTuple.hxx:80
RResult< std::string > ParseS3Url(std::string_view uri)
Translate an ntpl+s3 URI into its plain HTTP(S) equivalent.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
Entry point for an RNTuple stored in S3-compatible object storage.
bool operator==(const RNTupleAnchorS3 &other) const
Field-by-field equality check across all data members.
std::uint64_t fHeaderObjId
Object ID and byte offset of the compressed header within the S3 object.
std::string fUrlTemplate
Pattern for resolving object IDs to full S3 URLs.
std::uint32_t fVersionAnchor
Allows evolving the anchor JSON schema in future versions.
std::uint16_t fVersionEpoch
Version of the RNTuple binary format supported by the writer.
std::string fCloneTemplate
Pattern for resolving clone (attribute-set) names to base URLs.
std::uint64_t fNBytesHeader
Compressed and uncompressed sizes of the header envelope.
std::string ToJSON() const
Serialize the anchor to a JSON string suitable for storage at the base URL.
std::uint64_t fNBytesFooter
Compressed and uncompressed sizes of the footer envelope.
static RResult< RNTupleAnchorS3 > CreateFromJSON(const std::string &json)
Deserialize the anchor from a JSON string. Returns an error on malformed or incompatible input.
std::uint64_t fFooterObjId
Object ID and byte offset of the compressed footer within the S3 object.
Tag to select the internal constructor that takes an already-resolved base URL.
A sealed page contains the bytes of a page as written to storage (packed & compressed).